[pango/matthiasc/for-main: 2/2] pango-view: Don't omit the last caret position
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/matthiasc/for-main: 2/2] pango-view: Don't omit the last caret position
- Date: Thu, 26 Aug 2021 03:29:22 +0000 (UTC)
commit cba1d740a50318f462a6b802ce7172b9711929d9
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Aug 25 23:27:41 2021 -0400
pango-view: Don't omit the last caret position
We want to draw n+1 dots, the last one with trailing == 1.
utils/viewer-pangocairo.c | 24 ++++++++++++++++--------
1 file 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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]