summaryrefslogtreecommitdiff
path: root/pango/pango-fontset.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-05-27 19:43:49 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-05-27 19:43:49 +0000
commit4caf16365e5eb027f14e29038c2376e9a9dcf4dc (patch)
treeda0a8722dc20179c972ac29590aa856c3c085b7e /pango/pango-fontset.c
parent5ad5eff481421dbb95f450788807cd10315dc5d6 (diff)
downloadpango-4caf16365e5eb027f14e29038c2376e9a9dcf4dc.tar.gz
Add underline and strikethrough position and thickness metrics.
Thu May 27 15:32:03 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-font.h pango/fonts.c: Add underline and strikethrough position and thickness metrics. * pango/pangofc-font.c: Implement underline and strikethrough position and thickness metrics. * pango/pango-fontset.c (pango_fontset_real_get_metrics): Initialize metrics from the metrics of the first font in the fontset.
Diffstat (limited to 'pango/pango-fontset.c')
-rw-r--r--pango/pango-fontset.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/pango/pango-fontset.c b/pango/pango-fontset.c
index e3f38920..d4aaf351 100644
--- a/pango/pango-fontset.c
+++ b/pango/pango-fontset.c
@@ -100,6 +100,29 @@ pango_fontset_foreach (PangoFontset *fontset,
PANGO_FONTSET_GET_CLASS (fontset)->foreach (fontset, func, data);
}
+static gboolean
+get_first_metrics_foreach (PangoFontset *fontset,
+ PangoFont *font,
+ gpointer data)
+{
+ PangoFontMetrics *fontset_metrics = data;
+ PangoLanguage *language = PANGO_FONTSET_GET_CLASS (fontset)->get_language (fontset);
+ PangoFontMetrics *font_metrics = pango_font_get_metrics (font, language);
+ guint save_ref_count;
+
+ /* Initialize the fontset metrics to metrics of the first font in the
+ * fontset; saving the refcount and restoring it is a bit of hack but avoids
+ * having to update this code for each metrics addition.
+ */
+ save_ref_count = fontset_metrics->ref_count;
+ *fontset_metrics = *font_metrics;
+ fontset_metrics->ref_count = save_ref_count;
+
+ pango_font_metrics_unref (font_metrics);
+
+ return TRUE; /* Stops iteration */
+}
+
static PangoFontMetrics *
pango_fontset_real_get_metrics (PangoFontset *fontset)
{
@@ -118,6 +141,9 @@ pango_fontset_real_get_metrics (PangoFontset *fontset)
metrics = pango_font_metrics_new ();
fonts_seen = g_hash_table_new_full (NULL, NULL, g_object_unref, NULL);
+ /* Initialize the metrics from the first font in the fontset */
+ pango_fontset_foreach (fontset, get_first_metrics_foreach, metrics);
+
p = sample_str;
while (*p)
{