Stay organized with collections
Save and categorize content based on your preferences.
AI-generated Key Takeaways
The FontFamily enumeration is deprecated.
The methods getFontFamily() and setFontFamily(String) now use string names for fonts.
The FontFamily enumeration remains available for compatibility with older scripts.
You can use the FontFamily enumeration to set the font for text, elements, or documents.
FontFamily
Deprecated. The methods getFontFamily() and setFontFamily(String) now use string
names for fonts instead of this enum. Although this enum is deprecated, it will remain
available for compatibility with older scripts.
An enumeration of the supported fonts.
Use the FontFamily enumeration to set the font for a range of text, element or
document.
constbody=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.consttext='Apps Script';consta=body.getText().indexOf(text);constb=a+text.length-1;body.editAsText().setFontFamily(a,b,DocumentApp.FontFamily.COMIC_SANS_MS);
[null,null,["Last updated 2024-12-02 UTC."],[],["`FontFamily` enumeration, though deprecated, remains for older script compatibility. It lists supported font options like `ARIAL`, `CALIBRI`, and `COMIC_SANS_MS`. The methods `getFontFamily()` and `setFontFamily(String)` now use string names, and `FontFamily` is used to apply a specific font to document text, paragraphs, or specific ranges within text, via methods like `setFontFamily()`. There are multiple examples showing the usage of the font `FontFamily`.\n"]]