diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-08-25 23:27:41 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-08-25 23:29:08 -0400 |
commit | cba1d740a50318f462a6b802ce7172b9711929d9 (patch) | |
tree | 812775e8ab092459ad8b03245379de78d0d2106f /utils | |
parent | 1b05aadad8ac03e275120fa6112bf9c784134c69 (diff) | |
download | pango-cba1d740a50318f462a6b802ce7172b9711929d9.tar.gz |
pango-view: Don't omit the last caret position
We want to draw n+1 dots, the last one with trailing == 1.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/viewer-pangocairo.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c index 1c0494de..af4925e3 100644 --- a/utils/viewer-pangocairo.c +++ b/utils/viewer-pangocairo.c @@ -418,7 +418,9 @@ render_callback (PangoLayout *layout, { PangoRectangle rect; PangoLayoutRun *run; - const char *text, *start, *end, *p; + const char *text, *start, *p; + int x, y; + gboolean trailing; pango_layout_iter_get_run_extents (iter, NULL, &rect); run = pango_layout_iter_get_run_readonly (iter); @@ -427,25 +429,31 @@ render_callback (PangoLayout *layout, continue; text = pango_layout_get_text (layout); - start =text + run->item->offset; - end = start + run->item->length; - for (p = start; p < end; p = g_utf8_next_char (p)) - { - int x, y; + start = text + run->item->offset; + + y = pango_layout_iter_get_baseline (iter); + trailing = FALSE; + p = start; + for (int i = 0; i <= run->item->num_chars; i++) + { pango_glyph_string_index_to_x (run->glyphs, text + run->item->offset, run->item->length, &run->item->analysis, p - start, - FALSE, + trailing, &x); x += rect.x; - y = pango_layout_iter_get_baseline (iter); cairo_arc (cr, x / PANGO_SCALE, y / PANGO_SCALE, 3.0, 0, 2*G_PI); cairo_close_path (cr); cairo_fill (cr); + + if (i < run->item->num_chars) + p = g_utf8_next_char (p); + else + trailing = TRUE; } } while (pango_layout_iter_next_run (iter)); |