Enum FontFamily

FontFamily

Veraltet. Die Methoden getFontFamily() und setFontFamily(String) verwenden jetzt Stringnamen für Schriftarten anstelle dieser Aufzählung. Diese Enum wurde zwar verworfen, bleibt aber aus Kompatibilitätsgründen mit älteren Skripts verfügbar.

Eine Aufzählung der unterstützten Schriftarten.

Verwenden Sie die Aufzählung FontFamily, um die Schriftart für einen Text-, Element- oder Dokumentbereich festzulegen.

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);