Enum FontFamily
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ชุดแบบอักษร
เลิกใช้งานแล้ว ตอนนี้เมธอด getFontFamily()
และ setFontFamily(String)
ใช้ชื่อสตริงสำหรับแบบอักษรแทนการใช้ enum นี้ แม้ว่าเราจะเลิกใช้งาน Enum นี้แล้ว แต่ Enum นี้จะยังคงใช้งานได้เพื่อใช้งานร่วมกับสคริปต์รุ่นเก่า
การแจกแจงแบบอักษรที่รองรับ
ใช้การแจกแจง 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);
พร็อพเพอร์ตี้ที่เลิกใช้งานแล้ว
พร็อพเพอร์ตี้ | ประเภท | คำอธิบาย |
AMARANTH | Enum | ชุดแบบอักษร Amaranth |
ARIAL | Enum | ชุดแบบอักษร Arial |
ARIAL_BLACK | Enum | ชุดแบบอักษร Arial Black |
ARIAL_NARROW | Enum | ชุดแบบอักษร Arial Narrow |
ARVO | Enum | ชุดแบบอักษร Arvo |
CALIBRI | Enum | ชุดแบบอักษร Calibri |
CAMBRIA | Enum | ชุดแบบอักษร Cambria |
COMIC_SANS_MS | Enum | ชุดแบบอักษร Comic Sans MS |
CONSOLAS | Enum | ชุดแบบอักษร Consolas |
CORSIVA | Enum | ชุดแบบอักษร Corsiva |
COURIER_NEW | Enum | ชุดแบบอักษร Courier New |
DANCING_SCRIPT | Enum | ชุดแบบอักษร Dancing Script |
DROID_SANS | Enum | ชุดแบบอักษร Droid Sans |
DROID_SERIF | Enum | ชุดแบบอักษร Droid Serif |
GARAMOND | Enum | ชุดแบบอักษร Garamond |
GEORGIA | Enum | ชุดแบบอักษร Georgia |
GLORIA_HALLELUJAH | Enum | ชุดแบบอักษร Gloria Hallelujah |
GREAT_VIBES | Enum | ชุดแบบอักษร Great Vibes |
LOBSTER | Enum | ชุดแบบอักษร Lobster |
MERRIWEATHER | Enum | ชุดแบบอักษร Merriweather |
PACIFICO | Enum | ชุดแบบอักษร Pacifico |
PHILOSOPHER | Enum | ชุดแบบอักษร Philosopher |
POIRET_ONE | Enum | ชุดแบบอักษร Poiret One |
QUATTROCENTO | Enum | ชุดแบบอักษร Quattrocento |
ROBOTO | Enum | ชุดแบบอักษร Roboto |
SHADOWS_INTO_LIGHT | Enum | ชุดแบบอักษร Shadows Into Light |
SYNCOPATE | Enum | ชุดแบบอักษร Syncopate |
TAHOMA | Enum | ชุดแบบอักษร Tahoma |
TIMES_NEW_ROMAN | Enum | ชุดแบบอักษร Times New Roman |
TREBUCHET_MS | Enum | ชุดแบบอักษร Trebuchet MS |
UBUNTU | Enum | ชุดแบบอักษร Ubuntu |
VERDANA | Enum | ชุดแบบอักษร Verdana |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eFontFamily\u003c/code\u003e is deprecated and now uses string names for fonts instead of the enum, but remains for compatibility.\u003c/p\u003e\n"],["\u003cp\u003eThis enum allows you to set the font for text ranges, elements, or entire Google Docs documents.\u003c/p\u003e\n"],["\u003cp\u003eSupported fonts include Arial, Calibri, Comic Sans MS, Times New Roman, Verdana, and many more.\u003c/p\u003e\n"],["\u003cp\u003eYou can use methods like \u003ccode\u003esetFontFamily()\u003c/code\u003e within Google Apps Script to apply these fonts.\u003c/p\u003e\n"]]],["`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"],null,["# Enum FontFamily\n\nFontFamily\n\n\n**Deprecated.** The methods `get``Font``Family()` and `set``Font``Family(String)` now use string\nnames for fonts instead of this enum. Although this enum is deprecated, it will remain\navailable for compatibility with older scripts.\n\nAn enumeration of the supported fonts.\n\nUse the `Font``Family` enumeration to set the font for a range of text, element or\ndocument.\n\n```javascript\nconst body =\n DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();\n\n// Insert a paragraph at the start of the document.\nbody.insertParagraph(0, 'Hello, Apps Script!');\n\n// Set the tab font to Calibri.\nbody.editAsText().setFontFamily(DocumentApp.FontFamily.CALIBRI);\n\n// Set the first paragraph font to Arial.\nbody.getParagraphs()[0].setFontFamily(DocumentApp.FontFamily.ARIAL);\n\n// Set \"Apps Script\" to Comic Sans MS.\nconst text = 'Apps Script';\nconst a = body.getText().indexOf(text);\nconst b = a + text.length - 1;\nbody.editAsText().setFontFamily(a, b, DocumentApp.FontFamily.COMIC_SANS_MS);\n``` \n\n### Deprecated properties\n\n| Property | Type | Description |\n|----------------------|--------|-------------------------------------|\n| `AMARANTH` | `Enum` | The Amaranth font family. |\n| `ARIAL` | `Enum` | The Arial font family. |\n| `ARIAL_BLACK` | `Enum` | The Arial Black font family. |\n| `ARIAL_NARROW` | `Enum` | The Arial Narrow font family. |\n| `ARVO` | `Enum` | The Arvo font family. |\n| `CALIBRI` | `Enum` | The Calibri font family. |\n| `CAMBRIA` | `Enum` | The Cambria font family. |\n| `COMIC_SANS_MS` | `Enum` | The Comic Sans MS font family. |\n| `CONSOLAS` | `Enum` | The Consolas font family. |\n| `CORSIVA` | `Enum` | The Corsiva font family. |\n| `COURIER_NEW` | `Enum` | The Courier New font family. |\n| `DANCING_SCRIPT` | `Enum` | The Dancing Script font family. |\n| `DROID_SANS` | `Enum` | The Droid Sans font family. |\n| `DROID_SERIF` | `Enum` | The Droid Serif font family. |\n| `GARAMOND` | `Enum` | The Garamond font family. |\n| `GEORGIA` | `Enum` | The Georgia font family. |\n| `GLORIA_HALLELUJAH` | `Enum` | The Gloria Hallelujah font family. |\n| `GREAT_VIBES` | `Enum` | The Great Vibes font family. |\n| `LOBSTER` | `Enum` | The Lobster font family. |\n| `MERRIWEATHER` | `Enum` | The Merriweather font family. |\n| `PACIFICO` | `Enum` | The Pacifico font family. |\n| `PHILOSOPHER` | `Enum` | The Philosopher font family. |\n| `POIRET_ONE` | `Enum` | The Poiret One font family |\n| `QUATTROCENTO` | `Enum` | The Quattrocento font family. |\n| `ROBOTO` | `Enum` | The Roboto font family |\n| `SHADOWS_INTO_LIGHT` | `Enum` | The Shadows Into Light font family. |\n| `SYNCOPATE` | `Enum` | The Syncopate font family. |\n| `TAHOMA` | `Enum` | The Tahoma font family. |\n| `TIMES_NEW_ROMAN` | `Enum` | The Times New Roman font family. |\n| `TREBUCHET_MS` | `Enum` | The Trebuchet MS font family. |\n| `UBUNTU` | `Enum` | The Ubuntu font family. |\n| `VERDANA` | `Enum` | The Verdana font family. |"]]