summaryrefslogtreecommitdiff
path: root/pango/pangowin32.c
diff options
context:
space:
mode:
authorHans Breuer <hans@breuer.org>2001-05-06 13:58:53 +0000
committerHans Breuer <hans@src.gnome.org>2001-05-06 13:58:53 +0000
commitf10f21057c5fb0626ec16a2e743c68f6f7ee2cab (patch)
tree5ee2b7007984745d329f0bddd258f59e6de16a41 /pango/pangowin32.c
parentff742696f6b093aad1384d879405f51da3b220d3 (diff)
downloadpango-f10f21057c5fb0626ec16a2e743c68f6f7ee2cab.tar.gz
reflect new version number, removed external fribidi dependency from link
2001-01-06 Hans Breuer <hans@breuer.org> * pango/makefile.msc : reflect new version number, removed external fribidi dependency from link step as well * pango/pango.def : updated externals * pango/pangowin32.c : initialize approximate_(digit|char)_width similar to what the other backends do
Diffstat (limited to 'pango/pangowin32.c')
-rw-r--r--pango/pangowin32.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index f3f91d8c..6bfe0293 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -653,12 +653,16 @@ get_font_metrics_from_subfonts (PangoFont *font,
{
metrics->ascent = tm.tmAscent * PANGO_SCALE;
metrics->descent = tm.tmDescent * PANGO_SCALE;
+ metrics->approximate_digit_width = /* really an approximation ... */
+ metrics->approximate_char_width = tm.tmAveCharWidth * PANGO_SCALE;
first = FALSE;
}
else
{
metrics->ascent = MAX (tm.tmAscent * PANGO_SCALE, metrics->ascent);
metrics->descent = MAX (tm.tmDescent * PANGO_SCALE, metrics->descent);
+ metrics->approximate_digit_width = /* really an approximation ... */
+ metrics->approximate_char_width = MAX(tm.tmAveCharWidth * PANGO_SCALE, metrics->approximate_char_width);
}
}
}
@@ -845,12 +849,35 @@ pango_win32_font_get_metrics (PangoFont *font,
if (!tmp_list)
{
+ PangoLayout *layout;
+ PangoRectangle extents;
+ PangoContext *context;
+
+ win32font->metrics_by_lang = g_slist_prepend (win32font->metrics_by_lang, info);
+
info = g_new (PangoWin32MetricsInfo, 1);
info->lang = lookup_lang;
win32font->metrics_by_lang = g_slist_prepend (win32font->metrics_by_lang, info);
get_font_metrics_from_string (font, lang, str, &info->metrics);
+
+ /* lovely copy&paste programming (from pangox.c) */
+ /* This is sort of a sledgehammer solution, but we cache this
+ * stuff so not a huge deal hopefully. Get the avg. width of the
+ * chars in "0123456789"
+ */
+ context = pango_win32_get_context ();
+ pango_context_set_lang (context, lookup_lang);
+ layout = pango_layout_new (context);
+ pango_layout_set_text (layout, "0123456789", -1);
+
+ pango_layout_get_extents (layout, NULL, &extents);
+
+ info->metrics.approximate_digit_width = extents.width / 10.0;
+
+ g_object_unref (G_OBJECT (layout));
+ g_object_unref (G_OBJECT (context));
}
*metrics = info->metrics;