summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pango/pango-context.c8
-rw-r--r--pango/pango-layout.c15
-rw-r--r--tests/testmisc.c21
3 files changed, 36 insertions, 8 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 90952add..d1e447f7 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -1413,10 +1413,10 @@ itemize_state_update_for_new_run (ItemizeState *state)
{
gboolean is_emoji = state->emoji_iter.is_emoji;
if (is_emoji && !state->emoji_font_desc)
- {
- state->emoji_font_desc = pango_font_description_copy_static (state->font_desc);
- pango_font_description_set_family_static (state->emoji_font_desc, "emoji");
- }
+ {
+ state->emoji_font_desc = pango_font_description_copy_static (state->font_desc);
+ pango_font_description_set_family_static (state->emoji_font_desc, "emoji");
+ }
state->current_fonts = pango_font_map_load_fontset (state->context->font_map,
state->context,
is_emoji ? state->emoji_font_desc : state->font_desc,
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 57ec7606..2fe6c9dc 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -4982,7 +4982,7 @@ pango_layout_run_get_extents_and_height (PangoLayoutRun *run,
gboolean has_underline;
gboolean has_overline;
- if (G_UNLIKELY (!run_ink && !run_logical))
+ if (G_UNLIKELY (!run_ink && !run_logical && !height))
return;
pango_layout_get_item_properties (run->item, &properties);
@@ -5107,7 +5107,7 @@ pango_layout_line_get_extents_and_height (PangoLayoutLine *line,
g_return_if_fail (LINE_IS_VALID (line));
- if (G_UNLIKELY (!ink_rect && !logical_rect))
+ if (G_UNLIKELY (!ink_rect && !logical_rect && !height))
return;
switch (private->cache_status)
@@ -5213,8 +5213,15 @@ pango_layout_line_get_extents_and_height (PangoLayoutLine *line,
tmp_list = tmp_list->next;
}
- if (logical_rect && !line->runs)
- pango_layout_line_get_empty_extents (line, logical_rect);
+ if (!line->runs)
+ {
+ PangoRectangle r, *rect;
+
+ rect = logical_rect ? logical_rect : &r;
+ pango_layout_line_get_empty_extents (line, rect);
+ if (height)
+ *height = rect->height;
+ }
if (caching)
{
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 1697b7cd..06b39a7a 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -101,6 +101,26 @@ test_language_emoji_crash (void)
g_assert (scripts == NULL || num > 0);
}
+static void
+test_line_height (void)
+{
+ PangoContext *context;
+ PangoLayout *layout;
+ PangoLayoutLine *line;
+ int height = 0;
+
+ context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+ layout = pango_layout_new (context);
+ pango_layout_set_text (layout, "one\ttwo", -1);
+ line = pango_layout_get_line_readonly (layout, 0);
+ pango_layout_line_get_height (line, &height);
+
+ g_assert_cmpint (height, >, 0);
+
+ g_object_unref (layout);
+ g_object_unref (context);
+}
+
int
main (int argc, char *argv[])
{
@@ -111,6 +131,7 @@ main (int argc, char *argv[])
g_test_add_func ("/layout/itemize-utf8", test_itemize_utf8);
g_test_add_func ("/layout/short-string-crash", test_short_string_crash);
g_test_add_func ("/language/emoji-crash", test_language_emoji_crash);
+ g_test_add_func ("/layout/line-height", test_line_height);
return g_test_run ();
}