From 3c6e347a1e98b56dea7605330f7d7e124172ea12 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Fri, 30 Mar 2007 16:50:07 +1000 Subject: Fix glyph width for ttf As usual with glyph metrics, I only half understand what's going on there :-) From trial and error, it looks like the margin thing we apply for stroke font is no good for ttf, at least not using a margin does make things much nicer for me using ttf fonts Signed-off-by: Benjamin Herrenschmidt --- libtwin/twin_font.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libtwin/twin_font.c b/libtwin/twin_font.c index f7e5d70..5ad211c 100644 --- a/libtwin/twin_font.c +++ b/libtwin/twin_font.c @@ -156,19 +156,20 @@ static void _twin_text_compute_info (twin_path_t *path, info->scale.x = path->state.font_size; info->scale.y = path->state.font_size; - if (font->type != TWIN_FONT_TYPE_STROKE) + if (font->type != TWIN_FONT_TYPE_STROKE) { info->pen.x = info->pen.y = 0; - else { + info->margin.x = info->margin.y = 0; + } else { if (path->state.font_style & TWIN_TEXT_BOLD) info->pen.x = path->state.font_size / 16; else info->pen.x = path->state.font_size / 24; info->pen.y = info->pen.x; + info->margin.x = path->state.font_size / 24; + info->margin.y = info->margin.x; + } - info->margin.x = path->state.font_size / 24; - info->margin.y = info->margin.x; - info->pen_matrix = path->state.matrix; twin_matrix_translate (&info->matrix, info->margin.x + info->pen.x, -info->pen.y); @@ -297,6 +298,9 @@ static twin_fixed_t _twin_glyph_width (twin_text_info_t *info, right_side_bearing = right + info->margin.x; width = right_side_bearing + info->margin.x; + + DBGMSG(("gw: g_right=%d right=%f, rsb=%f, margin_x=%f, width=%f\n", + twin_glyph_right(b), F(right), F(right_side_bearing), F(info->margin.x), F(width))); return width; } -- cgit 1.2.3-korg