【发布时间】:2020-12-25 21:15:41
【问题描述】:
如何更改 odfpy 上的字体,例如,使用 Arial 或 Comic sans。我见过一些examples,但他们只使用参数“fontsize”和“fontweight”。我找不到任何更改字体的示例,并且参数“字体”似乎不起作用。
【问题讨论】:
标签: python fonts libreoffice libreoffice-writer odfpy
如何更改 odfpy 上的字体,例如,使用 Arial 或 Comic sans。我见过一些examples,但他们只使用参数“fontsize”和“fontweight”。我找不到任何更改字体的示例,并且参数“字体”似乎不起作用。
【问题讨论】:
标签: python fonts libreoffice libreoffice-writer odfpy
api-for-odfpy.odt 中的第 5.15.39 节将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" }))
虽然,我个人无意加载这么旧的软件来测试它。
【讨论】:
'fontfamily':"Arial" 为我工作,谢谢