Commit d5f912b3f90c2a6bd63cd50eeea0b51a42e328d0

henry 2004-05-09T07:13:48

Updated for changes in FTCharmap

diff --git a/include/FTGlyphContainer.h b/include/FTGlyphContainer.h
index 386bb14..35ebc79 100755
--- a/include/FTGlyphContainer.h
+++ b/include/FTGlyphContainer.h
@@ -45,13 +45,13 @@ class FTGL_EXPORT FTGlyphContainer
         bool CharMap( FT_Encoding encoding);
 
         /**
-         * Get the glyph index of the input character.
+         * Get the font index of the input character.
          *
          * @param characterCode The character code of the requested glyph in the
          *                      current encoding eg apple roman.
-         * @return      The glyph index for the character.
+         * @return      The font index for the character.
          */
-        unsigned int GlyphIndex( const unsigned int characterCode ) const;
+        signed int FontIndex( const unsigned int characterCode ) const;
         
         /**
          * Adds a glyph to this glyph list.
diff --git a/src/FTFont.cpp b/src/FTFont.cpp
index ef45aa8..c06d883 100755
--- a/src/FTFont.cpp
+++ b/src/FTFont.cpp
@@ -264,7 +264,7 @@ void FTFont::CheckGlyph( const unsigned int characterCode)
 {
     if( NULL == glyphList->Glyph( characterCode))
     {
-        unsigned int glyphIndex = glyphList->GlyphIndex( characterCode);
+        unsigned int glyphIndex = glyphList->FontIndex( characterCode);
         glyphList->Add( MakeGlyph( glyphIndex), characterCode);
     }
 }
diff --git a/src/FTGlyphContainer.cpp b/src/FTGlyphContainer.cpp
index 39013e4..5bd4a40 100755
--- a/src/FTGlyphContainer.cpp
+++ b/src/FTGlyphContainer.cpp
@@ -34,9 +34,9 @@ bool FTGlyphContainer::CharMap( FT_Encoding encoding)
 }
 
 
-unsigned int FTGlyphContainer::GlyphIndex( const unsigned int characterCode) const
+signed int FTGlyphContainer::FontIndex( const unsigned int characterCode) const
 {
-    return charMap->GlyphIndex( characterCode);
+    return charMap->FontIndex( characterCode);
 }
 
 
@@ -49,24 +49,24 @@ void FTGlyphContainer::Add( FTGlyph* tempGlyph, const unsigned int characterCode
 
 const FTGlyph* const FTGlyphContainer::Glyph( const unsigned int characterCode) const
 {
-    unsigned int index = charMap->CharIndex( characterCode);
+    signed int index = charMap->GlyphListIndex( characterCode);
     return glyphs[index];
 }
 
 
 FTBBox FTGlyphContainer::BBox( const unsigned int characterCode) const
 {
-    return glyphs[charMap->CharIndex( characterCode)]->BBox();
+    return glyphs[charMap->GlyphListIndex( characterCode)]->BBox();
 }
 
 
 float FTGlyphContainer::Advance( const unsigned int characterCode, const unsigned int nextCharacterCode)
 {
-    unsigned int left = charMap->GlyphIndex( characterCode);
-    unsigned int right = charMap->GlyphIndex( nextCharacterCode);
-    
+    unsigned int left = charMap->FontIndex( characterCode);
+    unsigned int right = charMap->FontIndex( nextCharacterCode);
+
     float width = face->KernAdvance( left, right).x;
-    width += glyphs[charMap->CharIndex( characterCode)]->Advance();
+    width += glyphs[charMap->GlyphListIndex( characterCode)]->Advance();
     
     return width;
 }
@@ -77,14 +77,14 @@ FTPoint FTGlyphContainer::Render( const unsigned int characterCode, const unsign
     FTPoint kernAdvance;
     float advance = 0;
     
-    unsigned int left = charMap->GlyphIndex( characterCode);
-    unsigned int right = charMap->GlyphIndex( nextCharacterCode);
-    
+    unsigned int left = charMap->FontIndex( characterCode);
+    unsigned int right = charMap->FontIndex( nextCharacterCode);
+
     kernAdvance = face->KernAdvance( left, right);
         
     if( !face->Error())
     {
-        advance = glyphs[charMap->CharIndex( characterCode)]->Render( penPosition);
+        advance = glyphs[charMap->GlyphListIndex( characterCode)]->Render( penPosition);
     }
     
     kernAdvance.x = advance + kernAdvance.x;
diff --git a/test/FTCharmap-Test.cpp b/test/FTCharmap-Test.cpp
index aec04a3..d0a0787 100755
--- a/test/FTCharmap-Test.cpp
+++ b/test/FTCharmap-Test.cpp
@@ -1,3 +1,5 @@
+#include <iostream>
+
 #include <cppunit/extensions/HelperMacros.h>
 #include <cppunit/TestCaller.h>
 #include <cppunit/TestCase.h>
@@ -19,8 +21,8 @@ class FTCharmapTest : public CppUnit::TestCase
     CPPUNIT_TEST_SUITE( FTCharmapTest);
         CPPUNIT_TEST( testConstructor);
         CPPUNIT_TEST( testSetEncoding);
-        CPPUNIT_TEST( testGetCharacterIndex);
-        CPPUNIT_TEST( testGetGlyphIndex);
+        CPPUNIT_TEST( testGetGlyphListIndex);
+        CPPUNIT_TEST( testGetFontIndex);
         CPPUNIT_TEST( testInsertCharacterIndex);
     CPPUNIT_TEST_SUITE_END();
         
@@ -59,46 +61,48 @@ class FTCharmapTest : public CppUnit::TestCase
         }
         
         
-        void testGetCharacterIndex()
+        void testGetGlyphListIndex()
         {
             charmap->CharMap( ft_encoding_unicode);
             
             CPPUNIT_ASSERT( charmap->Error() == 0);
-            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE_A)    == 0);
-            CPPUNIT_ASSERT( charmap->CharIndex( BIG_CHARACTER_CODE)  == 0);
-            CPPUNIT_ASSERT( charmap->CharIndex( NULL_CHARACTER_CODE) == 0);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_A)    == 0);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( BIG_CHARACTER_CODE)  == 0);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( NULL_CHARACTER_CODE) == 0);
             
             charmap->CharMap( ft_encoding_johab);
             
             CPPUNIT_ASSERT( charmap->Error() == 6);
-            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE_A)    == 0);
-            CPPUNIT_ASSERT( charmap->CharIndex( BIG_CHARACTER_CODE)  == 0);
-            CPPUNIT_ASSERT( charmap->CharIndex( NULL_CHARACTER_CODE) == 0);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_A)    == 0);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( BIG_CHARACTER_CODE)  == 0);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( NULL_CHARACTER_CODE) == 0);
         }
 
     
-        void testGetGlyphIndex()
+        void testGetFontIndex()
         {
             charmap->CharMap( ft_encoding_unicode);
 
             CPPUNIT_ASSERT( charmap->Error() == 0);
-            CPPUNIT_ASSERT( charmap->GlyphIndex( CHARACTER_CODE_A)    == FONT_INDEX_OF_A);
-            CPPUNIT_ASSERT( charmap->GlyphIndex( BIG_CHARACTER_CODE)  == BIG_FONT_INDEX);
-            CPPUNIT_ASSERT( charmap->GlyphIndex( NULL_CHARACTER_CODE) == NULL_FONT_INDEX);
+
+            CPPUNIT_ASSERT( charmap->FontIndex( CHARACTER_CODE_A)    == FONT_INDEX_OF_A);
+            CPPUNIT_ASSERT( charmap->FontIndex( BIG_CHARACTER_CODE)  == BIG_FONT_INDEX);
+            CPPUNIT_ASSERT( charmap->FontIndex( NULL_CHARACTER_CODE) == NULL_FONT_INDEX);
         }
     
     
         void testInsertCharacterIndex()
         {
-            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE_A) == 0);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_A) == 0);
+            CPPUNIT_ASSERT( charmap->FontIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
 
-            charmap->InsertIndex( CHARACTER_CODE_A, charmap->GlyphIndex( CHARACTER_CODE_A));
-            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
+            charmap->InsertIndex( CHARACTER_CODE_A, 69);
+            CPPUNIT_ASSERT( charmap->FontIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_A) == 69);
 
-            charmap->InsertIndex( CHARACTER_CODE_A, 999);
-            CPPUNIT_ASSERT( charmap->CharIndex( CHARACTER_CODE_A) == 999);
+            charmap->InsertIndex( CHARACTER_CODE_G, 999);
+            CPPUNIT_ASSERT( charmap->GlyphListIndex( CHARACTER_CODE_G) == 999);
         }
-
         
         void setUp() 
         {
diff --git a/test/FTGlyphContainer-Test.cpp b/test/FTGlyphContainer-Test.cpp
index 7ab4c5c..ccf89c2 100755
--- a/test/FTGlyphContainer-Test.cpp
+++ b/test/FTGlyphContainer-Test.cpp
@@ -71,8 +71,8 @@ class FTGlyphContainerTest : public CppUnit::TestCase
 
         void testGlyphIndex()
         {
-            CPPUNIT_ASSERT( glyphContainer->GlyphIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
-            CPPUNIT_ASSERT( glyphContainer->GlyphIndex( BIG_CHARACTER_CODE) == BIG_FONT_INDEX);
+            CPPUNIT_ASSERT( glyphContainer->FontIndex( CHARACTER_CODE_A) == FONT_INDEX_OF_A);
+            CPPUNIT_ASSERT( glyphContainer->FontIndex( BIG_CHARACTER_CODE) == BIG_FONT_INDEX);
         }