
0, 2, 3, 8, 9 .from PIL import Image, ImageFont, ImageDraw
ttf_path = "vista-hei-all.ttf"
text = "0123456789"
text_size = 35
font = ImageFont.truetype(ttf_path, text_size)
text_width, text_height = font.getsize(text)
canvas = Image.new("RGBA", [text_width, text_height], (255, 0, 0, 0))
draw = ImageDraw.Draw(canvas)
draw.text((0, 0), text, font=font, fill="#000000")
canvas.show()
Are you able to replicate this problem with a font that you can link to?
@radarhere I place a zip here.
As a note for future investigation of this, here's a clear way to demonstrate that this is a bug - removing the '0' from '0123456789' causes the missing pixels to be drawn without a problem.
I have seen this before in some previous tests. I believe the cause is #185, as the solution there seems to be to count the text distance from the bottom instead of from the top. (Confusingly, this patch made the ascender variable refer to the descender height.) This is wrong and works only because most fonts tend to have a gap at the top. I believe I have fixed this properly in my WIP PR for https://github.com/python-pillow/Pillow/issues/4511#issuecomment-612940904, by enabling hinting for FT_GetGlyphCBox in _imagingft.getsize.
@nulano Nice!
I have run the code below on pillow version 7.1.1 and 8.0.1 respectively, and the bug seems to be fixed.
from PIL import Image, ImageFont, ImageDraw
ttf_path = "vista-hei-all.ttf"
text = "0123456789"
text_size = 35
font = ImageFont.truetype(ttf_path, text_size)
text_width, text_height = font.getsize(text)
canvas = Image.new("RGBA", [text_width, text_height], (255, 0, 0, 255))
draw = ImageDraw.Draw(canvas)
draw.text((0, 0), text, font=font, fill="#000000")
canvas.show()

Thanks for letting us know!