diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-01-23 12:07:49 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-01-23 23:44:54 -0500 |
commit | 3f05313ec3d3a98db666e347133528bbd62022f0 (patch) | |
tree | 4e9c417039281ebbe48d60a1a4c63c94e3ff6c90 /tests/rendernode-create-tests.c | |
parent | 9960be7eebd9e32900986b11ebef42c44b10fa94 (diff) | |
download | gtk+-pango-line-breaker.tar.gz |
Port to pango2 apipango-line-breaker
Diffstat (limited to 'tests/rendernode-create-tests.c')
-rw-r--r-- | tests/rendernode-create-tests.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/rendernode-create-tests.c b/tests/rendernode-create-tests.c index 2bd7a3876b..8b58fe9376 100644 --- a/tests/rendernode-create-tests.c +++ b/tests/rendernode-create-tests.c @@ -399,7 +399,8 @@ text (guint n) PangoLayoutIter *iter; PangoLayoutRun *run; GdkRGBA color; - int x, y, width, height; + PangoRectangle ext; + int x, y; pango_layout_set_text (layout, words[g_random_int_range (0, n_words)], -1); if (g_random_boolean ()) @@ -413,9 +414,11 @@ text (guint n) font = pango_context_load_font (context, desc); pango_layout_set_font_description (layout, desc); - pango_layout_get_pixel_size (layout, &width, &height); - x = width >= 1000 ? 0 : g_random_int_range (0, 1000 - width); - y = height >= 1000 ? 0 : g_random_int_range (0, 1000 - height); + pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext); + pango_extents_to_pixels (&ext, NULL); + + x = ext.width >= 1000 ? 0 : g_random_int_range (0, 1000 - ext.width); + y = ext.height >= 1000 ? 0 : g_random_int_range (0, 1000 - ext.height); hsv_to_rgb (&color, g_random_double (), g_random_double_range (0.5, 1.0), g_random_double_range (0.15, 0.75)); iter = pango_layout_get_iter (layout); @@ -424,9 +427,11 @@ text (guint n) run = pango_layout_iter_get_run (iter); if (run != NULL) { + PangoGlyphString *glyphs; GskRenderNode *node; - - node = gsk_text_node_new (font, run->glyphs, &color, &GRAPHENE_POINT_INIT (x, y)); + + glyphs = pango_layout_run_get_glyphs (run); + node = gsk_text_node_new (font, glyphs, &color, &GRAPHENE_POINT_INIT (x, y)); if (node) g_ptr_array_add (nodes, node); } |