Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify localized forms of CJK scripts in ImageFont? #5041

Closed
SunHaozhe opened this issue Nov 14, 2020 · 2 comments
Closed

How to specify localized forms of CJK scripts in ImageFont? #5041

SunHaozhe opened this issue Nov 14, 2020 · 2 comments

Comments

@SunHaozhe
Copy link

SunHaozhe commented Nov 14, 2020

CJK scripts (CJK Unified Ideographs) share the same Unicode code points, the distinction between simplified Chinese, traditional Chinese and Kanji can only be handled by the font.

Some fonts support several forms (simplified Chinese, traditional Chinese, Kanji, etc.) at the same time. Some people suggest that this can be specified using locl, some others suggest that this should be specified using langsys. Anyway, my objective is to specify the form of CJK scripts with PIL's ImageFont or the FreeTypeFont object.

How can I specify the form to use when working with PIL package? Is this specification even possible with PIL version 8.0.1?

image_font = ImageFont.truetype(font="Arial Unicode.ttf", size=10) # PIL.ImageFont.FreeTypeFont object

I asked this question first on Stack Overflow, but it seems that this is something I should ask on your issue tracker. This feature can be useful for a lot of people.

@nulano
Copy link
Contributor

nulano commented Nov 15, 2020

I think this can be done using the language parameter added in #3693.

See documentation here (scroll down to the language parameter, I can't link to the parameter directly): https://pillow.readthedocs.io/en/stable/reference/ImageDraw.html#PIL.ImageDraw.ImageDraw.text

@radarhere radarhere changed the title How to specify localized forms of CJK scripts in Python's PIL ImageFont? How to specify localized forms of CJK scripts in ImageFont? Nov 15, 2020
@SunHaozhe
Copy link
Author

Thanks a lot! This resolved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@nulano @SunHaozhe and others