* Fix an off-by-one error in FTBufferGlyph::Render.
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
diff --git a/src/FTFont/FTBufferFont.cpp b/src/FTFont/FTBufferFont.cpp
index a9e4f33..eadd394 100644
--- a/src/FTFont/FTBufferFont.cpp
+++ b/src/FTFont/FTBufferFont.cpp
@@ -134,14 +134,14 @@ inline FTPoint FTBufferFontImpl::RenderI(const T* string, const int len,
FTPoint position, FTPoint spacing,
int renderMode)
{
- const float border = 1.0f;
+ const float padding = 3.0f;
FTBBox bbox = BBox(string, len, position, spacing);
int width = static_cast<int>(bbox.Upper().X() - bbox.Lower().X()
- + border + border + 0.5);
+ + padding + padding + 0.5);
int height = static_cast<int>(bbox.Upper().Y() - bbox.Lower().Y()
- + border + border + 0.5);
+ + padding + padding + 0.5);
int texWidth = NextPowerOf2(width);
int texHeight = NextPowerOf2(height);
@@ -155,7 +155,7 @@ inline FTPoint FTBufferFontImpl::RenderI(const T* string, const int len,
buffer->width = texWidth;
buffer->height = texHeight;
buffer->pitch = texWidth;
- buffer->pos = FTPoint(1, 1) - bbox.Lower();
+ buffer->pos = FTPoint(padding, padding) - bbox.Lower();
FTPoint tmp = FTFontImpl::Render(string, len, position,
spacing, renderMode);
@@ -182,17 +182,17 @@ inline FTPoint FTBufferFontImpl::RenderI(const T* string, const int len,
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
- glTexCoord2f(border / texWidth,
- (texHeight - height + border) / texHeight);
+ glTexCoord2f(padding / texWidth,
+ (texHeight - height + padding) / texHeight);
glVertex2f(bbox.Lower().Xf(), bbox.Upper().Yf());
- glTexCoord2f(border / texWidth,
- (texHeight - border) / texHeight);
+ glTexCoord2f(padding / texWidth,
+ (texHeight - padding) / texHeight);
glVertex2f(bbox.Lower().Xf(), bbox.Lower().Yf());
- glTexCoord2f((width - border) / texWidth,
- (texHeight - border) / texHeight);
+ glTexCoord2f((width - padding) / texWidth,
+ (texHeight - padding) / texHeight);
glVertex2f(bbox.Upper().Xf(), bbox.Lower().Yf());
- glTexCoord2f((width - border) / texWidth,
- (texHeight - height + border) / texHeight);
+ glTexCoord2f((width - padding) / texWidth,
+ (texHeight - height + padding) / texHeight);
glVertex2f(bbox.Upper().Xf(), bbox.Upper().Yf());
glEnd();
diff --git a/src/FTGlyph/FTBufferGlyph.cpp b/src/FTGlyph/FTBufferGlyph.cpp
index b0b00e7..861ee6a 100644
--- a/src/FTGlyph/FTBufferGlyph.cpp
+++ b/src/FTGlyph/FTBufferGlyph.cpp
@@ -94,7 +94,7 @@ const FTPoint& FTBufferGlyphImpl::RenderImpl(const FTPoint& pen, int renderMode)
{
FTPoint pos(buffer->pos + pen + corner);
int dx = (int)(pos.Xf() + 0.5f);
- int dy = buffer->height - 1 - (int)(pos.Yf() + 0.5f);
+ int dy = buffer->height - (int)(pos.Yf() + 0.5f);
unsigned char * dest = buffer->pixels + dx + dy * buffer->pitch;
for(int y = 0; y < bitmap.rows; y++)