[pango/kill-ft-face: 1/2] Use harfbuzz for all font metrics



commit eb46d47803584f5d141161078fb9fb480b3a2ca3
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jul 3 16:00:48 2019 +0000

    Use harfbuzz for all font metrics
    
    This fills in the gap left by 092d865269c263b0969.
    Note that the harfbuzz api has not landed yet.

 pango/pangofc-font.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 12cc4f50..bc351efe 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -47,9 +47,6 @@
 #include "pango-impl-utils.h"
 
 #include <harfbuzz/hb-ot.h>
-#include <fontconfig/fcfreetype.h>
-
-#include FT_TRUETYPE_TABLES_H
 
 enum {
   PROP_0,
@@ -404,11 +401,27 @@ get_face_metrics (PangoFcFont      *fcfont,
       metrics->ascent = extents.ascender;
     }
 
+  metrics->underline_thickness = PANGO_SCALE;
+  metrics->underline_position = - PANGO_SCALE;
+  metrics->strikethrough_thickness = PANGO_SCALE;
+  metrics->strikethrough_position = metrics->ascent / 2;
+
+  /* FIXME: use the right hb version */
+#if HB_VERSION_ATLEAST (2,5,2)
+  hb_position_t position;
+
+  if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_UNDERLINE_SIZE, &position))
+    metrics->underline_thickness = position;
+
+  if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_UNDERLINE_OFFSET, &position))
+    metrics->underline_position = position;
+
+  if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_STRIKEOUT_SIZE, &position))
+    metrics->strikethrough_thickness = position;
 
-  metrics->underline_thickness = 0;
-  metrics->underline_position = 0;
-  metrics->strikethrough_thickness = 0;
-  metrics->strikethrough_position = 0;
+  if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_STRIKEOUT_OFFSET, &position))
+    metrics->strikethrough_position = position;
+#endif
 }
 
 PangoFontMetrics *


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