From 7ae12b0cc50eafcb27067d494ea8378b4d1d9712 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 29 May 2003 00:19:58 +0000 Subject: [PATCH] move the measure func to render.c its more similar code there --- glft/font.c | 32 +------------------------------- glft/render.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/glft/font.c b/glft/font.c index 33285506..6ebab367 100644 --- a/glft/font.c +++ b/glft/font.c @@ -252,6 +252,7 @@ struct GlftGlyph *GlftFontGlyph(struct GlftFont *font, const char *c) } else { /*g->width = TRUNC(ROUND(font->face->glyph->advance.x));*/ g->width = font->face->glyph->metrics.width >> 6; + g_message("Width: %c = %d", *c, g->width); } g->height = -(font->face->glyph->metrics.height >> 6); @@ -260,34 +261,3 @@ struct GlftGlyph *GlftFontGlyph(struct GlftFont *font, const char *c) return g; } - -void GlftMeasureString(struct GlftFont *font, - const char *str, - int bytes, - int *w, - int *h) -{ - const char *c; - struct GlftGlyph *g; - - if (!g_utf8_validate(str, bytes, NULL)) { - GlftDebug("Invalid UTF-8 in string\n"); - return; - } - - *w = 0; - *h = 0; - - c = str; - while (c - str < bytes) { - g = GlftFontGlyph(font, c); - if (g) { - *w += g->width; - *h = MAX(g->height, *h); - } else { - *w += font->max_advance_width; - } - c = g_utf8_next_char(c); - } -} - diff --git a/glft/render.c b/glft/render.c index 5bb2711e..5ea2bfea 100644 --- a/glft/render.c +++ b/glft/render.c @@ -105,3 +105,33 @@ void GlftRenderString(struct GlftFont *font, const char *str, int bytes, glPopMatrix(); } + +void GlftMeasureString(struct GlftFont *font, + const char *str, + int bytes, + int *w, + int *h) +{ + const char *c; + struct GlftGlyph *g; + + if (!g_utf8_validate(str, bytes, NULL)) { + GlftDebug("Invalid UTF-8 in string\n"); + return; + } + + *w = 0; + *h = 0; + + c = str; + while (c - str < bytes) { + g = GlftFontGlyph(font, c); + if (g) { + *w += g->width; + *h = MAX(g->height, *h); + } else { + *w += font->max_advance_width; + } + c = g_utf8_next_char(c); + } +} -- 2.34.1