Changed CheckGlyph function to indicate failure to create a glyph.
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
diff --git a/src/FTFont.cpp b/src/FTFont.cpp
index 9a8ee7a..80aab52 100755
--- a/src/FTFont.cpp
+++ b/src/FTFont.cpp
@@ -135,20 +135,23 @@ void FTFont::BBox( const char* string,
{
const unsigned char* c = (unsigned char*)string;
- CheckGlyph( *c);
-
- totalBBox = glyphList->BBox( *c);
- float advance = glyphList->Advance( *c, *(c + 1));
- ++c;
-
- while( *c)
+ if(CheckGlyph( *c))
{
- CheckGlyph( *c);
- FTBBox tempBBox = glyphList->BBox( *c);
- tempBBox.Move( FTPoint( advance, 0.0f, 0.0f));
- totalBBox += tempBBox;
- advance += glyphList->Advance( *c, *(c + 1));
+ totalBBox = glyphList->BBox( *c);
+ float advance = glyphList->Advance( *c, *(c + 1));
++c;
+
+ while( *c)
+ {
+ if(CheckGlyph( *c))
+ {
+ FTBBox tempBBox = glyphList->BBox( *c);
+ tempBBox.Move( FTPoint( advance, 0.0f, 0.0f));
+ totalBBox += tempBBox;
+ advance += glyphList->Advance( *c, *(c + 1));
+ ++c;
+ }
+ }
}
}
@@ -170,20 +173,23 @@ void FTFont::BBox( const wchar_t* string,
{
const wchar_t* c = string;
- CheckGlyph( *c);
-
- totalBBox = glyphList->BBox( *c);
- float advance = glyphList->Advance( *c, *(c + 1));
- ++c;
-
- while( *c)
+ if(CheckGlyph( *c))
{
- CheckGlyph( *c);
- FTBBox tempBBox = glyphList->BBox( *c);
- tempBBox.Move( FTPoint( advance, 0.0f, 0.0f));
- totalBBox += tempBBox;
- advance += glyphList->Advance( *c, *(c + 1));
+ totalBBox = glyphList->BBox( *c);
+ float advance = glyphList->Advance( *c, *(c + 1));
++c;
+
+ while( *c)
+ {
+ if(CheckGlyph( *c))
+ {
+ FTBBox tempBBox = glyphList->BBox( *c);
+ tempBBox.Move( FTPoint( advance, 0.0f, 0.0f));
+ totalBBox += tempBBox;
+ advance += glyphList->Advance( *c, *(c + 1));
+ ++c;
+ }
+ }
}
}
@@ -203,11 +209,13 @@ float FTFont::Advance( const wchar_t* string)
while( *c)
{
- CheckGlyph( *c);
- width += glyphList->Advance( *c, *(c + 1));
- ++c;
+ if(CheckGlyph( *c))
+ {
+ width += glyphList->Advance( *c, *(c + 1));
+ ++c;
+ }
}
-
+
return width;
}
@@ -219,9 +227,11 @@ float FTFont::Advance( const char* string)
while( *c)
{
- CheckGlyph( *c);
- width += glyphList->Advance( *c, *(c + 1));
- ++c;
+ if(CheckGlyph( *c))
+ {
+ width += glyphList->Advance( *c, *(c + 1));
+ ++c;
+ }
}
return width;
@@ -256,21 +266,28 @@ void FTFont::Render( const wchar_t* string )
void FTFont::DoRender( const unsigned int chr, const unsigned int nextChr)
{
- CheckGlyph( chr);
-
- FTPoint kernAdvance = glyphList->Render( chr, nextChr, pen);
-
- pen.x = kernAdvance.x;
- pen.y = kernAdvance.y;
+ if(CheckGlyph( chr))
+ {
+ FTPoint kernAdvance = glyphList->Render( chr, nextChr, pen);
+
+ pen.x = kernAdvance.x;
+ pen.y = kernAdvance.y;
+ }
}
-
-void FTFont::CheckGlyph( const unsigned int characterCode)
+bool FTFont::CheckGlyph( const unsigned int characterCode)
{
if( NULL == glyphList->Glyph( characterCode))
{
unsigned int glyphIndex = glyphList->FontIndex( characterCode);
- glyphList->Add( MakeGlyph( glyphIndex), characterCode);
+ FTGlyph* tempGlyph = MakeGlyph( glyphIndex);
+ if( NULL == tempGlyph)
+ {
+ return false;
+ }
+ glyphList->Add( tempGlyph, characterCode);
}
+
+ return true;
}