I want to change the font and set its style to bold. I have two problems:
CharWeight
works but not CharFontName
Here's my code:
sub AddAnimation
xTextCursor = ThisComponent.CurrentController.Selection(0)
xText = xTextCursor.getText()
xText.CharFontName = "Consolas"
xText.CharWeight = com.sun.star.awt.FontWeight.BOLD
end Sub
Calling getText()
gets the entire text, not just the selected part.
Sub ChangeFont
xTextCursor = ThisComponent.CurrentController.Selection(0)
xTextCursor.CharFontName = "Consolas"
xTextCursor.CharWeight = com.sun.star.awt.FontWeight.BOLD
End Sub
The font name changed when I tried it, using both LO and AOO.
Are you using CTL or CJK scripts? If so, then it needs to be CharFontNameComplex
or CharFontNameAsian
. However if CharWeight
worked, then that must not be the issue.
One more guess: Maybe a style is overriding it.