summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-01-02 18:50:45 -0500
committerMatthias Clasen <mclasen@redhat.com>2022-01-03 11:13:29 -0500
commitef3551e2bc7861c7d9539d41d98988fd20f34839 (patch)
treeb0c400e0410d8dcc67ed4c94af2ecd7f1b330aeb
parente5cefff034652310509b76e109b898c10bac9d58 (diff)
downloadpango-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.
-rw-r--r--pango/pango-layout.c5
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)
{