From: Derek Foreman Date: Thu, 29 May 2003 23:08:26 +0000 (+0000) Subject: use bitmap width for texturing X-Git-Tag: gl2~22 X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=12052a296d95aa740cda6426b83e0d6218d55053;p=dana%2Fopenbox.git use bitmap width for texturing --- diff --git a/glft/font.h b/glft/font.h index 2494358e..12fa6d0f 100644 --- a/glft/font.h +++ b/glft/font.h @@ -58,6 +58,7 @@ struct GlftGlyph { int height; int padx, pady; + int texw, texh; }; /*! Takes a character in UTF-8 encoding and returns an OpenGL display list diff --git a/glft/render.c b/glft/render.c index 3180d5f2..fa7c33ec 100644 --- a/glft/render.c +++ b/glft/render.c @@ -17,6 +17,9 @@ void GlftRenderGlyph(FT_Face face, struct GlftGlyph *g) err = FT_Render_Glyph(slot, ft_render_mode_normal); g_assert(!err); + g->texw = slot->bitmap.width; + g->texh = slot->bitmap.rows; + g->padx = 1; while (g->padx < slot->bitmap.width) g->padx <<= 1; @@ -26,6 +29,7 @@ void GlftRenderGlyph(FT_Face face, struct GlftGlyph *g) g->pady <<= 1; padbuf = g_new0(unsigned char, g->padx * g->pady); +printf("glyph rendered to %d wide\n", slot->bitmap.width); for (i = 0; i < slot->bitmap.rows; i++) memcpy(padbuf + i*g->padx, slot->bitmap.buffer + i*slot->bitmap.width, @@ -60,22 +64,23 @@ void GlftRenderString(struct GlftFont *font, const char *str, int bytes, while (c - str < bytes) { g = GlftFontGlyph(font, c); if (g) { +printf("glyph width %d(%d)\n", g->width, g->x); glTranslatef(GlftFontAdvance(font, p, g), 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, g->tnum); glBegin(GL_QUADS); glColor3f(0.0, 0.0, 0.0); - glTexCoord2f(0, g->height/(float)g->pady); + glTexCoord2f(0, g->texh/(float)g->pady); glVertex2i(0, 0); - glTexCoord2f(g->width/(float)g->padx, g->height/(float)g->pady); - glVertex2i(0 + g->width, 0); + glTexCoord2f(g->texw/(float)g->padx, g->texh/(float)g->pady); + glVertex2i(0 + g->texw, 0); - glTexCoord2f(g->width/(float)g->padx, 0); - glVertex2i(0 + g->width, 0 + g->height); + glTexCoord2f(g->texw/(float)g->padx, 0); + glVertex2i(0 + g->texw, 0 + g->texh); glTexCoord2f(0, 0); - glVertex2i(0, 0 + g->height); + glVertex2i(0, 0 + g->texh); glEnd(); } else glTranslatef(font->max_advance_width, 0.0, 0.0);