Google 用于设置列表项字形字体的 Apps 脚本
Google Apps Script to set the List Item's Glyph font
在 Google 文档中,我正在尝试为列表项的字形(列表编号)设置字体。
我试过设置属性。只有列表项的文本字体会发生变化。但是,字形(列表编号)字体未更改。有什么办法可以改变字形字体吗?
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);
}
}
}
文档中没有提到字形字体,只有字形类型。您可以使用 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 示例。
目前还不可能。
在 Google 文档中,我正在尝试为列表项的字形(列表编号)设置字体。
我试过设置属性。只有列表项的文本字体会发生变化。但是,字形(列表编号)字体未更改。有什么办法可以改变字形字体吗?
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);
}
}
}
文档中没有提到字形字体,只有字形类型。您可以使用 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 示例。
目前还不可能。