Added CheckGlyph function
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
diff --git a/include/FTFont.h b/include/FTFont.h
index 826e8a3..c135ea6 100755
--- a/include/FTFont.h
+++ b/include/FTFont.h
@@ -249,6 +249,11 @@ class FTGL_EXPORT FTFont
* @param nextChr next character
*/
inline void doRender( const unsigned int chr, const unsigned int nextChr);
+
+ /**
+ *
+ */
+ inline void CheckGlyph( const unsigned int chr);
};
diff --git a/src/FTFont.cpp b/src/FTFont.cpp
index 06af6e9..0f5d142 100755
--- a/src/FTFont.cpp
+++ b/src/FTFont.cpp
@@ -130,12 +130,8 @@ void FTFont::BBox( const char* string,
while( *c)
{
- if( !glyphList->Glyph( static_cast<unsigned int>(*c)))
- {
- unsigned int g = face.CharIndex( static_cast<unsigned int>(*c));
- glyphList->Add( MakeGlyph( g), g);
- }
-
+ CheckGlyph( *c);
+
bbox = glyphList->BBox( *c);
// Lower extent
@@ -172,12 +168,8 @@ void FTFont::BBox( const wchar_t* string,
while( *c)
{
- if( !glyphList->Glyph( static_cast<unsigned int>(*c)))
- {
- unsigned int g = face.CharIndex( static_cast<unsigned int>(*c));
- glyphList->Add( MakeGlyph( g), g);
- }
-
+ CheckGlyph( *c);
+
bbox = glyphList->BBox( *c);
// Lower extent
@@ -232,11 +224,7 @@ float FTFont::Advance( const char* string)
float FTFont::doAdvance( const unsigned int chr, const unsigned int nextChr)
{
- if( !glyphList->Glyph( chr))
- {
- unsigned int g = face.CharIndex( chr);
- glyphList->Add( MakeGlyph( g), g);
- }
+ CheckGlyph( chr);
return glyphList->Advance( chr, nextChr);
}
@@ -270,11 +258,7 @@ void FTFont::render( const wchar_t* string )
void FTFont::doRender( const unsigned int chr, const unsigned int nextChr)
{
- if( !glyphList->Glyph( chr))
- {
- unsigned int g = face.CharIndex( chr);
- glyphList->Add( MakeGlyph( g), g);
- }
+ CheckGlyph( chr);
FTPoint kernAdvance = glyphList->render( chr, nextChr, pen);
@@ -282,3 +266,13 @@ void FTFont::doRender( const unsigned int chr, const unsigned int nextChr)
pen.y += kernAdvance.y;
}
+
+void FTFont::CheckGlyph( const unsigned int chr)
+{
+ if( !glyphList->Glyph( chr))
+ {
+ unsigned int g = face.CharIndex( chr);
+ glyphList->Add( MakeGlyph( g), g);
+ }
+}
+