Open youasscoder opened 11 months ago
I think that's an error from freetype - and it is what it says, invalid pixel size. Some bitmap color fonts (sbix and CBDT) contains bitmaps designed for specific sizes, and if you ask for pixel sizes not in one of the designed values, FreeType gives you that error. You can use "ftdump" to get a list of what valid sizes are.
How is this error related to this font?
From that error message, I would assume that PIL's ImageFont.truetype()
uses freetype to load this font, and PIL can't use the SVG table, so it is reading the sbix or CBDT table only of this font, which are of specific pixel sizes.
I thought I have written a README.md about it, but perhaps I have only written to freetype-devel: if you have either pycairo or skia-python available, you can make any freetype-py using program (and I believe PIL being one) support SVG-OT with either https://github.com/HinTak/harfbuzz-python-demos/blob/master/otsvg.py or https://github.com/HinTak/harfbuzz-python-demos/blob/master/skia_ot_svg_module.py .
These two basically enable any freetype-py using python programs to read SVG-OT fonts. And SVG-OT being any-pixel-size, it gets around the sbix/CBDT fixed-pixel-size limitations.
You might have to ask PIL people how to hook the two modules in - it depends on how PIL uses freetype-py/freetype.
Okay, I looked at PIL in my hard disk - it uses freetype directly via _imagingft.cpython.....so
. You'll need to contact the PIL people directly, essentially with the above info. They need to hook up the C-equivalent of that python code. There are again two versions of it, the cairo-dependent version is upstream in ft2-demos, while the skia-dependent version only exists as a patch and is posted at https://github.com/HinTak/harfbuzz-python-demos/tree/master/skia-adventure, with a README.md describing it.
font = ImageFont.truetype(font_path, font_size) no size gives me no "OSError: invalid pixel size" python PIL