From 6582ad8f95da00e5f6f4118f235c4148888fcaf0 Mon Sep 17 00:00:00 2001 From: HW Date: Thu, 8 Dec 2011 00:39:40 +0100 Subject: [PATCH] restructured glyph blitting a bit and fixed bug --- ft.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ft.c b/ft.c index 0131d684d..5cfc9b69b 100644 --- a/ft.c +++ b/ft.c @@ -107,7 +107,7 @@ static int renderGlyph(lua_State *L) { return luaL_error(L, "freetype error"); } - int w = (*face)->glyph->bitmap.width; // 2px steps + int w = (*face)->glyph->bitmap.width; int h = (*face)->glyph->bitmap.rows; lua_newtable(L); @@ -120,22 +120,19 @@ static int renderGlyph(lua_State *L) { lua_setfield(L, -2, "bb"); - bb->w = w; - bb->h = h; - uint8_t *dst = bb->data; int y; int x; - w = (*face)->glyph->bitmap.width; for(y = 0; y < h; y++) { uint8_t *src = (*face)->glyph->bitmap.buffer + y * (*face)->glyph->bitmap.pitch; - for(x = 0; x < w; x+=2) { + for(x = 0; x < (w/2); x++) { *dst = (src[0] & 0xF0) | (src[1] >> 4); src+=2; dst++; } if(w & 1) { - *dst = (*src & 0xF0) >> 4; + *dst = *src & 0xF0; + dst++; } }