Fix padding usage in FTBufferFont, patch courtesy of Benlitz. Addresses sourceforge bug #2023590.
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
diff --git a/src/FTFont/FTBufferFont.cpp b/src/FTFont/FTBufferFont.cpp
index 73a875d..a171c87 100644
--- a/src/FTFont/FTBufferFont.cpp
+++ b/src/FTFont/FTBufferFont.cpp
@@ -304,22 +304,22 @@ inline FTPoint FTBufferFontImpl::RenderI(const T* string, const int len,
buffer->Size(0, 0);
}
- FTPoint low = position + bbox.Lower();
- FTPoint up = position + bbox.Upper();
+ FTPoint low = position + bbox.Lower() - FTPoint(padding, padding);
+ FTPoint up = position + bbox.Upper() + FTPoint(padding, padding);
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
- glTexCoord2f(padding / texWidth,
- (texHeight - height + padding) / texHeight);
+ glTexCoord2f(0.0f,
+ 1.0f / texHeight * (texHeight - height));
glVertex2f(low.Xf(), up.Yf());
- glTexCoord2f(padding / texWidth,
- (texHeight - padding) / texHeight);
+ glTexCoord2f(0.0f,
+ 1.0f);
glVertex2f(low.Xf(), low.Yf());
- glTexCoord2f((width - padding) / texWidth,
- (texHeight - padding) / texHeight);
+ glTexCoord2f(1.0f / texWidth * width,
+ 1.0f);
glVertex2f(up.Xf(), low.Yf());
- glTexCoord2f((width - padding) / texWidth,
- (texHeight - height + padding) / texHeight);
+ glTexCoord2f(1.0f / texWidth * width,
+ 1.0f / texHeight * (texHeight - height));
glVertex2f(up.Xf(), up.Yf());
glEnd();