Can now get the list of supported charmaps for the font.
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
diff --git a/include/FTCharmap.h b/include/FTCharmap.h
index f7f83f0..dd9288a 100644
--- a/include/FTCharmap.h
+++ b/include/FTCharmap.h
@@ -69,6 +69,10 @@ class FTGL_EXPORT FTCharmap
* unavailable it will be set to ft_encoding_none.
*/
bool CharMap( FT_Encoding encoding);
+
+
+ unsigned int CharMapCount();
+ FT_Encoding* CharMapList();
/**
* Get the FTGlyphContainer index of the input character.
@@ -112,6 +116,8 @@ class FTGL_EXPORT FTCharmap
*/
FT_Encoding ftEncoding;
+ FT_Encoding* fontEncodingList;
+
/**
* The current Freetype face.
*/
diff --git a/src/FTCharmap.cpp b/src/FTCharmap.cpp
index 31f6aa3..d88a19e 100644
--- a/src/FTCharmap.cpp
+++ b/src/FTCharmap.cpp
@@ -3,7 +3,8 @@
FTCharmap::FTCharmap( FTFace* face)
-: ftFace( *(face->Face())),
+: fontEncodingList(0),
+ ftFace( *(face->Face())),
err(0)
{
if( !ftFace->charmap)
@@ -44,6 +45,27 @@ bool FTCharmap::CharMap( FT_Encoding encoding)
}
+unsigned int FTCharmap::CharMapCount()
+{
+ return ftFace->num_charmaps;
+}
+
+
+FT_Encoding* FTCharmap::CharMapList()
+{
+ if( 0 == fontEncodingList)
+ {
+ fontEncodingList = new FT_Encoding[CharMapCount()];
+ for( size_t encodingIndex = 0; encodingIndex < CharMapCount(); ++encodingIndex)
+ {
+ fontEncodingList[encodingIndex] = ftFace->charmaps[encodingIndex]->encoding;
+ }
+ }
+
+ return fontEncodingList;
+}
+
+
unsigned int FTCharmap::CharIndex( unsigned int characterCode )
{
return charMap.find( characterCode);
diff --git a/test/FTCharmap-Test.cpp b/test/FTCharmap-Test.cpp
index 43e740d..df37a20 100755
--- a/test/FTCharmap-Test.cpp
+++ b/test/FTCharmap-Test.cpp
@@ -22,6 +22,7 @@ class FTCharmapTest : public CppUnit::TestCase
CPPUNIT_TEST( testGetCharacterIndex);
CPPUNIT_TEST( testGetGlyphIndex);
CPPUNIT_TEST( testInsertCharacterIndex);
+ CPPUNIT_TEST( testGetCharmapList);
CPPUNIT_TEST_SUITE_END();
public:
@@ -99,6 +100,16 @@ class FTCharmapTest : public CppUnit::TestCase
CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE_A) == 999);
}
+ void testGetCharmapList()
+ {
+ CPPUNIT_ASSERT( charmap->CharMapCount() == 2);
+
+ FT_Encoding* charmapList = charmap->CharMapList();
+
+ CPPUNIT_ASSERT( charmapList[0] == ft_encoding_unicode);
+ CPPUNIT_ASSERT( charmapList[1] == ft_encoding_adobe_standard);
+ }
+
void setUp()
{