* Align FTPixmapGlyph and FTTextureGlyph objects at round pixel coordinates to reduce bleeding. Patch by Ton Roosendaal, from Blender commit r4411.
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
diff --git a/src/FTPixmapGlyph.cpp b/src/FTPixmapGlyph.cpp
index dd56097..00d7dcf 100644
--- a/src/FTPixmapGlyph.cpp
+++ b/src/FTPixmapGlyph.cpp
@@ -34,6 +34,8 @@
#include "config.h"
+#include <math.h>
+
#include "FTPixmapGlyph.h"
FTPixmapGlyph::FTPixmapGlyph( FT_GlyphSlot glyph)
@@ -97,8 +99,8 @@ const FTPoint& FTPixmapGlyph::Render(const FTPoint& pen, int renderMode)
{
float dx, dy;
- dx = pen.X() + pos.X();
- dy = pen.Y() - pos.Y();
+ dx = floor(pen.X() + pos.X());
+ dy = floor(pen.Y() - pos.Y());
glBitmap(0, 0, 0.0f, 0.0f, dx, dy, (const GLubyte*)0);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
diff --git a/src/FTTextureGlyph.cpp b/src/FTTextureGlyph.cpp
index b478f5b..fca61ac 100644
--- a/src/FTTextureGlyph.cpp
+++ b/src/FTTextureGlyph.cpp
@@ -34,6 +34,8 @@
#include "config.h"
+#include <math.h>
+
#include "FTTextureGlyph.h"
GLint FTTextureGlyph::activeTextureID = 0;
@@ -93,30 +95,31 @@ FTTextureGlyph::~FTTextureGlyph()
const FTPoint& FTTextureGlyph::Render(const FTPoint& pen, int renderMode)
{
+ float dx, dy;
+
if(activeTextureID != glTextureID)
{
glBindTexture(GL_TEXTURE_2D, (GLuint)glTextureID);
activeTextureID = glTextureID;
}
- glTranslatef(pen.X(), pen.Y(), 0.0f);
+ dx = floor(pen.X() + pos.X());
+ dy = floor(pen.Y() + pos.Y());
glBegin(GL_QUADS);
glTexCoord2f(uv[0].X(), uv[0].Y());
- glVertex2f(pos.X(), pos.Y());
+ glVertex2f(dx, dy);
glTexCoord2f(uv[0].X(), uv[1].Y());
- glVertex2f(pos.X(), pos.Y() - destHeight);
+ glVertex2f(dx, dy - destHeight);
glTexCoord2f(uv[1].X(), uv[1].Y());
- glVertex2f(destWidth + pos.X(), pos.Y() - destHeight);
+ glVertex2f(dx + destWidth, dy - destHeight);
glTexCoord2f(uv[1].X(), uv[0].Y());
- glVertex2f(destWidth + pos.X(), pos.Y());
+ glVertex2f(dx + destWidth, dy);
glEnd();
- glTranslatef(-pen.X(), -pen.Y(), 0.0f);
-
return advance;
}