I'm using FreeTypeGL to render system fonts in OpenGL using the below
code (running on Windows).
FTFont* pFont = new FTTextureFont(fontFile);
This worked very well for multiple fonts I initially tried. I then
tried "MS Sans Serif" ("C:\Windows\Fonts\SSERIFE.FON") initially with a
point size of 8.
When calling FaceSize, the error flag FNT_Err_Invalid_Pixel_Size was
set. I asked about this initially on the FreeType list and someone
suggested the problem was the default dpi of 72 was not correct for
I tried changing my call to FaceSize to be the below, which passed in
res = GetDeviceCaps(refDC,LOGPIXELSY);
When doing this, it appeared to me not to have any affect in that 72
was still being passed to FreeType. It looked to me like there was a
bug in FTSize::CharSize. See the below where I replaced the commented
out line with the one below it.
bool FTSize::CharSize(FT_Face* face, unsigned int
pointSize, unsigned int xRes, unsigned int yRes)
if(size != pointSize || xResolution != xRes || yResolution != yRes)
// err = FT_Set_Char_Size(*face, 0L, pointSize * 64,
err = FT_Set_Char_Size(*face, 0L, pointSize * 64, xRes, yRes);
ftFace = face;
size = pointSize;
xResolution = xRes;
yResolution = yRes;
ftSize = (*ftFace)->size;
Making this change resulted in the 96 getting passed through to
FreeType. Now the FaceSize "works", there's no error flagged.
However, when I try and call Advance to figure out the width of a text
string, it crashes.
What's odd is that this works fine with other fonts (Times New Roman,
Lucida Sans Unicode), but with "MS Sans Serif" its not working.
Any ideas? Suggestions?