Using custom font in linux failed #4923
-
We are using this code to try inserting text with a custom font. It works correctly on Windows, but on Linux it throws the error: "Exception: need font file or buffer", and the custom font is not applied successfully—all Chinese characters are displayed as "?". We have tried directly using fontfile in insert_textbox, and we have already ruled out version and environment differences, but still no success. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Have you confirmed that You can always use the built-in CJK font. It supports Latin, Chinese, Korean and Japanese. cjk = pymupdf.Font("cjk")
fontname = "mycjk"
# then for each page where you need it:
page.insert_font(fontname=fontname, fontbuffer=cjk.buffer)
# text insertions do this:
page.insert_text(..., fontname=fontname, ...)
...This ensures that a full blown font is used with a large range of languages. |
Beta Was this translation helpful? Give feedback.
Have you confirmed that
simsun.ttfactually exists on your Linux system? The backslash in any case cannot be used on a Linux system ...You can always use the built-in CJK font. It supports Latin, Chinese, Korean and Japanese.
Try this:
This ensures that a full blown font is used with a large range of languages.