summaryrefslogtreecommitdiff
path: root/pango/pango-layout.c
diff options
context:
space:
mode:
authorArtem Rebrov <artem.rebrov@devexpress.com>2021-07-08 19:21:37 +0300
committerArtem Rebrov <artem.rebrov@devexpress.com>2021-07-08 19:21:37 +0300
commit2690612cf3acb19449bc0fc98e9cc66a1f83849c (patch)
treedad8f5533255757436bec8be9447a0eca6f77591 /pango/pango-layout.c
parentf3aec778e817f685498e949663c67b72f27e0308 (diff)
downloadpango-2690612cf3acb19449bc0fc98e9cc66a1f83849c.tar.gz
layout: make the height of an empty line match a regular line
When using line-spacing, the height of an empty line is the same as when line-spacing has zero value. Take the value from font metrics.
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r--pango/pango-layout.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 0227f819..87d2a2a9 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -176,9 +176,10 @@ static PangoLayoutLine* _pango_layout_iter_get_line (PangoLayoutIter *iter);
static void pango_layout_get_item_properties (PangoItem *item,
ItemProperties *properties);
-static void pango_layout_get_empty_extents_at_index (PangoLayout *layout,
+static void pango_layout_get_empty_extents_and_height_at_index (PangoLayout *layout,
int index,
- PangoRectangle *logical_rect);
+ PangoRectangle *logical_rect,
+ int *height);
static void pango_layout_finalize (GObject *object);
@@ -4330,8 +4331,9 @@ pango_layout_check_lines (PangoLayout *layout)
if (layout->height >= 0)
{
PangoRectangle logical;
- pango_layout_get_empty_extents_at_index (layout, 0, &logical);
- state.line_height = logical.height;
+ int height;
+ pango_layout_get_empty_extents_and_height_at_index (layout, 0, &logical, &height);
+ state.line_height = layout->line_spacing == 0.0 ? logical.height : layout->line_spacing * height;
}
do
@@ -4879,9 +4881,10 @@ pango_layout_line_get_x_ranges (PangoLayoutLine *line,
}
static void
-pango_layout_get_empty_extents_at_index (PangoLayout *layout,
- int index,
- PangoRectangle *logical_rect)
+pango_layout_get_empty_extents_and_height_at_index (PangoLayout *layout,
+ int index,
+ PangoRectangle *logical_rect,
+ int *height)
{
if (logical_rect)
{
@@ -4945,6 +4948,8 @@ pango_layout_get_empty_extents_at_index (PangoLayout *layout,
{
logical_rect->y = - pango_font_metrics_get_ascent (metrics);
logical_rect->height = - logical_rect->y + pango_font_metrics_get_descent (metrics);
+ if (height)
+ *height = pango_font_metrics_get_height (metrics);
pango_font_metrics_unref (metrics);
}
@@ -4970,10 +4975,11 @@ pango_layout_get_empty_extents_at_index (PangoLayout *layout,
}
static void
-pango_layout_line_get_empty_extents (PangoLayoutLine *line,
- PangoRectangle *logical_rect)
+pango_layout_line_get_empty_extents_and_height (PangoLayoutLine *line,
+ PangoRectangle *logical_rect,
+ int *height)
{
- pango_layout_get_empty_extents_at_index (line->layout, line->start_index, logical_rect);
+ pango_layout_get_empty_extents_and_height_at_index (line->layout, line->start_index, logical_rect, height);
}
static void
@@ -5224,9 +5230,7 @@ pango_layout_line_get_extents_and_height (PangoLayoutLine *line,
PangoRectangle r, *rect;
rect = logical_rect ? logical_rect : &r;
- pango_layout_line_get_empty_extents (line, rect);
- if (height)
- *height = rect->height;
+ pango_layout_line_get_empty_extents_and_height (line, rect, height);
}
if (caching)