Implemented FTCharmap class
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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
diff --git a/include/FTFace.h b/include/FTFace.h
index 8e564bb..9ba7514 100755
--- a/include/FTFace.h
+++ b/include/FTFace.h
@@ -9,6 +9,8 @@
#include "FTSize.h"
+class FTCharmap;
+
/**
* FTFace class provides an abstraction layer for the Freetype Face.
*
@@ -18,7 +20,6 @@
class FTFace
{
public:
- // methods
/**
* Default Constructor
*/
@@ -59,20 +60,6 @@ class FTFace
/**
* Sets the character map for the face.
- * Valid encodings as at Freetype 2.0.4
- * ft_encoding_none
- * ft_encoding_symbol
- * ft_encoding_unicode
- * ft_encoding_latin_2
- * ft_encoding_sjis
- * ft_encoding_gb2312
- * ft_encoding_big5
- * ft_encoding_wansung
- * ft_encoding_johab
- * ft_encoding_adobe_standard
- * ft_encoding_adobe_expert
- * ft_encoding_adobe_custom
- * ft_encoding_apple_roman
*
* @param encoding the Freetype encoding symbol. See above.
* @return <code>true</code> if charmap was valid
@@ -93,7 +80,6 @@ class FTFace
* Gets the kerning vector between two glyphs
*/
FT_Vector& KernAdvance( unsigned int index1, unsigned int index2);
-
/**
* Loads and creates a Freetype glyph.
@@ -104,7 +90,6 @@ class FTFace
* Gets the current Freetype face.
*/
FT_Face* Face() const { return ftFace;}
-
/**
* Queries for errors.
@@ -113,17 +98,16 @@ class FTFace
*/
FT_Error Error() const { return err; }
- // attributes
-
private:
- // methods
-
- // attributes
-
/**
* The size object associated with this face
*/
FTSize charSize;
+
+ /**
+ * The Character Map object associated with this face
+ */
+ FTCharmap* charMap;
/**
* The Freetype face
diff --git a/src/FTFace.cpp b/src/FTFace.cpp
index 827f552..20d2014 100755
--- a/src/FTFace.cpp
+++ b/src/FTFace.cpp
@@ -1,11 +1,13 @@
#include "FTFace.h"
#include "FTLibrary.h"
+#include "FTCharmap.h"
#include "FTGL.h"
FTFace::FTFace()
: ftFace(0),
numCharMaps(0),
+ charMap(0),
numGlyphs(0),
err(0)
{}
@@ -13,6 +15,7 @@ FTFace::FTFace()
FTFace::~FTFace()
{
+ delete charMap;
Close();
}
@@ -30,6 +33,7 @@ bool FTFace::Open( const char* filename)
}
else
{
+ charMap = new FTCharmap( *ftFace);
return true;
}
}
@@ -40,13 +44,13 @@ void FTFace::Close()
if( ftFace)
{
FT_Done_Face( *ftFace);
- delete ftFace; // is this a prob?
+ delete ftFace;
ftFace = 0;
}
}
-FTSize& FTFace::Size( const unsigned int size, const unsigned int res )
+FTSize& FTFace::Size( const unsigned int size, const unsigned int res)
{
if( !charSize.CharSize( ftFace, size, res, res))
{
@@ -57,43 +61,19 @@ FTSize& FTFace::Size( const unsigned int size, const unsigned int res )
}
-bool FTFace::CharMap( FT_Encoding encoding )
+bool FTFace::CharMap( FT_Encoding encoding)
{
-
-// FT_CharMap found = 0;
-// FT_CharMap charmap;
-// int n;
-//
-// for ( n = 0; n < face->num_charmaps; n++ )
-// {
-// charmap = face->charmaps[n];
-// if ( charmap->platform_id == my_platform_id &&
-// charmap->encoding_id == my_encoding_id )
-// {
-// found = charmap;
-// break;
-// }
-// }
-//
-// if ( !found ) { ... }
-//
-// /* now, select the charmap for the face object */
-// error = FT_Set_CharMap( face, found );
-// if ( error ) { ... }
-
-
- err = FT_Select_Charmap( *ftFace, encoding );
- return !err;
+ return charMap->CharMap( encoding);
}
-unsigned int FTFace::CharIndex( unsigned int index ) const
+unsigned int FTFace::CharIndex( unsigned int index) const
{
- return FT_Get_Char_Index( *ftFace, index);
+ return charMap->CharIndex( index);
}
-FT_Vector& FTFace::KernAdvance( unsigned int index1, unsigned int index2 )
+FT_Vector& FTFace::KernAdvance( unsigned int index1, unsigned int index2)
{
kernAdvance.x = 0; kernAdvance.y = 0;