Open joaohaas opened 4 months ago
It is absolutely normal for FreeType to render a NULL-buffer without any errors returned. particularly for whitespace characters. The size of such bitmaps will also be 0x0, with advance properly assigned, however.
Thanks very much @apodtele
I've created #8324 to resolve this by drawing an empty character.
The font is interesting indeed. The space character contains a degenerate contour of two points (0,0) and (0,1). So the output is NULL of size 0x1 (one raw of zero pixels each), i.e. bitmap.width = 0
, bitmap.rows = 1
. But it could be something else depending on the rendering mode.
I opened https://gitlab.freedesktop.org/freetype/freetype/-/issues/1295, if you have an opinion.
If it is degenerate (https://lists.nongnu.org/archive/html/freetype-devel/2012-04/msg00068.html, "A degenerate contour is one that does not change the rendering if removed.") and I presume the size of the glyph doesn't affect the advance, then output makes no difference for rendering operations that use the same settings, right?
What did you do?
Tried to call
ImageDraw.text((15, 36), "A B")
with the following font: FS Lola Medium Regular.zipWhat did you expect to happen?
Either a successful call, since that font is rendered correctly on browsers and as a system font, or the usage of one of the 'unidentified characters' (□, �).
What actually happened?
Because of the whitespace, the call fails with a
OSError: Bitmap missing for glyph
exception onPIL/ImageFont.py:607
. I'm not exactly sure if there's any actual error with the font file, but as mentioned, it works fine on browsers and as a system font.What are your OS, Python and Pillow versions?