aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2007-03-30 16:50:07 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2007-03-30 16:50:07 +1000
commit3c6e347a1e98b56dea7605330f7d7e124172ea12 (patch)
tree6a194442938d438b948291f890d5a5ff93ff265a
parent2ccc4ec8e0662d6afb441b0ed7719495b913578d (diff)
downloadlibtwin-3c6e347a1e98b56dea7605330f7d7e124172ea12.tar.gz
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 <benh@kernel.crashing.org>
-rw-r--r--libtwin/twin_font.c14
1 files 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;
}