我有一些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.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句