Closed novadev94 closed 4 years ago
👍 I'm also experiencing this issue
symbola.ttf can be found here.
If you replace 😞
with the Python source code U0001F61E
I get this on Ubuntu 14.04 (Python 2.7.6, Pillow 3.2.0):
But I still get this on Windows 7 (Python 2.7.11, Pillow 3.2.0):
(Here's the same thing reported but unsolved on Stack Overflow, confirming the problem on Mac and Windows but not Ubuntu.)
Same issue unfortunately 😦
Mac OS X 10.11.5, Python 2.7.10, Pillow 3.3.0.
Has anyone had any progress on this issue? I'm trying to do the same thing on OS X Sierra (10.12.1) with Python 3 and Pillow 3.4.2 (and will need to achieve the same on Ubuntu as well)
The cnblog linked above google translates as:
I inserted some code inside the debugging information, positioning the problem occurred in the function call FT_Set_Pixel_Sizes inside, which is a freetype function call. Is it not freetype emoji fonts?
Continue to trace freetype, I found freetype 2.5 is called from the beginning to support the color font, I use the 2.6, should be no problem.
I https://gist.github.com/jokertarot/7583938 to find a color font support code, a closer look at the first three steps to use freetype:
1, call Init initialization library
2, construct FreeTypeFace object, generate typeface
3, call SetXXXFont, note that in this step ordinary font and Color font is not the same, ordinary font calls SetNormalFont, internal call FT_Set_Pixel_Sizes; and Color font call SetColorFont, internal call FT_Select_Size
Looking back Pillow-master / _imagingft.c the getfont function, he is not distinguish between NormalFont and ColorFont, according to NormalFont to deal with, so wrong.
This should be the core issue: freetype support color font, but in the specific treatment of the need to use a different interface in the Pillow this layer is not taken into account, it is Pillow can not support color font. To solve the problem, you must make the changes in getfont in Pillow-master / _imagingft.c.
Freetype that support color font code I have not tried, go back and then specialized study.
So it does seem that it's possible with freetype, it's a matter of building it in.
Current status with Pillow 4.2.1:
# -*- coding: utf-8 -*-
from PIL import Image, ImageFont, ImageDraw
text = u'A😞B'
# text = u'A\U0001F61EB'
image = Image.new('RGB', (100, 50), 'white')
font = ImageFont.truetype('Symbola.ttf', size=36, encoding='unic')
draw = ImageDraw.Draw(image)
draw.text((0, 0), text, (0, 0, 0), font=font)
image.show()
text |
OS | Python | Result |
---|---|---|---|
u'A😞B' |
Ubuntu 16.04.2 LTS | Python 2.7.12 | ![]() |
u'A😞B' |
Ubuntu 16.04.2 LTS | Python 3.5.2 | ![]() |
u'A\U0001F61EB' |
Ubuntu 16.04.2 LTS | Python 2.7.12 | ![]() |
u'A\U0001F61EB' |
Ubuntu 16.04.2 LTS | Python 3.5.2 | ![]() |
u'A😞B' |
macOS Sierra 10.12.5 | Python 2.7.13 | ![]() |
u'A😞B' |
macOS Sierra 10.12.5 | Python 3.6.2 | ![]() |
u'A\U0001F61EB' |
macOS Sierra 10.12.5 | Python 2.7.13 | ![]() |
u'A\U0001F61EB' |
macOS Sierra 10.12.5 | Python 3.6.2 | ![]() |
u'A😞B' |
Windows 7 | Python 2.7.11 | ![]() |
u'A😞B' |
Windows 7 | Python 3.5.0 | ![]() |
u'A\U0001F61EB' |
Windows 7 | Python 2.7.11 | ![]() |
u'A\U0001F61EB' |
Windows 7 | Python 3.5.0 | ![]() |
Just checking if there's any hope to see it fixed on Windows in the not-too-distant future?
With Linux Mint it does no work. There are only questionmarks
Bump. I see only a square box on mac. I tried putting u"My ✨ string here", I tried with u"\U0001f44d" too.
@hugovk Can you check this again with Pillow 6.1? This looks to me like another duplicate of #3777 which was fixed in #3780 for Python 3.x.
@quantumpotato What Python version did you use? It works for me with the emoji and code from https://github.com/python-pillow/Pillow/issues/1774#issuecomment-330820569 on Mac with Python 3, but not Python 2 (so as before). It's quite possible this won't get fixed for Python 2 before the EOL on 2020-01-01.
@nulano I don't have a Windows machine handy at the moment to retest with Python 3. Would be good if someone else can.
I just tried it with Pillow 6.1 on Windows 10 and it works with Python 3.7 but not with Python 2.7, so same as Mac before.
Closing because the next major release, Pillow 7.0.0, only supports Python 3.
Closing because the next major release, Pillow 7.0.0, only supports Python 3.
Same issue Pillow version: 7.1.2 Python version: 3.8.2 font: Apple Color Emoji.ttf OS: ubuntu 20 & windows 10
@alisentinel The OSError is explained in https://github.com/python-pillow/Pillow/issues/1422#issuecomment-636795697:
The FreeType library, which Pillow uses to handle fonts, doesn't allow scaling of bitmap fonts. The only option is to render at a supported size and scale the output yourself.
The sizes available in Apple Color Emoji.ttf
are (according to https://github.com/python-pillow/Pillow/issues/1422#issuecomment-140056288):
Testing, I found that the following sizes work - 20, 32, 40, 48, 64, 96, 160
Also note that Pillow currently doesn't support colour in fonts, see #3346. The output will be an outline of the shape.
If we are talking about a text with colored emoji support WITHOUT using many fonts (>=1
), there are APIs that provide emoji images.
You could calculate spacing for each line and character and use emojicdn.elk.sh API as an example.
I used pilmoji to get around this!
I used pilmoji to get around this!
Pilmoji is trash which needs access to remove servers. That is a certified clown activity
lol
I want to use Pillow to render text with emojis, to get it easy, I've used a font named
Symbola
.But seem like it doesn't succeed![image](https://cloud.githubusercontent.com/assets/6073918/13809905/a6520648-eb9f-11e5-8f16-4e92e3f08072.png)
When I switched to
Apple Color Emoji
, I have another problem on lineSo what should I do to be able to render emojis?
May related to https://github.com/python-pillow/Pillow/issues/1422
Also someone has reported a problem about
ColorFont
support inFreeType
(this is a Chinese blog) http://www.cnblogs.com/palance/p/4809872.html