[pango/small-caps: 1/6] itemize: Handle PANGO_FONT_SCALE_SMALL_CAPS




commit 70f3f4dd361bfa9afe87769d95a47926360cf41f
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 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/pango/itemize.c b/pango/itemize.c
index bd339633..539cdc66 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;
@@ -1086,6 +1090,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 +1183,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]