I've run into a case where I am using FTGL on a platform where the max texture size is 512x512. When rendering a font glyph at size = 200 (which I then down-sample to 100 post-rendering), I encountered a crash near line #185 in src/FTFont/FTTextureFont.cpp. It appears that the glyphWidth parameter went higher (731) than the textureWidth parameter (512, due to HW restrictions). This causes the variable "h" to become zero, causing divide-by-zero when calculating textureHeight.
I noticed the mysterious "+ 0.5" on the end... is this an attempt to force rounding upward? If so, most compilers that I use seem to truncate this instead of rounding when performing a cast-to-int. On a hunch, I changed the cast into a call to the C99 lrintf() function (in math.h) and it seems to fix the problem for me.
I am attaching a patch below.
Log in to post a comment.