Commit f300fc4977b4bd6db0be79f9a2af27df4d3e1c5a

sammy 2008-04-21T16:09:46

* Fix the FTLayout rendering: line feeds were not properly handled. Patch by Eric Beets.

diff --git a/src/FTBitmapGlyph.cpp b/src/FTBitmapGlyph.cpp
index b5451ff..e913b86 100644
--- a/src/FTBitmapGlyph.cpp
+++ b/src/FTBitmapGlyph.cpp
@@ -85,17 +85,22 @@ FTBitmapGlyph::~FTBitmapGlyph()
 }
 
 
-const FTPoint& FTBitmapGlyph::Render( const FTPoint& pen)
+const FTPoint& FTBitmapGlyph::Render(const FTPoint& pen)
 {
-    glBitmap( 0, 0, 0.0f, 0.0f, pen.X() + pos.X(), pen.Y() - pos.Y(), (const GLubyte*)0 );
-    
-    if( data)
+    if(data)
     {
-        glPixelStorei( GL_UNPACK_ROW_LENGTH, destPitch * 8);
-        glBitmap( destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0, (const GLubyte*)data);
+        float dx, dy;
+
+        dx = pen.X() + pos.X();
+        dy = pen.Y() - pos.Y();
+
+        glBitmap(0, 0, 0.0f, 0.0f, dx, dy, (const GLubyte*)0);
+        glPixelStorei(GL_UNPACK_ROW_LENGTH, destPitch * 8);
+        glBitmap(destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0,
+                 (const GLubyte*)data);
+        glBitmap(0, 0, 0.0f, 0.0f, -dx, -dy, (const GLubyte*)0);
     }
     
-    glBitmap( 0, 0, 0.0f, 0.0f, -pos.X(), pos.Y(), (const GLubyte*)0 );
-    
     return advance;
 }
+
diff --git a/src/FTExtrdGlyph.cpp b/src/FTExtrdGlyph.cpp
index 6436810..b767329 100644
--- a/src/FTExtrdGlyph.cpp
+++ b/src/FTExtrdGlyph.cpp
@@ -174,11 +174,11 @@ FTExtrdGlyph::~FTExtrdGlyph()
 
 const FTPoint& FTExtrdGlyph::Render(const FTPoint& pen)
 {
-    glTranslatef(pen.X(), pen.Y(), 0);
-    
     if(glList)
     {
+        glTranslatef(pen.X(), pen.Y(), 0);
         glCallList(glList);    
+        glTranslatef(-pen.X(), -pen.Y(), 0);
     }
     
     return advance;
diff --git a/src/FTFont.cpp b/src/FTFont.cpp
index 571db86..c5d1eeb 100644
--- a/src/FTFont.cpp
+++ b/src/FTFont.cpp
@@ -267,7 +267,7 @@ void FTFont::DoRender(const unsigned int chr,
     if(CheckGlyph(chr))
     {
         FTPoint kernAdvance = glyphList->Render(chr, nextChr, origin);
-        origin = kernAdvance;
+        origin += kernAdvance;
     }
 }
 
@@ -280,10 +280,7 @@ inline void FTFont::RenderI(const T* string)
 
     while(*c)
     {
-        if(CheckGlyph(*c))
-        {
-            pen = glyphList->Render(*c, *(c + 1), pen);
-        }
+        DoRender(*c, *(c + 1), pen);
         ++c;
     }
 }
diff --git a/src/FTOutlineGlyph.cpp b/src/FTOutlineGlyph.cpp
index eca616e..64c6d88 100644
--- a/src/FTOutlineGlyph.cpp
+++ b/src/FTOutlineGlyph.cpp
@@ -88,13 +88,13 @@ FTOutlineGlyph::~FTOutlineGlyph()
 }
 
 
-const FTPoint& FTOutlineGlyph::Render( const FTPoint& pen)
+const FTPoint& FTOutlineGlyph::Render(const FTPoint& pen)
 {
-    glTranslatef( pen.X(), pen.Y(), 0.0f);
-
-    if( glList)
+    if(glList)
     {
-        glCallList( glList);
+        glTranslatef(pen.X(), pen.Y(), 0.0f);
+        glCallList(glList);
+        glTranslatef(-pen.X(), -pen.Y(), 0.0f);
     }
     
     return advance;
diff --git a/src/FTPixmapGlyph.cpp b/src/FTPixmapGlyph.cpp
index 36ef647..95bf651 100644
--- a/src/FTPixmapGlyph.cpp
+++ b/src/FTPixmapGlyph.cpp
@@ -91,19 +91,24 @@ FTPixmapGlyph::~FTPixmapGlyph()
 }
 
 
-const FTPoint& FTPixmapGlyph::Render( const FTPoint& pen)
+const FTPoint& FTPixmapGlyph::Render(const FTPoint& pen)
 {
-    glBitmap( 0, 0, 0.0f, 0.0f, pen.X() + pos.X(), pen.Y() - pos.Y(), (const GLubyte*)0);
-    
-    if( data)
+    if(data)
     {
-        glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
-        glPixelStorei( GL_UNPACK_ALIGNMENT, 2);
+        float dx, dy;
+
+        dx = pen.X() + pos.X();
+        dy = pen.Y() - pos.Y();
+
+        glBitmap(0, 0, 0.0f, 0.0f, dx, dy, (const GLubyte*)0);
+        glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+        glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
 
-        glDrawPixels( destWidth, destHeight, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, (const GLvoid*)data);
+        glDrawPixels(destWidth, destHeight, GL_LUMINANCE_ALPHA,
+                     GL_UNSIGNED_BYTE, (const GLvoid*)data);
+        glBitmap(0, 0, 0.0f, 0.0f, -dx, -dy, (const GLubyte*)0);
     }
-        
-    glBitmap( 0, 0, 0.0f, 0.0f, -pos.X(), pos.Y(), (const GLubyte*)0);
 
     return advance;
 }
+
diff --git a/src/FTPolyGlyph.cpp b/src/FTPolyGlyph.cpp
index 97ec4d4..02d1432 100644
--- a/src/FTPolyGlyph.cpp
+++ b/src/FTPolyGlyph.cpp
@@ -100,14 +100,15 @@ FTPolyGlyph::~FTPolyGlyph()
 }
 
 
-const FTPoint& FTPolyGlyph::Render( const FTPoint& pen)
+const FTPoint& FTPolyGlyph::Render(const FTPoint& pen)
 {
-    glTranslatef(  pen.X(),  pen.Y(), 0.0f);
-
-    if( glList)
+    if(glList)
     {
-        glCallList( glList);    
+        glTranslatef(pen.X(), pen.Y(), 0.0f);
+        glCallList(glList);
+        glTranslatef(-pen.X(), -pen.Y(), 0.0f);
     }
     
     return advance;
 }
+