How to customize the font in the insert_textbox function #3935
-
When using the insert_textbox function, I want to use some Chinese fonts, such as SimSum.ttf. I checked the source code of the function and found that it doesn't support this font. It's also not possible to directly assign a local font file path. How should I proceed to make the inserted text use the SimSum.ttf font? tks page.insert_textbox(rect,
nowPage,
fontsize=int(pageFontSet.fontSize),
fontname='D:\\SimSum.ttf',
color=pageFontSet.fontColor,
align=TEXT_ALIGN_CENTER,
overlay=True) # |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This is not an issue, but a Discussions item. |
Beta Was this translation helpful? Give feedback.
-
To support a font file or a font in memory, use the page.insert_font(fontname="myfont", fontfile='D:\\SimSum.ttf') # or fontbuffer=...
page.insert_textbox(...., fontname="myfont") |
Beta Was this translation helpful? Give feedback.
To support a font file or a font in memory, use the
page.insert_font()
method.In general please note that the "fontname" parameter is not the font filename!
This is a symbolic name (like a variable name) by which the font is referenced.
Therefore, do this: