Memory overrun when text without descenders is rendered with underlining

Issue #237 closed
Lenard Lindstrom
created an issue

Bo Jangeborg posted on the Pygame Mailing List:

How stable is the freetype module ? I have been running into problems with it hanging my app completly. The following code should demonstrate the problem. Pressing ESC and you'll see that it has crashed. However if you set the underline parameter to 'False' things work nicely. I am running it on Windows 7.

Example code attached—requires the Times New Roman font to be installed.

Comments (5)

  1. Lenard Lindstrom reporter
    • changed status to open

    When generating the size rectangle for a text string, the _freetype.Font layout manager ignores underlining. So if the underline lies outside of the text's bounding box, the underline is drawn outside of valid memory. To fix, function _PGFT_LoadLayout in src/freetype/ft_layout.c needs to calculate add in underlining to the size calculation. This suggests rendering the underline should be abstracted out of ft_render.c, and treated as a glyph.

  2. Log in to comment