summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-10-19 02:16:27 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-10-19 16:42:26 -0400
commite76ee94bb87dcd6ff808a777e0d251b318620eee (patch)
treef2b5f8be6cb8e31fc9e3df993c2778cf7b4269e4
parent20ec670e124e4461075a2967faa29603d25106cc (diff)
downloadpango-e76ee94bb87dcd6ff808a777e0d251b318620eee.tar.gz
Fix empty line heights
Fix the calculation of line height for empty lines to take the line-height attributes into account like we do for non-empty lines.
-rw-r--r--pango/pango-layout.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 74799ddc..ff2b2fba 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -5122,6 +5122,8 @@ pango_layout_get_empty_extents_and_height_at_index (PangoLayout *layout,
PangoFont *font;
PangoFontDescription *font_desc = NULL;
gboolean free_font_desc = FALSE;
+ double line_height_factor = 0.0;
+ int absolute_line_height = 0;
font_desc = pango_context_get_font_description (layout->context);
@@ -5147,6 +5149,8 @@ pango_layout_get_empty_extents_and_height_at_index (PangoLayout *layout,
if (start <= index && index < end)
{
+ PangoAttribute *attr;
+
if (!free_font_desc)
{
font_desc = pango_font_description_copy_static (font_desc);
@@ -5158,6 +5162,14 @@ pango_layout_get_empty_extents_and_height_at_index (PangoLayout *layout,
NULL,
NULL);
+ attr = pango_attr_iterator_get (&iter, PANGO_ATTR_LINE_HEIGHT);
+ if (attr)
+ line_height_factor = ((PangoAttrFloat *)attr)->value;
+
+ attr = pango_attr_iterator_get (&iter, PANGO_ATTR_ABSOLUTE_LINE_HEIGHT);
+ if (attr)
+ absolute_line_height = ((PangoAttrInt *)attr)->value;
+
break;
}
@@ -5183,6 +5195,17 @@ pango_layout_get_empty_extents_and_height_at_index (PangoLayout *layout,
*height = pango_font_metrics_get_height (metrics);
pango_font_metrics_unref (metrics);
+
+ if (absolute_line_height != 0 || line_height_factor != 0.0)
+ {
+ int line_height, leading;
+
+ line_height = MAX (absolute_line_height, ceilf (line_height_factor * logical_rect->height));
+
+ leading = line_height - logical_rect->height;
+ logical_rect->y -= leading / 2;
+ logical_rect->height += leading;
+ }
}
else
{
@@ -5347,6 +5370,7 @@ pango_layout_run_get_extents_and_height (PangoLayoutRun *run,
int line_height, leading;
line_height = MAX (properties.absolute_line_height, ceilf (properties.line_height * line_logical->height));
+
leading = line_height - line_logical->height;
line_logical->y -= leading / 2;
line_logical->height += leading;