Commit 45c2269f932e4f64e338f08aec95de1a1459eb6a

sammy 2008-05-07T16:10:28

* Some code cleanup here and there, mostly in FTGlyphContainer.

diff --git a/src/FTFace.cpp b/src/FTFace.cpp
index 7fd8154..743836e 100644
--- a/src/FTFace.cpp
+++ b/src/FTFace.cpp
@@ -134,7 +134,7 @@ const FTSize& FTFace::Size(const unsigned int size, const unsigned int res)
 }
 
 
-unsigned int FTFace::CharMapCount()
+unsigned int FTFace::CharMapCount() const
 {
     return (*ftFace)->num_charmaps;
 }
diff --git a/src/FTFace.h b/src/FTFace.h
index 899822f..0e903b5 100644
--- a/src/FTFace.h
+++ b/src/FTFace.h
@@ -110,7 +110,7 @@ class FTFace
          *
          * @return character map count.
          */
-        unsigned int CharMapCount();
+        unsigned int CharMapCount() const;
 
         /**
          * Get a list of character maps in this face.
diff --git a/src/FTFont/FTFont.cpp b/src/FTFont/FTFont.cpp
index b345dae..cc47932 100644
--- a/src/FTFont/FTFont.cpp
+++ b/src/FTFont/FTFont.cpp
@@ -117,7 +117,7 @@ bool FTFont::CharMap(FT_Encoding encoding)
 }
 
 
-unsigned int FTFont::CharMapCount()
+unsigned int FTFont::CharMapCount() const
 {
     return impl->CharMapCount();
 }
@@ -393,7 +393,7 @@ bool FTFontImpl::CharMap(FT_Encoding encoding)
 }
 
 
-unsigned int FTFontImpl::CharMapCount()
+unsigned int FTFontImpl::CharMapCount() const
 {
     return face.CharMapCount();
 }
diff --git a/src/FTFont/FTFontImpl.h b/src/FTFont/FTFontImpl.h
index f163b7b..7007211 100644
--- a/src/FTFont/FTFontImpl.h
+++ b/src/FTFont/FTFontImpl.h
@@ -55,7 +55,7 @@ class FTFontImpl
 
         virtual bool CharMap(FT_Encoding encoding);
 
-        virtual unsigned int CharMapCount();
+        virtual unsigned int CharMapCount() const;
 
         virtual FT_Encoding* CharMapList();
 
diff --git a/src/FTGL/FTFont.h b/src/FTGL/FTFont.h
index b8010db..d7b3b05 100644
--- a/src/FTGL/FTFont.h
+++ b/src/FTGL/FTFont.h
@@ -131,7 +131,7 @@ class FTGL_EXPORT FTFont
          *
          * @return character map count.
          */
-        unsigned int CharMapCount();
+        unsigned int CharMapCount() const;
 
         /**
          * Get a list of character maps in this face.
diff --git a/src/FTGlyphContainer.cpp b/src/FTGlyphContainer.cpp
index fb88e2f..d9f7db6 100644
--- a/src/FTGlyphContainer.cpp
+++ b/src/FTGlyphContainer.cpp
@@ -62,58 +62,58 @@ bool FTGlyphContainer::CharMap(FT_Encoding encoding)
 }
 
 
-unsigned int FTGlyphContainer::FontIndex(const unsigned int characterCode) const
+unsigned int FTGlyphContainer::FontIndex(const unsigned int charCode) const
 {
-    return charMap->FontIndex(characterCode);
+    return charMap->FontIndex(charCode);
 }
 
 
-void FTGlyphContainer::Add(FTGlyph* tempGlyph, const unsigned int characterCode)
+void FTGlyphContainer::Add(FTGlyph* tempGlyph, const unsigned int charCode)
 {
-    charMap->InsertIndex(characterCode, glyphs.size());
+    charMap->InsertIndex(charCode, glyphs.size());
     glyphs.push_back(tempGlyph);
 }
 
 
-const FTGlyph* const FTGlyphContainer::Glyph(const unsigned int characterCode) const
+const FTGlyph* const FTGlyphContainer::Glyph(const unsigned int charCode) const
 {
-    signed int index = charMap->GlyphListIndex(characterCode);
+    unsigned int index = charMap->GlyphListIndex(charCode);
     return glyphs[index];
 }
 
 
-FTBBox FTGlyphContainer::BBox(const unsigned int characterCode) const
+FTBBox FTGlyphContainer::BBox(const unsigned int charCode) const
 {
-    return glyphs[charMap->GlyphListIndex(characterCode)]->BBox();
+    return Glyph(charCode)->BBox();
 }
 
 
-float FTGlyphContainer::Advance(const unsigned int characterCode, const unsigned int nextCharacterCode)
+float FTGlyphContainer::Advance(const unsigned int charCode,
+                                const unsigned int nextCharCode)
 {
-    unsigned int left = charMap->FontIndex(characterCode);
-    unsigned int right = charMap->FontIndex(nextCharacterCode);
+    unsigned int left = charMap->FontIndex(charCode);
+    unsigned int right = charMap->FontIndex(nextCharCode);
 
-    float width = face->KernAdvance(left, right).Xf();
-    width += glyphs[charMap->GlyphListIndex(characterCode)]->Advance().Xf();
-
-    return width;
+    return face->KernAdvance(left, right).Xf()
+                   + Glyph(charCode)->Advance().Xf();
 }
 
 
-FTPoint FTGlyphContainer::Render(const unsigned int characterCode, const unsigned int nextCharacterCode, FTPoint penPosition, int renderMode)
+FTPoint FTGlyphContainer::Render(const unsigned int charCode,
+                                 const unsigned int nextCharCode,
+                                 FTPoint penPosition, int renderMode)
 {
-    FTPoint kernAdvance, advance;
-
-    unsigned int left = charMap->FontIndex(characterCode);
-    unsigned int right = charMap->FontIndex(nextCharacterCode);
+    unsigned int left = charMap->FontIndex(charCode);
+    unsigned int right = charMap->FontIndex(nextCharCode);
 
-    kernAdvance = face->KernAdvance(left, right);
+    FTPoint kernAdvance = face->KernAdvance(left, right);
 
     if(!face->Error())
     {
-        advance = glyphs[charMap->GlyphListIndex(characterCode)]->Render(penPosition, renderMode);
+        unsigned int index = charMap->GlyphListIndex(charCode);
+        kernAdvance += glyphs[index]->Render(penPosition, renderMode);
     }
 
-    kernAdvance += advance;
     return kernAdvance;
 }
+