From 59b12064686a2ee183ca6b686bd088f471383b95 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 3 Sep 2017 19:35:02 -0400 Subject: Avoid empty nodes another way Make gsk_text_node_new return NULL if the extents are empty. --- gsk/gskrendernodeimpl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'gsk/gskrendernodeimpl.c') diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 0b0981efe4..48fecc36b6 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -4041,6 +4041,13 @@ gsk_text_node_new (PangoFont *font, GskTextNode *self; PangoRectangle ink_rect; + pango_glyph_string_extents (glyphs, font, &ink_rect, NULL); + pango_extents_to_pixels (&ink_rect, NULL); + + /* Don't create nodes with empty bounds */ + if (ink_rect.width == 0 || ink_rect.height == 0) + return NULL; + self = (GskTextNode *) gsk_render_node_new (&GSK_TEXT_NODE_CLASS, 0); self->font = g_object_ref (font); @@ -4053,8 +4060,6 @@ gsk_text_node_new (PangoFont *font, self->has_color = font_has_color_glyphs (font); - pango_glyph_string_extents (glyphs, font, &ink_rect, NULL); - pango_extents_to_pixels (&ink_rect, NULL); graphene_rect_init (&self->render_node.bounds, x_offset + base_x + ink_rect.x, -- cgit v1.2.1