已弃用。getFontFamily()
和 setFontFamily(String)
方法现在为字体使用字符串名称,而不是此枚举。虽然此枚举已被弃用,但仍然可供使用,以便与旧版脚本兼容。
枚举受支持字体。
使用 FontFamily
枚举设置一系列文本、元素或文档的字体。
var body = DocumentApp.getActiveDocument().getBody(); // Insert a paragraph at the start of the document. body.insertParagraph(0, "Hello, Apps Script!"); // Set the document font to Calibri. body.editAsText().setFontFamily(DocumentApp.FontFamily.CALIBRI); // Set the first paragraph font to Arial. body.getParagraphs()[0].setFontFamily(DocumentApp.FontFamily.ARIAL); // Set "Apps Script" to Comic Sans MS. var text = 'Apps Script'; var a = body.getText().indexOf(text); var b = a + text.length - 1; body.editAsText().setFontFamily(a, b, DocumentApp.FontFamily.COMIC_SANS_MS);