Change to BBox to stop it exiting completely on a NULL 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
diff --git a/src/FTFont.cpp b/src/FTFont.cpp
index eb29fc8..ee47f19 100755
--- a/src/FTFont.cpp
+++ b/src/FTFont.cpp
@@ -134,23 +134,22 @@ void FTFont::BBox( const char* string,
if((NULL != string) && ('\0' != *string))
{
const unsigned char* c = (unsigned char*)string;
+ float advance = 0;
if(CheckGlyph( *c))
{
totalBBox = glyphList->BBox( *c);
- float advance = glyphList->Advance( *c, *(c + 1));
- ++c;
+ advance = glyphList->Advance( *c, *(c + 1));
+ }
- while( *c)
+ while( *++c)
+ {
+ if(CheckGlyph( *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;
+ FTBBox tempBBox = glyphList->BBox( *c);
+ tempBBox.Move( FTPoint( advance, 0.0f, 0.0f));
+ totalBBox += tempBBox;
+ advance += glyphList->Advance( *c, *(c + 1));
}
}
}
@@ -172,23 +171,22 @@ void FTFont::BBox( const wchar_t* string,
if((NULL != string) && ('\0' != *string))
{
const wchar_t* c = string;
+ float advance = 0;
if(CheckGlyph( *c))
{
totalBBox = glyphList->BBox( *c);
- float advance = glyphList->Advance( *c, *(c + 1));
- ++c;
-
- while( *c)
+ advance = glyphList->Advance( *c, *(c + 1));
+ }
+
+ while( *++c)
+ {
+ if(CheckGlyph( *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;
+ FTBBox tempBBox = glyphList->BBox( *c);
+ tempBBox.Move( FTPoint( advance, 0.0f, 0.0f));
+ totalBBox += tempBBox;
+ advance += glyphList->Advance( *c, *(c + 1));
}
}
}