summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-05-30 04:24:32 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-05-30 04:24:32 +0000
commit1668f1ca023fd0b227185b67a15fb0f639b4060e (patch)
treef66fe53c9d3cffb326dd33233c500936d9479bb1
parente6759c74462435d23512ede99f48554f69e4db6a (diff)
downloadpango-1668f1ca023fd0b227185b67a15fb0f639b4060e.tar.gz
Bug 125378 – Better underline thickness handling
2006-05-30 Behdad Esfahbod <behdad@gnome.org> Bug 125378 – Better underline thickness handling * pango/pango-layout.c (pango_layout_run_get_extents): Include underline in ink extents.
-rw-r--r--ChangeLog7
-rw-r--r--pango/pango-layout.c75
2 files changed, 42 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index f383feb2..7e45270c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-05-30 Behdad Esfahbod <behdad@gnome.org>
+
+ Bug 125378 – Better underline thickness handling
+
+ * pango/pango-layout.c (pango_layout_run_get_extents): Include
+ underline in ink extents.
+
2006-05-26 Behdad Esfahbod <behdad@gnome.org>
* === Released 1.12.3 ===
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index f2283e57..2bb62b43 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3892,57 +3892,52 @@ pango_layout_run_get_extents (PangoLayoutRun *run,
PangoRectangle *run_logical)
{
ItemProperties properties;
- PangoRectangle tmp_ink;
- gboolean need_ink;
pango_layout_get_item_properties (run->item, &properties);
- need_ink = run_ink || properties.uline == PANGO_UNDERLINE_LOW;
-
if (properties.shape_set)
imposed_extents (run->item->num_chars,
properties.shape_ink_rect,
properties.shape_logical_rect,
- need_ink ? &tmp_ink : NULL, run_logical);
+ run_ink, run_logical);
else
pango_glyph_string_extents (run->glyphs, run->item->analysis.font,
- need_ink ? &tmp_ink : NULL,
- run_logical);
-
- if (run_ink)
- *run_ink = tmp_ink;
+ run_ink, run_logical);
- switch (properties.uline)
+ if (properties.uline != PANGO_UNDERLINE_NONE)
{
- case PANGO_UNDERLINE_NONE:
- break;
- case PANGO_UNDERLINE_ERROR:
- if (run_ink)
- run_ink->height = MAX (run_ink->height, 3 * PANGO_SCALE - run_ink->y);
- if (run_logical)
- run_logical->height = MAX (run_logical->height, 3 * PANGO_SCALE - run_logical->y);
- break;
- case PANGO_UNDERLINE_SINGLE:
- if (run_ink)
- run_ink->height = MAX (run_ink->height, 2 * PANGO_SCALE - run_ink->y);
- if (run_logical)
- run_logical->height = MAX (run_logical->height, 2 * PANGO_SCALE - run_logical->y);
- break;
- case PANGO_UNDERLINE_DOUBLE:
- if (run_ink)
- run_ink->height = MAX (run_ink->height, 4 * PANGO_SCALE - run_ink->y);
- if (run_logical)
- run_logical->height = MAX (run_logical->height, 4 * PANGO_SCALE - run_logical->y);
- break;
- case PANGO_UNDERLINE_LOW:
- /* FIXME: Should this simply be run_logical->height += 2 * PANGO_SCALE instead?
- */
- if (run_ink)
- run_ink->height += 2 * PANGO_SCALE;
- if (run_logical)
- run_logical->height = MAX (run_logical->height,
- tmp_ink.y + tmp_ink.height + 2 * PANGO_SCALE - run_logical->y);
- break;
+ PangoFontMetrics *metrics = pango_font_get_metrics (run->item->analysis.font,
+ run->item->analysis.language);
+ int underline_thickness = pango_font_metrics_get_underline_thickness (metrics);
+ int underline_position = pango_font_metrics_get_underline_position (metrics);
+
+ switch (properties.uline)
+ {
+ case PANGO_UNDERLINE_ERROR:
+ if (run_ink)
+ run_ink->height = MAX (run_ink->height,
+ 3 * underline_thickness - underline_position - run_ink->y);
+ break;
+ case PANGO_UNDERLINE_SINGLE:
+ if (run_ink)
+ run_ink->height = MAX (run_ink->height,
+ underline_thickness - underline_position - run_ink->y);
+ break;
+ case PANGO_UNDERLINE_DOUBLE:
+ if (run_ink)
+ run_ink->height = MAX (run_ink->height,
+ 3 * underline_thickness - underline_position - run_ink->y);
+ break;
+ case PANGO_UNDERLINE_LOW:
+ if (run_ink)
+ run_ink->height += 2 * underline_thickness;
+ break;
+ default:
+ g_critical ("unknown underline mode");
+ break;
+ }
+
+ pango_font_metrics_unref (metrics);
}
if (properties.rise != 0)