Updated for changes in FTCharmap
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
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);
}