[pango/pango2: 4/25] Avoid overflow when calculating caret slope




commit 1a50c62b6dac806eee7996f3e687744bc0dcf287
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 19 07:47:10 2022 -0700

    Avoid overflow when calculating caret slope
    
    This showed up as wrong slopes with font size > 60.

 pango/pango-line.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/pango/pango-line.c b/pango/pango-line.c
index 10661e904..7672a3e10 100644
--- a/pango/pango-line.c
+++ b/pango/pango-line.c
@@ -1574,7 +1574,8 @@ pango_line_get_caret_pos (PangoLine      *line,
         return;
 
       hb_font_get_scale (hb_font, &x_scale, &y_scale);
-      slope_inv = (caret_run * y_scale) / (double) (caret_rise * x_scale);
+
+      slope_inv = (caret_run / (double) caret_rise) * (y_scale / (double) x_scale);
 
       if (strong_pos)
         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]