-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support for different charset encodings in PcfFontFile #3907
Conversation
Could you add a test case, something that fails without your change and passes with your change? |
Should I copy |
I would say a new test, yes. |
To do the tests I need to also include another pcf file in the Fonts directory alongside properly generated pil/pbm ones for few charsets. Is there any policy regarding what I can place there? I've been testing this using xos4 Terminus fonts amongst others. It is licensed under SIL OFL 1.1. Is it OK to add it to the repository? |
Sure. Just add another line to the list in https://github.com/python-pillow/Pillow/blob/master/Tests/fonts/LICENSE.txt |
Can confirm this bug exists. BTW, I'm wondering when it will be mergerd? |
Also, if I'm understanding the code correctly, this line again makes the whole program decodes only 256 chars from pcf file, which is not acceptable. I'm corrently working with Pillow to print Chinese Bitmap-fonts onto a screen. It's a hard time for me. |
@EletronicElephant this probably still waits for writing tests for this feature, about which I've totally forgot. |
@yawor Bad news for me. I'll have to walk around for a new method... Thank you all the same ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a full review, just a couple of quick comments.
And please could you fix the lint on CI with?
pip install -U black
black .
@hugovk regarding the lint issue, I can remove the |
Thank you! |
Add release notes for #3907 PcfFontFile charset encodings
Changes proposed in this pull request:
Currently
PcfFontFile
class outputs only bitmap pil fonts with iso8859-1 encoding, even though the PCF format supports Unicode. This makes in hard to work with Pillow with bitmap fonts in languages which use different character sets. With my PR it's possible to set different charset encoding inPcfFontFile
's class constructor. By default, it generates pil font file with iso8859-1 like before the change.Generated pil font file still contains up to 256 characters, but the character set is different depending on the selected encoding.
The change works in both Python 2 and 3.
To use such font with
ImageDraw.text
method, the method must be called with astr
(py2)/bytes
(py3) object with the same encoding as the font file.