Commit 32ef6d1e3e9387a88781ceaf1a70ba9816083cd2

sammy 2008-05-11T11:29:17

* Get rid of FTFontImpl::DoRender(), one of the oldest TODOs.

diff --git a/src/FTFont/FTFont.cpp b/src/FTFont/FTFont.cpp
index b90e1a6..8f21feb 100644
--- a/src/FTFont/FTFont.cpp
+++ b/src/FTFont/FTFont.cpp
@@ -414,16 +414,15 @@ template <typename T>
 inline FTPoint FTFontImpl::AdvanceI(const T* string, const int len,
                                     FTPoint position, FTPoint spacing)
 {
-    const T* c = string;
-
-    while(*c)
+    for(int i = 0; (len < 0 && string[i]) || (len >= 0 && i < len); i++)
     {
-        if(CheckGlyph(*c))
+        if(CheckGlyph(string[i]))
         {
-            position += glyphList->Advance(*c, *(c + 1));
+            position += glyphList->Advance((unsigned int)string[i],
+                                           (unsigned int)string[i + 1]);
         }
-        ++c;
-        if(*c)
+
+        if(string[i + 1])
         {
             position += spacing;
         }
@@ -449,30 +448,21 @@ FTPoint FTFontImpl::Advance(const wchar_t* string, const int len,
 }
 
 
-/* FIXME: DoRender should disappear, see commit [853]. */
-void FTFontImpl::DoRender(const unsigned int chr, const unsigned int nextChr,
-                          FTPoint &origin, int renderMode)
-{
-    if(CheckGlyph(chr))
-    {
-        FTPoint kernAdvance = glyphList->Render(chr, nextChr, origin, renderMode);
-        origin += kernAdvance;
-    }
-}
-
-
 template <typename T>
 inline FTPoint FTFontImpl::RenderI(const T* string, const int len,
                                    FTPoint position, FTPoint spacing,
                                    int renderMode)
 {
-    const T* c = string;
-
-    while(*c)
+    for(int i = 0; (len < 0 && string[i]) || (len >= 0 && i < len); i++)
     {
-        DoRender(*c, *(c + 1), position, renderMode);
-        ++c;
-        if(*c)
+        if(CheckGlyph(string[i]))
+        {
+            position += glyphList->Render((unsigned int)string[i],
+                                          (unsigned int)string[i + 1],
+                                          position, renderMode);
+        }
+
+        if(string[i + 1])
         {
             position += spacing;
         }
diff --git a/src/FTFont/FTFontImpl.h b/src/FTFont/FTFontImpl.h
index 2c1bf6e..d9891b1 100644
--- a/src/FTFont/FTFontImpl.h
+++ b/src/FTFont/FTFontImpl.h
@@ -36,7 +36,7 @@ class FTLayout;
 
 class FTFontImpl
 {
-        /* Allow FTLayout classes to access DoRender and CheckGlyph */
+        /* Allow FTLayout classes to access CheckGlyph */
         friend class FTLayoutImpl;
         friend class FTFont;
 
@@ -123,22 +123,6 @@ class FTFontImpl
         FTFont *intf;
 
         /**
-         * Render a character.
-         * This function does an implicit conversion on its arguments.
-         *
-         * @param chr       current character
-         * @param nextChr   next character
-         * @param origin       The position of the origin of the character.
-         *                  After rendering the point referenced by origin
-         *                  will be incremented by the kerning advance of
-         *                  char and nextChr.
-         * @param renderMode    Render mode to display
-         */
-        void DoRender(const unsigned int chr,
-                      const unsigned int nextChr, FTPoint &origin,
-                      int renderMode);
-
-        /**
          * Check that the glyph at <code>chr</code> exist. If not load it.
          *
          * @param chr  character index
diff --git a/src/FTLayout/FTLayout.cpp b/src/FTLayout/FTLayout.cpp
index 8a33fa4..193344e 100644
--- a/src/FTLayout/FTLayout.cpp
+++ b/src/FTLayout/FTLayout.cpp
@@ -81,7 +81,12 @@ FTLayoutImpl::~FTLayoutImpl()
 void FTLayoutImpl::DoRender(FTFont *font, const unsigned int chr,
                             const unsigned int nextChr, int renderMode)
 {
-    font->impl->DoRender(chr, nextChr, pen, renderMode);
+    wchar_t string[3];
+    string[0] = chr;
+    string[1] = nextChr;
+    string[2] = '\0';
+
+    pen = font->Render(string, 1, pen, FTPoint(), renderMode);
 }