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

ImageFont cannot support AppleColorEmoji.ttf on MAC #1422

Closed
palanceli opened this issue Sep 14, 2015 · 8 comments
Closed

ImageFont cannot support AppleColorEmoji.ttf on MAC #1422

palanceli opened this issue Sep 14, 2015 · 8 comments

Comments

@palanceli
Copy link

I want to convert emoji to a png on MAC, but I failed to create font. My code is below:

font = PIL.ImageFont.truetype('/System/Library/Fonts/Apple Color Emoji.ttf', 16, encoding='unic')

I got error below:

  File "test.py", line 37, in TestEmoji

    font = PIL.ImageFont.truetype('/System/Library/Fonts/Apple Color Emoji.ttf', 16, encoding='unic')

  File "/Library/Python/2.7/site-packages/PIL/ImageFont.py", line 290, in truetype

    return FreeTypeFont(fontpath, size, index, encoding)

  File "/Library/Python/2.7/site-packages/PIL/ImageFont.py", line 140, in __init__

    self.font = core.getfont(font, size, index, encoding)

IOError: invalid pixel size
@radarhere
Copy link
Member

Testing, I found that the following sizes work - 20, 32, 40, 48, 64, 96, 160

@radarhere
Copy link
Member

I think that the font only supports those sizes, and so this error is valid. If you disagree, please say so. If you think the error should be a different one, please say so, and the issue can be re-opened.

For the moment however, I think there is nothing to do here, and this can be closed.

@freeIsa
Copy link

freeIsa commented Jun 1, 2020

Just found the same issue.

Testing, I found that the following sizes work - 20, 32, 40, 48, 64, 96, 160

Just to be clear, is there any way to make it work with "arbitrary" sizes?

@nulano
Copy link
Contributor

nulano commented Jun 1, 2020

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.

@NightMachinery
Copy link

The emojis are rendered black and white. Is this intended? It also can't render any normal text ...

@NightMachinery
Copy link

The color support can be fixed with #4955 .

@jdhao
Copy link

jdhao commented Apr 2, 2022

For anyone interested, you may need to loop through different font sizes to find the correct size to use for the color font.

I tried the apple color emoji provided here. It seems that only 137 is the valid size. The following works:

unicode_font = ImageFont.truetype(r"E:\AppleColorEmoji.ttf", 137)

@luisadrianpuga
Copy link

96

thank you

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

8 participants