[pango/matthiasc/for-main: 15/15] pango-view: Show caret slopes as well
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/matthiasc/for-main: 15/15] pango-view: Show caret slopes as well
- Date: Fri, 27 Aug 2021 21:16:10 +0000 (UTC)
commit 05f62eae063ec1cfe56cbfcc9e99b6dfa989ef90
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Aug 27 17:15:09 2021 -0400
pango-view: Show caret slopes as well
When annotating caret positions, render the diagonal
of the caret position rectangle as well.
utils/viewer-pangocairo.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
---
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c
index 1bc9f025..b010c3f3 100644
--- a/utils/viewer-pangocairo.c
+++ b/utils/viewer-pangocairo.c
@@ -534,6 +534,25 @@ render_callback (PangoLayout *layout,
while (pango_layout_iter_next_run (iter));
pango_layout_iter_free (iter);
+ const char *text = pango_layout_get_text (layout);
+ int length = g_utf8_strlen (text, -1);
+ for (int i = 0; i <= length; i++)
+ {
+ PangoRectangle rect;
+ pango_layout_get_caret_pos (layout, i, &rect, NULL);
+
+ cairo_move_to (cr,
+ (double)rect.x / PANGO_SCALE - lw / 2
+ + (double)rect.width / PANGO_SCALE + lw,
+ (double)rect.y / PANGO_SCALE - lw / 2);
+ cairo_line_to (cr,
+ (double)rect.x / PANGO_SCALE - lw / 2,
+ (double)rect.y / PANGO_SCALE - lw / 2
+ + (double)rect.height / PANGO_SCALE + lw);
+ cairo_stroke (cr);
+
+ }
+
cairo_restore (cr);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]