Enum FontFamily

字体系列

已弃用。方法 getFontFamily()setFontFamily(String) 现在使用字符串名称来表示字体,而不是此枚举。虽然此枚举已废弃,但仍可供与旧脚本兼容。

受支持的字体的枚举。

使用 FontFamily 枚举为一系列文本、元素或文档设置字体。

const body =     DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();  // Insert a paragraph at the start of the document. body.insertParagraph(0, 'Hello, Apps Script!');  // Set the tab 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. const text = 'Apps Script'; const a = body.getText().indexOf(text); const b = a + text.length - 1; body.editAsText().setFontFamily(a, b, DocumentApp.FontFamily.COMIC_SANS_MS);