2

我想更改字体并将其样式设置为粗体。我有两个问题:

  • 改变CharWeight作品但不改变CharFontName
  • 它将“粗体”应用于整个段落,而不仅仅是选择

这是我的代码:

sub AddAnimation
    xTextCursor = ThisComponent.CurrentController.Selection(0)
    xText = xTextCursor.getText()
    xText.CharFontName = "Consolas"
    xText.CharWeight = com.sun.star.awt.FontWeight.BOLD
end Sub
4

1 回答 1

1

调用getText()获取整个文本,而不仅仅是选定的部分。

Sub ChangeFont
    xTextCursor = ThisComponent.CurrentController.Selection(0)
    xTextCursor.CharFontName = "Consolas"
    xTextCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD
End Sub

当我尝试使用 LO 和 AOO 时,字体名称发生了变化。

结果

您使用的是CTL 还是 CJK脚本?如果是这样,那么它需要是CharFontNameComplexor CharFontNameAsian。但是,如果CharWeight有效,那么这一定不是问题。

还有一个猜测:也许一种风格压倒了它。

于 2017-04-03T17:51:46.810 回答