【问题标题】:Google Apps Script to set the List Item's Glyph font用于设置列表项的字形字体的 Google Apps 脚本
【发布时间】:2017-12-20 14:45:25
【问题描述】:

在 Google Docs 中,我正在尝试为列表项的字形(列表编号)设置字体。

我尝试设置属性。只有列表项的文本字体正在更改。但是,字形(列表编号)字体保持不变。有什么办法可以改变字形字体吗?

function TEST()
{
  var document = DocumentApp.openById("1111111111111111DocumentID111111111111111");
  var docBody = document.getBody();
  var docBodyChildrenCount = docBody.getNumChildren();

  for (var i = 0; i < docBodyChildrenCount; i++){
    var child = docBody.getChild(i);
    var childType = child.getType();  
    if (childType == DocumentApp.ElementType.LIST_ITEM) {
      var childListItem = child.asListItem();
      var listItemStyle = {};
      listItemStyle[DocumentApp.Attribute.FONT_FAMILY] = DocumentApp.FontFamily.TAHOMA;
      listItemStyle[DocumentApp.Attribute.FONT_SIZE] = 14;
      var bodyChildText = childListItem.setAttributes(listItemStyle);
    }
  }
}

【问题讨论】:

  • 您不能使用应用程序脚本执行此操作真的很奇怪,因为您可以手动执行此操作....我正在尝试更改我的附加组件 Magic Rainbow 中项目符号点的颜色独角兽

标签: google-apps-script google-docs


【解决方案1】:

文档中没有提到字形字体,只有字形类型。您可以使用setGlyphType(glyphType) 设置字形类型,例如:

var body = DocumentApp.getActiveDocument().getBody();

 // Insert at list item, with the default nesting level of zero.
  body.appendListItem("Item 1");

  // Append a second list item, with a nesting level of one, indented one inch.
  // The two items will have different bullet glyphs.
  body.appendListItem("Item 2").setNestingLevel(1).setIndentStart(72)
      .setGlyphType(DocumentApp.GlyphType.SQUARE_BULLET);

来自Enum GlyphType 示例。

【讨论】:

  • 谢谢。看起来,在当前版本中,无法更改字形的字体。
【解决方案2】:

到目前为止,这是不可能的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-10
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多