Added hasKerningTable member so we don't query the font every glyph. Got rid of the redundant Close() and unused UnitsPerEM()
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
diff --git a/include/FTFace.h b/include/FTFace.h
index 26bb396..0a985e0 100755
--- a/include/FTFace.h
+++ b/include/FTFace.h
@@ -60,11 +60,6 @@ class FTGL_EXPORT FTFace
bool Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes);
/**
- * Disposes of the face
- */
- void Close();
-
- /**
* Get the freetype face object..
*
* @return pointer to an FT_Face.
@@ -83,8 +78,6 @@ class FTGL_EXPORT FTFace
*/
const FTSize& Size( const unsigned int size, const unsigned int res);
- unsigned int UnitsPerEM() const;
-
/**
* Get the number of character maps in this face.
*
@@ -140,6 +133,11 @@ class FTGL_EXPORT FTFace
FT_Encoding* fontEncodingList;
/**
+ * This face has kerning tables
+ */
+ bool hasKerningTable;
+
+ /**
* Current error code. Zero means no error.
*/
FT_Error err;
diff --git a/src/FTFace.cpp b/src/FTFace.cpp
index 0385e23..2eb3b26 100755
--- a/src/FTFace.cpp
+++ b/src/FTFace.cpp
@@ -21,6 +21,7 @@ FTFace::FTFace( const char* filename)
else
{
numGlyphs = (*ftFace)->num_glyphs;
+ hasKerningTable = FT_HAS_KERNING((*ftFace));
}
}
@@ -48,7 +49,12 @@ FTFace::FTFace( const unsigned char *pBufferBytes, size_t bufferSizeInBytes)
FTFace::~FTFace()
{
- Close();
+ if( ftFace)
+ {
+ FT_Done_Face( *ftFace);
+ delete ftFace;
+ ftFace = 0;
+ }
}
@@ -72,17 +78,6 @@ bool FTFace::Attach( const unsigned char *pBufferBytes, size_t bufferSizeInBytes
}
-void FTFace::Close()
-{
- if( ftFace)
- {
- FT_Done_Face( *ftFace);
- delete ftFace;
- ftFace = 0;
- }
-}
-
-
const FTSize& FTFace::Size( const unsigned int size, const unsigned int res)
{
charSize.CharSize( ftFace, size, res, res);
@@ -113,18 +108,12 @@ FT_Encoding* FTFace::CharMapList()
}
-unsigned int FTFace::UnitsPerEM() const
-{
- return (*ftFace)->units_per_EM;
-}
-
-
FTPoint FTFace::KernAdvance( unsigned int index1, unsigned int index2)
{
float x, y;
x = y = 0.0f;
- if( FT_HAS_KERNING((*ftFace)) && index1 && index2)
+ if( hasKerningTable && index1 && index2)
{
FT_Vector kernAdvance;
kernAdvance.x = kernAdvance.y = 0;