mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
Avoid empty nodes another way
Make gsk_text_node_new return NULL if the extents are empty.
This commit is contained in:
parent
ccc587cca7
commit
59b1206468
@ -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,
|
||||
|
@ -119,25 +119,22 @@ gsk_pango_renderer_show_text_glyphs (PangoRenderer *renderer,
|
||||
GdkRGBA color;
|
||||
PangoRectangle ink_rect;
|
||||
|
||||
/* FIXME: vulkan fallbacks don't deal with empty nodes gracefully */
|
||||
pango_glyph_string_extents (glyphs, font, &ink_rect, NULL);
|
||||
pango_extents_to_pixels (&ink_rect, NULL);
|
||||
if (ink_rect.width == 0 || ink_rect.height == 0)
|
||||
return;
|
||||
|
||||
gtk_snapshot_get_offset (crenderer->snapshot, &x_offset, &y_offset);
|
||||
|
||||
gtk_snapshot_offset (crenderer->snapshot, base_x, base_y);
|
||||
|
||||
get_color (crenderer, PANGO_RENDER_PART_FOREGROUND, &color);
|
||||
|
||||
node = gsk_text_node_new (font, glyphs, &color, x_offset, y_offset, base_x, base_y);
|
||||
if (node == NULL)
|
||||
return;
|
||||
|
||||
if (crenderer->snapshot->record_names)
|
||||
{
|
||||
char name[64];
|
||||
snprintf (name, sizeof (name), "Glyphs<%d>", glyphs->num_glyphs);
|
||||
gsk_render_node_set_name (node, name);
|
||||
}
|
||||
|
||||
gtk_snapshot_offset (crenderer->snapshot, base_x, base_y);
|
||||
|
||||
gtk_snapshot_append_node (crenderer->snapshot, node);
|
||||
gsk_render_node_unref (node);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user