如何更改字体?
How to change the font?
我想更改字体并将其样式设置为粗体。
我有两个问题:
- 更改
CharWeight
有效但无效 CharFontName
- 它将 "bold" 应用于整个段落,而不仅仅是选择
这是我的代码:
sub AddAnimation
xTextCursor = ThisComponent.CurrentController.Selection(0)
xText = xTextCursor.getText()
xText.CharFontName = "Consolas"
xText.CharWeight = com.sun.star.awt.FontWeight.BOLD
end Sub
调用 getText()
获取整个文本,而不仅仅是所选部分。
Sub ChangeFont
xTextCursor = ThisComponent.CurrentController.Selection(0)
xTextCursor.CharFontName = "Consolas"
xTextCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD
End Sub
我试的时候字体名称变了,同时使用了LO和AOO。
您在使用 CTL or CJK 脚本吗?如果是这样,则需要 CharFontNameComplex
或 CharFontNameAsian
。但是,如果 CharWeight
有效,那一定不是问题。
还有一个猜测:可能是一种样式覆盖了它。
我想更改字体并将其样式设置为粗体。 我有两个问题:
- 更改
CharWeight
有效但无效CharFontName
- 它将 "bold" 应用于整个段落,而不仅仅是选择
这是我的代码:
sub AddAnimation
xTextCursor = ThisComponent.CurrentController.Selection(0)
xText = xTextCursor.getText()
xText.CharFontName = "Consolas"
xText.CharWeight = com.sun.star.awt.FontWeight.BOLD
end Sub
调用 getText()
获取整个文本,而不仅仅是所选部分。
Sub ChangeFont
xTextCursor = ThisComponent.CurrentController.Selection(0)
xTextCursor.CharFontName = "Consolas"
xTextCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD
End Sub
我试的时候字体名称变了,同时使用了LO和AOO。
您在使用 CTL or CJK 脚本吗?如果是这样,则需要 CharFontNameComplex
或 CharFontNameAsian
。但是,如果 CharWeight
有效,那一定不是问题。
还有一个猜测:可能是一种样式覆盖了它。