Commit 0418c75ca428387d4abec64ffa3ef4295d61f584

henry 2003-10-19T02:40:00

Can now get the list of supported charmaps for the font.

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() 
         {