[pango/small-caps: 2/7] itemize: Handle PANGO_FONT_SCALE_SMALL_CAPS




commit 8aea98dc89562aaf7e273a38c2a7a33f8497dcd6
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Nov 6 23:43:07 2021 -0400

    itemize: Handle PANGO_FONT_SCALE_SMALL_CAPS
    
    This is not used by anything yet.

 pango/itemize.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/pango/itemize.c b/pango/itemize.c
index bd339633..f0d2a7da 100644
--- a/pango/itemize.c
+++ b/pango/itemize.c
@@ -1024,6 +1024,8 @@ itemize_state_finish (ItemizeState *state)
 /* }}} */
 /* {{{ Post-processing */
 
+ /* {{{ Handling font scale */
+
 typedef struct {
   PangoAttribute *attr;
   double scale;
@@ -1051,6 +1053,8 @@ collect_font_scale (PangoContext  *context,
               hb_font_t *hb_font;
               int y_scale;
               hb_position_t y_size;
+              hb_position_t cap_height;
+              hb_position_t x_height;
 
               entry = g_new (ScaleItem, 1);
               entry->attr = attr;
@@ -1076,6 +1080,7 @@ collect_font_scale (PangoContext  *context,
                     entry->scale = y_size / (double) y_scale;
                   else
                     entry->scale = 1 / 1.2;
+                  g_print ("collect scale: %f\n", entry->scale);
                   break;
                 case PANGO_FONT_SCALE_SUBSCRIPT:
                   if (hb_font &&
@@ -1086,6 +1091,18 @@ collect_font_scale (PangoContext  *context,
                   else
                     entry->scale = 1 / 1.2;
                   break;
+                case PANGO_FONT_SCALE_SMALL_CAPS:
+                  if (hb_font &&
+                      hb_ot_metrics_get_position (hb_font,
+                                                  HB_OT_METRICS_TAG_CAP_HEIGHT,
+                                                  &cap_height) &&
+                      hb_ot_metrics_get_position (hb_font,
+                                                  HB_OT_METRICS_TAG_X_HEIGHT,
+                                                  &x_height))
+                     entry->scale = x_height / (double) cap_height;
+                  else
+                     entry->scale = 0.8;
+                  break;
                 default:
                   g_assert_not_reached ();
                 }
@@ -1167,6 +1184,8 @@ apply_font_scale (PangoContext *context,
     }
 }
 
+/* }}} */
+
 static GList *
 post_process_items (PangoContext *context,
                     GList        *items)


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