[pango/line-breaking-fixes: 8/12] Simplify find_break_extra_width




commit fe8927f33cc980ba1c2effc4b1f2879c0f6cf465
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Nov 12 13:52:15 2021 -0500

    Simplify find_break_extra_width
    
    We can use the log_widths that we already have.

 pango/pango-layout.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 34787f0e..a8c0f757 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3737,23 +3737,6 @@ find_hyphen_width (PangoItem *item)
   return 0;
 }
 
-static int
-find_char_width (PangoItem *item,
-                 gunichar   wc)
-{
-  hb_font_t *hb_font;
-  hb_codepoint_t glyph;
-
-  if (!item->analysis.font)
-    return 0;
-
-  hb_font = pango_font_get_hb_font (item->analysis.font);
-  if (hb_font_get_nominal_glyph (hb_font, wc, &glyph))
-    return hb_font_get_glyph_h_advance (hb_font, glyph);
-
-  return 0;
-}
-
 static inline void
 ensure_hyphen_width (ParaBreakState *state)
 {
@@ -3775,14 +3758,7 @@ find_break_extra_width (PangoLayout    *layout,
       ensure_hyphen_width (state);
 
       if (layout->log_attrs[state->start_offset + pos].break_removes_preceding)
-        {
-          PangoItem *item = state->items->data;
-          gunichar wc;
-
-          wc = g_utf8_get_char (g_utf8_offset_to_pointer (layout->text, state->start_offset + pos - 1));
-
-          return state->hyphen_width - find_char_width (item, wc);
-        }
+        return state->hyphen_width - state->log_widths[state->log_widths_offset + pos - 1];
       else
         return state->hyphen_width;
     }


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