-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Is it possible to use colored Whatsapp/Facebook emoji? #3346
Comments
I think this is not implemented. But have somebody ideas to do a workaround? For example to tranform the emoji to a image and open the image and render it in text. |
A workaround is to call something like ImageMagick to create an image of the emoji, then open that. For example, https://stackoverflow.com/a/52131155/724176 |
this does not work under linux |
Does this still happen? How about when using a Noto font? |
Noto Emoji gives black and white emojis, and Noto Color Emoji fails to load with |
This error is due to a freetype limitation. Bitmap fonts don't support scaling with freetype, so you must specify a valid size, which is 109 for Noto Color Emoji. Additionally, freetype must be built with libpng to support this font (png bitmaps). However, due to #960, bitmap fonts will not work with Pillow at all. And even if they did, you would get a grayscale version of the emojis, because Pillow only returns one channel from the C layer font functions. Note: I am working on improving some of this, I just need to write some tests to submit a PR. |
it looks like FreeType 2.10.0 adds support for COLR/CPAL tables, which Noto Color Emoji uses for scalable color emoji glyphs. could this be taken advantage of to add support for this type of emoji font to Pillow? |
@boringcactus I've got it partially implemented, but it is not PR ready. I'm not sure when I'll have time to work on it, but it will be either next week or a few weeks later. |
cough |
I ended up working on #4724 first π and postponed this until that gets merged to avoid merge conflicts. Thinking about it again, I don't think these two actually conflict too badly, so perhaps I can submit this soon as well. I'm hoping both of these can be included in version 8.0.0 planned for release in 6 weeks. |
Ah thanks, if you have the patch could you send it to me? I can implement it locally |
See my branch nulano/Pillow@06ba083...nulano:ft-color. IIRC it should work, but there are some extra unnecessary changes that should be removed, and parts of it can be simplified, before submitting it as a PR. Please treat it as a WIP, the API will likely change in the final version. |
Hey, can you send me a compiled version for windows? |
I've re-triggered the GHA run, you can get wheels there: https://github.com/nulano/Pillow/actions/runs/232647949 |
I'm dumb, how do I install it with that? |
Not dumb, it's not so obvious! :) If you click dist"-ft-color" under Artifacts it'll download a zip file. Extract that, and then |
Hey, thank you so much, the new version installed correctly # -*- coding: utf-8 -*-
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import os
im = Image.open('purple.png')
draw = ImageDraw.Draw(im)
font = ImageFont.truetype('seguiemj.ttf', 64, encoding = 'unic')
textToDraw = u'π'
print(textToDraw)
draw.text((20,20), textToDraw, (255,255,255), font=font)
im.show() |
For backwards compatibility you have enable color support using |
POG IT WORKS thank you so much man |
Also, is there a way to have a secondary font for mission glyphs? like many fonts don't have emoji and ideally I want to support them still |
See #4808. Edit: fix link typo. The best you can do for now is use |
Pillow 8.0.0 has now been released, adding support for CBDT and COLR fonts. Edit: SBIX is supported in Pillow 8.0.0. |
@nulano I tried Pillow 9.0 and it seems that I still can not use noto color emoji font. The same error persists:
|
@jdhao would you be able to create a new issue with a self-contained example, and information about your environment? |
Okay, will do it: #6166. |
What did you do?
What did you expect to happen?
Is it possible to show colored Whatsapp oder Facebook Emoji?
What actually happened?
For the woman emoji i only get a white rect.
What versions of Pillow and Python are you using?
Pillow 3.1.2
Python 3.5.2
The text was updated successfully, but these errors were encountered: