Enum FontFamily

FontFamily

已淘汰。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);