-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Added FreeTypeFont has_characters() #9160
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
base: main
Are you sure you want to change the base?
Conversation
1fd230e to
97e7a97
Compare
|
I'm on the fence with this. It feels outside the core focus of Pillow, and it's not too tricky to do this with Pillow in Python: Plus it's a even easier with a dedicated FreeType library: |
|
A font is roughly a collection of images and checking if an image exists in the collection is pretty basic functionality? Of course it's doable in other ways but:
|
023d11c to
952711a
Compare
952711a to
acc4816
Compare
|
If there is no consensus on this, should the issue be closed? We can always return to the idea again if someone else raises it in the future. |
|
Any downside assuming we determine it's in scope? |
|
To adding the code? Only the usual theoretical maintenance burden. But it's a new method, so it doesn't affect anything else, and it's relatively simple code, so I can't foresee any problems. To returning to it later? No. I don't see us refactoring the underlying font handling that this method relies on anytime soon. |
Resolves #9158. The issue requested a method to check if glyphs are present in a font. This question has arisen previously in #7380 (comment), and I think this would also help users from #4808, in a less elegant way.
This adds
FreeTypeFont.has_characters(text). I expect that the issue was only thinking about checking a single character at a time, but if user wanted to check multiple characters at once, I don't see any reason not to let them. If any character in the string is missing, thenFalseis returned.The C code in here is based on
Pillow/src/_imagingft.c
Lines 432 to 463 in 9d39fe6