rougier / freetype-py

Python binding for the freetype library
Other
298 stars 88 forks source link

freetype.ft_errors.FT_Exception: FT_Exception: (stack overflow) #146

Closed miguelsousa closed 2 years ago

miguelsousa commented 2 years ago

Cross posted with https://github.com/googlefonts/fontbakery/issues/3642 and https://gitlab.freedesktop.org/freetype/freetype/-/issues/1137

AnchoGX.ttf version 1.000 (from http://beatrizl.com/project/ancho) crashes freetype-py v2.2.0. fontview v0.3.1 also doesn't render it, I assume because of a FreeType failure.

import freetype
face = freetype.Face("AnchoGX.ttf")
face.set_char_size(48 * 64)
face.load_char('S')
bitmap = face.glyph.bitmap
print(bitmap.buffer)

The snippet above crashes with this error,

freetype.ft_errors.FT_Exception: FT_Exception:  (too many function definitions)

And Rubik-Italic.ttf crashes with,

freetype.ft_errors.FT_Exception: FT_Exception:  (stack overflow)
HinTak commented 2 years ago

Please quote exact revision of AnchoGX.ttf for the problem.

miguelsousa commented 2 years ago

@HinTak done!

HinTak commented 2 years ago

I reproduced the errors; then I ran FontVal on both. For Rubik-Italic it says NPUSHB at the beginning of prep caused a stack overflow, E6045; for AnchorGX, it caused a piles of E6016 FDEF out of range in prep before the "too many function definition".

So it looks like the fonts have slightly broken prep tables; but broken in different ways.

HinTak commented 2 years ago

There is a python binding to the FontVal backend at https://github.com/FontVal-extras/freetype-py

miguelsousa commented 2 years ago

Thanks @HinTak. Sounds like these aren't FreeType bugs then. Closing.

HinTak commented 2 years ago

@miguelsousa the fix for the stack overflow as werner responded in upstream is to increase the maxstack value in the cvt table. For the FDEF out of range problem, it might be fixable by increasing the maxFDEF value (not sure about the actual name, but it is in cvt alright) in cvt too.