1

我想更改字體並將其樣式設置爲粗體。 我有兩個問題:如何更改字體?

  • 改變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 
+0

當前設置的字體名稱是什麼?嘗試從空文檔開始並創建一個文本塊。 –

回答

0

調用getText()獲取整個文本,而不僅僅是選定的部分。

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

當我嘗試使用LO和AOO時,字體名稱改變了。

result

是否使用CTL or CJK腳本?如果是這樣,那麼它需要是CharFontNameComplexCharFontNameAsian。但是,如果CharWeight工作,那肯定不是問題。

還有一種猜測:也許一種風格是壓倒它。

+0

如何改變風格呢? –

+0

轉到側邊欄中的「樣式和格式」,看看是否有問題。顯然相關的樣式被稱爲[Graphic Styles](https://help.libreoffice.org/Impress/Styles_and_Formatting#Graphic_Styles)。 –