[pango/hb-metrics-fallback] Use newer harfbuzz api




commit 5d4ccae966eef90a48d6e838a475bcf0c9c6122f
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 15 17:49:58 2022 -0600

    Use newer harfbuzz api
    
    Use pango_ot_metrics_get_position_with_fallback,
    where appropriate.

 pango/itemize.c      | 36 +++++++++++++++---------------------
 pango/pango-layout.c | 13 ++++---------
 pango/pangofc-font.c | 28 ++++++++--------------------
 3 files changed, 27 insertions(+), 50 deletions(-)
---
diff --git a/pango/itemize.c b/pango/itemize.c
index 01399b7e..713af97f 100644
--- a/pango/itemize.c
+++ b/pango/itemize.c
@@ -1076,11 +1076,11 @@ collect_font_scale (PangoContext  *context,
                 case PANGO_FONT_SCALE_NONE:
                   break;
                 case PANGO_FONT_SCALE_SUPERSCRIPT:
-                  if (prev &&
-                      hb_ot_metrics_get_position (pango_font_get_hb_font (prev->analysis.font),
-                                                  HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_SIZE,
-                                                  &y_size))
+                  if (prev)
                     {
+                      hb_ot_metrics_get_position_with_fallback (pango_font_get_hb_font (prev->analysis.font),
+                                                                HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_SIZE,
+                                                                &y_size);
                       hb_font_get_scale (pango_font_get_hb_font (prev->analysis.font), NULL, &y_scale);
                       entry->scale = y_size / (double) y_scale;
                     }
@@ -1090,11 +1090,11 @@ collect_font_scale (PangoContext  *context,
                     }
                   break;
                 case PANGO_FONT_SCALE_SUBSCRIPT:
-                  if (prev &&
-                      hb_ot_metrics_get_position (pango_font_get_hb_font (prev->analysis.font),
-                                                  HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_SIZE,
-                                                  &y_size))
+                  if (prev)
                     {
+                      hb_ot_metrics_get_position_with_fallback (pango_font_get_hb_font (prev->analysis.font),
+                                                                HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_SIZE,
+                                                                &y_size);
                       hb_font_get_scale (pango_font_get_hb_font (prev->analysis.font), NULL, &y_scale);
                       entry->scale = y_size / (double) y_scale;
                     }
@@ -1104,19 +1104,13 @@ collect_font_scale (PangoContext  *context,
                     }
                   break;
                 case PANGO_FONT_SCALE_SMALL_CAPS:
-                  if (hb_ot_metrics_get_position (pango_font_get_hb_font (item->analysis.font),
-                                                  HB_OT_METRICS_TAG_CAP_HEIGHT,
-                                                  &cap_height) &&
-                      hb_ot_metrics_get_position (pango_font_get_hb_font (item->analysis.font),
-                                                  HB_OT_METRICS_TAG_X_HEIGHT,
-                                                  &x_height))
-                    {
-                      entry->scale = x_height / (double) cap_height;
-                    }
-                  else
-                    {
-                      entry->scale = 0.8;
-                    }
+                  hb_ot_metrics_get_position_with_fallback (pango_font_get_hb_font (item->analysis.font),
+                                                            HB_OT_METRICS_TAG_CAP_HEIGHT,
+                                                            &cap_height);
+                  hb_ot_metrics_get_position_with_fallback (pango_font_get_hb_font (item->analysis.font),
+                                                            HB_OT_METRICS_TAG_X_HEIGHT,
+                                                            &x_height);
+                  entry->scale = x_height / (double) cap_height;
                   break;
                 default:
                   g_assert_not_reached ();
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 9167883c..062be57a 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -6627,17 +6627,12 @@ collect_baseline_shift (ParaBreakState *state,
                   if (prev)
                     {
                       hb_font_t *hb_font = pango_font_get_hb_font (prev->analysis.font);
-                      hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_OFFSET, 
&superscript_y_offset);
-                      hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_OFFSET, 
&superscript_x_offset);
-                      hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_OFFSET, 
&subscript_y_offset);
-                      hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_SUBSCRIPT_EM_X_OFFSET, 
&subscript_x_offset);
+                      hb_ot_metrics_get_position_with_fallback (hb_font, 
HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_OFFSET, &superscript_y_offset);
+                      hb_ot_metrics_get_position_with_fallback (hb_font, 
HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_OFFSET, &superscript_x_offset);
+                      hb_ot_metrics_get_position_with_fallback (hb_font, 
HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_OFFSET, &subscript_y_offset);
+                      hb_ot_metrics_get_position_with_fallback (hb_font, 
HB_OT_METRICS_TAG_SUBSCRIPT_EM_X_OFFSET, &subscript_x_offset);
                     }
 
-                  if (superscript_y_offset == 0)
-                    superscript_y_offset = 5000;
-                  if (subscript_y_offset == 0)
-                    subscript_y_offset = 5000;
-
                   switch (value)
                     {
                     case PANGO_BASELINE_SHIFT_NONE:
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 9d555a37..6a26691a 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -379,29 +379,17 @@ get_face_metrics (PangoFcFont      *fcfont,
       metrics->height = extents.ascender - extents.descender + extents.line_gap;
     }
 
-  if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_UNDERLINE_SIZE, &position) &&
-      position != 0)
-    metrics->underline_thickness = position;
-  else
-    metrics->underline_thickness = PANGO_SCALE;
+  hb_ot_metrics_get_position_with_fallback (hb_font, HB_OT_METRICS_TAG_UNDERLINE_SIZE, &position);
+  metrics->underline_thickness = position;
 
-  if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_UNDERLINE_OFFSET, &position) &&
-      position != 0)
-    metrics->underline_position = position;
-  else
-    metrics->underline_position = - PANGO_SCALE;
+  hb_ot_metrics_get_position_with_fallback (hb_font, HB_OT_METRICS_TAG_UNDERLINE_OFFSET, &position);
+  metrics->underline_position = position;
 
-  if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_SIZE, &position) &&
-      position != 0)
-    metrics->strikethrough_thickness = position;
-  else
-    metrics->strikethrough_thickness = PANGO_SCALE;
+  hb_ot_metrics_get_position_with_fallback (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_SIZE, &position);
+  metrics->strikethrough_thickness = position;
 
-  if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, &position) &&
-      position != 0)
-    metrics->strikethrough_position = position;
-  else
-    metrics->strikethrough_position = metrics->ascent / 2;
+  hb_ot_metrics_get_position_with_fallback (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, &position);
+  metrics->strikethrough_position = position;
 }
 
 PangoFontMetrics *


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