0

如何更改 odfpy 上的字体,例如,使用 Arial 或 Comic sans。我见过一些例子,但他们只使用参数“fontsize”和“fontweight”。我找不到任何更改字体的示例,并且参数“字体”似乎不起作用。

4

1 回答 1

0

第 5.15.39 节api-for-odfpy.odt列出style.TextProperties如下:

    5.15.39  style.TextProperties
    Requires the following attributes: No attribute is required.
    Allows the following attributes: backgroundcolor, color, condition, country,
 countryasian, countrycomplex, display, fontcharset, fontcharsetasian,
 fontcharsetcomplex, fontfamily, fontfamilyasian, fontfamilycomplex,
 fontfamilygeneric, fontfamilygenericasian, fontfamilygenericcomplex, fontname,
fontnameasian, fontnamecomplex, fontpitch, fontpitchasian, fontpitchcomplex,
 fontrelief, fontsize, fontsizeasian, fontsizecomplex, fontsizerel, fontsizerelasian,
 fontsizerelcomplex, fontstyle, fontstyleasian, fontstylecomplex, fontstylename,
 fontstylenameasian, fontstylenamecomplex, fontvariant, fontweight, fontweightasian,
 fontweightcomplex, hyphenate, hyphenationpushcharcount, hyphenationremaincharcount, language, languageasian, languagecomplex, letterkerning, letterspacing, scripttype,
 textblinking, textcombine, textcombineendchar, textcombinestartchar, textemphasize,
 textlinethroughcolor, textlinethroughmode, textlinethroughstyle, textlinethroughtext,
 textlinethroughtextstyle, textlinethroughtype, textlinethroughwidth, textoutline,
 textposition, textrotationangle, textrotationscale, textscale, textshadow,
 texttransform, textunderlinecolor, textunderlinemode, textunderlinestyle, 
textunderlinetype, textunderlinewidth, usewindowfontcolor.

我假设它们可以以与fontsize和相同的方式访问fontweight,如下所示:

h1style.addElement(TextProperties(attributes={'fontsize':"24pt",'fontweight':"bold" }))

虽然,我个人无意加载这么旧的软件来测试它。

于 2020-12-26T09:34:48.207 回答