Enum FontFamily

FontFamily

Không dùng nữa. Các phương thức getFontFamily()setFontFamily(String) hiện sử dụng tên chuỗi cho phông chữ thay vì enum này. Mặc dù enum này không còn được dùng nữa, nhưng vẫn có khả năng tương thích với các tập lệnh cũ.

Bảng liệt kê các phông chữ được hỗ trợ.

Sử dụng giá trị liệt kê FontFamily để đặt phông chữ cho một loạt văn bản, phần tử hoặc tài liệu.

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