Tidied up the error stuff and got rid of some redundant code. Added a note about glyph bounding boxes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/src/FTGLTextureFont.cpp b/src/FTGLTextureFont.cpp
index 348e401..cd1dffe 100755
--- a/src/FTGLTextureFont.cpp
+++ b/src/FTGLTextureFont.cpp
@@ -56,25 +56,20 @@ bool FTGLTextureFont::MakeGlyphList()
float currTextU = (float)padding / (float)textureSize;
float currTextV = (float)padding / (float)textureSize;
-// float Uinc = (float)glyphWidth / (float)textureSize;
-// float Vinc = (float)glyphHeight / (float)textureSize;
-// int currGlyph = 0;
int glyphIndex;
+ numGlyphs = 256; // FIXME hack
+
for( int n = 0; n <= numGlyphs; ++n)
{
glyphIndex = FT_Get_Char_Index( *ftFace, n);
err = FT_Load_Glyph( *ftFace, glyphIndex, FT_LOAD_DEFAULT);
- if( err)
- { }
FT_Glyph ftGlyph;
err = FT_Get_Glyph( (*ftFace)->glyph, &ftGlyph);
- if( err)
- {}
unsigned char* data = textMem + ( ( currentTextY * textureSize) + currentTextX);
@@ -102,6 +97,7 @@ bool FTGLTextureFont::MakeGlyphList()
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA, textureSize, textureSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, textMem);
+ return !err;
}
@@ -110,6 +106,11 @@ bool FTGLTextureFont::CreateTexture()
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &maxTextSize);
glGenTextures( 1, &glTextureID);
+// There is a fixed relationship between ppem, point size, and the
+// resulting pixel size. The real dimension of the glyphs are not
+// covered by this. The field `bbox' in FT_Face gives a maximal bounding
+// box large enough to hold all bboxes of single glyphs.
+
// calc the area required for this font
glyphHeight = ( charSize.Height()) + padding;
glyphWidth = ( charSize.Width()) + padding;