summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-05-30 04:23:40 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-05-30 04:23:40 +0000
commitfd3c2ca4ef69e7c4b3677b399ae04d0d6f82bffa (patch)
tree89e515542fbecf6f006cf00d5154869e79a14a7a
parent2707f73f24e379c6c96d3c7f72fdd7440dc5a9cd (diff)
downloadpango-fd3c2ca4ef69e7c4b3677b399ae04d0d6f82bffa.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 f45aeb03..691c4acc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
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-30 Behdad Esfahbod <behdad@gnome.org>
+
* pango/pangocairo-render.c (draw_error_underline): Fix offset to
center the underline in requested rectangle.
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 7b4b5c4e..c95b6390 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3920,57 +3920,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)