summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-07-09 20:09:03 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-07-09 20:09:03 +0000
commit2590ffe04b9b3d25f14ccbd7d3b6f6571cbb0b8e (patch)
tree34a4f3aa7b627adcc799fd3904c965276892f92f
parent1def38f4cef415264f9d28f8c00c3a3553eecb54 (diff)
parent2690612cf3acb19449bc0fc98e9cc66a1f83849c (diff)
downloadpango-2590ffe04b9b3d25f14ccbd7d3b6f6571cbb0b8e.tar.gz
Merge branch 'fix-empty-line-spacing-2' into 'master'
layout: make the height of an empty line match a regular line Closes #577 See merge request GNOME/pango!363
-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 9b61cf77..a56e5329 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);
@@ -4335,8 +4336,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
@@ -4884,9 +4886,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)
{
@@ -4950,6 +4953,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);
}
@@ -4975,10 +4980,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
@@ -5229,9 +5235,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)