[pango/pango2: 174/178] Avoid overflow when calculating caret slope




commit 290d3eded81dfa31b7e2c4c40f45a5be646943fb
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 bff853bb2..0acdd168f 100644
--- a/pango/pango-line.c
+++ b/pango/pango-line.c
@@ -1576,7 +1576,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]