-
-
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
ParryHotter font isn't displayed #2578
Comments
Can you post the font? |
Here you go: https://mfi.re/?6k1d126g8ryt93o The font is also shipped with Windows by default. |
I've found some more fonts that aren't displayed correctly (or at all). Another font that doesn't seem to be correctly loaded is Segoe UI Symbol, where font.getsize("Segoe UI Symbol text that ends with a j") |
Parry Hotter is from www.anke-art.de, it's donation-ware, so I find it hard to believe that it ships with Windows. At any rate, it does not define any glyphs in the unicode range < 0x8f, so ordinary ascii text is not going to show up. It appears that the font is entirely contained in the unicode region 0x10002 to 0x100aa. The other two fonts are similar. |
How about these three though? They appear correctly in FontForge, but are displayed as squares when using PIL. |
Could you please re-upload the fonts to github, instead of a file hosting site that expires them and blocks wget? |
That doesn't have ParryHotter, xfiles, or woodcut. |
The files didn't expire. I took them down, because they aren't my property, so hosting them didn't feel right. |
Ok, so I've poked at this some more. There's a clear problem with the first three font files. Truetype fonts have at least one 'cmap' table (https://www.microsoft.com/typography/otspec/cmap.htm), and these have three. There is one with a Mac platform ID and one with a Windows platform ID, both with roughly equivalent contents. There's also an empty cmap of platformID0, platformEncodingId of 3. Deleting that empty table fixes the first three fonts. (using https://github.com/fonttools/fonttools) Additionally, the woodcut and parryhotter fonts had I'm not sure why freetype is using the |
I found another font where the "J" isn't displayed or rather computed correctly. This time it is Littlelordfontleroy. from PIL import Image, ImageFont, ImageDraw
font = ImageFont.truetype("littlelo.ttf", 100)
image = Image.new("RGBA", font.getsize("james P Sullivan"))
draw = ImageDraw.Draw(image)
draw.text((0,0),"james P Sullivan", font=font, fill=(0,0,0))
image.show() Where this is the output when using a capital "J": |
The 'J' metrics is a totally different issue, it looks like the x-advance is being used as the full width of the character for bounding box issues. |
I inspected Littlelordfontleroy in FontForge and several of the glyphs have a a negative Bearing X and are self-interesecting. Since the beginning of the rendering is at (0,0) it should be expected that the first letter gets clipped as there is no image to draw on. If you print with " james" instead, it works fine. This doesn't seem like a Pillow problem. |
It's not just Pillow. This is with Apple's font rendering, on a font shipped with the OS. There's some extension into -x at the beginning of the line, and some beyond even that that's clipped. What Apple does do is align the visual edge of the glyph with the margin. Doing this properly is going to take a different api than we have, as it has to reference the baseline, return an extents, and the offset to the visual margin. |
When I try this with a somewhat recent build of master, I find that this looks a bit better now (maybe due to #4910, IIRC there were some fixes for negative x bearing in there): Using the new im2 = Image.new("RGBA", (-bbox[0]+bbox[2], -bbox[1]+bbox[3]))
d2 = ImageDraw.Draw(im2)
d2.text((-bbox[0],-bbox[1]), "james P Sullivan", font=font, fill="black")
im2.show() The 'j' is no longer cropped, because the text is no longer visually aligned with (0, 0). For the first font, Parry Hotter, it seems to have three cmap tables:
I have found that specifying ft = ImageFont.truetype("D:\Downloads\parryhotter.ttf", 20, encoding="armn")
bbox = ft.getbbox("Parry Hotter")
image = Image.new("RGBA", (-bbox[0]+bbox[2], -bbox[1]+bbox[3]))
draw = ImageDraw.Draw(image)
draw.text((-bbox[0],-bbox[1]), "Parry Hotter", font=ft)
image.show() (white text, might be hard to see in light GitHub style)
Frankfurter Venetian TT also displays correctly with
(white text, might be hard to see in light GitHub style)
I believe this part has been resolved by the addition of Edit:
This also seems to be working fine now: |
Russrite.ttf, woodcut.ttf and xfiles.ttf also work with @nulano is there anything left to do here, or is this resolved? |
I believe this is resolved. |
What did you do?
I tried to create a text using the font "ParryHotter" (using the code below)
What did you expect to happen?
I expected to see an image with the text "Parry Hotter" in the corresponding font
What actually happened?
A blank image opened
What versions of Pillow and Python are you using?
Python 2.7.13 and 3.6.1
Pillow 4.1.1
Please include code that reproduces the issue and whenever possible, an image that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.
The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as plone, Django, or buildout, try to replicate the issue just using Pillow.
The text was updated successfully, but these errors were encountered: