diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-01-02 18:50:45 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-01-03 11:13:29 -0500 |
commit | ef3551e2bc7861c7d9539d41d98988fd20f34839 (patch) | |
tree | b0c400e0410d8dcc67ed4c94af2ecd7f1b330aeb /pango/pango-layout.c | |
parent | e5cefff034652310509b76e109b898c10bac9d58 (diff) | |
download | pango-ef3551e2bc7861c7d9539d41d98988fd20f34839.tar.gz |
layout: Make sloped carets work better
When the font matrix has uneven scales, we need
to factor that into the slope that we get from
the font metrics.
Tested with a condensed italic Cantarell.
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r-- | pango/pango-layout.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 24a1a88b..973d2a7b 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -88,6 +88,7 @@ #include "pango-layout-private.h" #include "pango-attributes-private.h" +#include "pango-font-private.h" typedef struct _ItemProperties ItemProperties; @@ -2716,6 +2717,7 @@ pango_layout_get_caret_pos (PangoLayout *layout, hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_HORIZONTAL_DESCENDER, &descender)) { double slope_inv; + int x_scale, y_scale; if (strong_pos) strong_pos->x += caret_offset; @@ -2726,7 +2728,8 @@ pango_layout_get_caret_pos (PangoLayout *layout, if (caret_rise == 0) return; - slope_inv = caret_run / (double) caret_rise; + hb_font_get_scale (hb_font, &x_scale, &y_scale); + slope_inv = (caret_run * y_scale) / (double) (caret_rise * x_scale); if (strong_pos) { |