[英]Apps Script to set font for current selection in Google doc
我有一些 Google Apps 腳本代碼來設置 Google 文檔中某些文本的字體。
text.setFontFamily(element.getStartOffset(), element.getEndOffsetInclusive(), "Roboto Mono");
但我想要 Roboto Mono Medium 。 我該怎么做呢? 我不確定是什么樣的實體媒體。 我認為這是一個重量。 但我沒有看到任何記錄的方式來設置權重。
當我通過給出“Roboto Mono Medium”檢查字體名稱時,它是“Roboto Mono;500”。 那么如何使用Roboto Mono;500
作為字體名稱如下?
text.setFontFamily(element.getStartOffset(), element.getEndOffsetInclusive(), "Roboto Mono");
text.setFontFamily(element.getStartOffset(), element.getEndOffsetInclusive(), "Roboto Mono;500");
檢查字體名稱的簡單示例腳本如下。 當您使用它時,請將腳本復制並粘貼到 Google Document 的腳本編輯器中,並在正文中選擇一個文本並運行該腳本。
const selection = DocumentApp.getActiveDocument().getSelection(); const text = selection.getSelectedElements()[0].getElement().asText(); console.log(text.getFontFamily()) // Check the font name.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.