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

Error when using bitmap font embedded inside truetype font. #891

Closed
jackyyf opened this issue Sep 7, 2014 · 4 comments · Fixed by #1072
Closed

Error when using bitmap font embedded inside truetype font. #891

jackyyf opened this issue Sep 7, 2014 · 4 comments · Fixed by #1072
Labels
Bug Any unexpected behavior, until confirmed feature.

Comments

@jackyyf
Copy link
Contributor

jackyyf commented Sep 7, 2014

Truetype font has a feature which allows you to embed bitmap font for specific font size, to optimize the rendering results on screens. But using such fonts in Pillow will generate some strange result.

Example:
Bitmap font vs TrueType font

In this case I'm using a modified version of SimSun, which contains embedded bitmap fonts, for all size between 8px and 24px. In the image, first line is using 24px font and the second line is 28px.

TestCase is available (Contains SimSun font, testcode and the result above).
This test can be reproduced on both windows and linux.

@wiredfool
Copy link
Member

Replicated here on Ubuntu 12.04 with Freetype 2.4.8. I'd like to find something that renders fonts using Freetype (other than Pillow) to see if it's a problem at the font/freetype layer, or something in how we're driving freetype.

@jackyyf
Copy link
Contributor Author

jackyyf commented Sep 12, 2014

I have a project in PHP, which is actually an image generator with this font at 14px using php5-gd library, and it works really great (using embedded bitmap font).

According package dependency information of debian package php5-gd, it depends on libfreetype6. So I think it's not an issue with freetype library :)

@jackyyf
Copy link
Contributor Author

jackyyf commented Sep 21, 2014

After some test, this bug exists since at least Pillow 2.2.2(earlier versions do not support freetype 6). All versions since 2.2.2 produced same image.

@wiredfool wiredfool added the Bug Any unexpected behavior, until confirmed feature. label Sep 23, 2014
@jackyyf
Copy link
Contributor Author

jackyyf commented Oct 14, 2014

Found a dirty work around, adding FT_LOAD_NO_BITMAP to all FT_Load_Glyph load flags, which will let freetype avoid embedded bitmap font.

Found the solution at http://www.freetype.org/freetype2/docs/tutorial/step1.html

wiredfool pushed a commit to wiredfool/Pillow that referenced this issue Jan 8, 2015
  Since embedded bitmap font works incorrectly, we should avoid using
them, until a final patch is available and tested. I've added
`FT_LOAD_NO_BITMAP` to ALL(3) places in `_imagingft.c`, which did
(not much) actually fixed the issue. A notice has also been added to
`_imagingft.c`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants