[pango/simple-fontmap: 1/2] pango-view: Add italic Cantarell variant




commit bdec4557a4f67a939582386c41e5a9d71f8cc028
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 24 01:37:51 2021 -0700

    pango-view: Add italic Cantarell variant
    
    This is a hack to test the synthetic oblique support.

 utils/viewer-pangocairo.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/utils/viewer-pangocairo.c b/utils/viewer-pangocairo.c
index 1b3d2f80..ef90c6aa 100644
--- a/utils/viewer-pangocairo.c
+++ b/utils/viewer-pangocairo.c
@@ -25,6 +25,8 @@
 #include "viewer-cairo.h"
 
 #include <pango/pangocairo.h>
+#include <pango/pango-hbface.h>
+#include <pango/pango-simplefontmap.h>
 
 static int opt_annotate = 0;
 static const char **opt_font_file = NULL;
@@ -51,10 +53,26 @@ pangocairo_view_create (const PangoViewer *klass G_GNUC_UNUSED)
 
   if (opt_font_file != NULL)
     {
+      PangoFontFamily *fam;
+
       instance->fontmap = PANGO_FONT_MAP (pango_simple_font_map_new ());
       pango_simple_font_map_set_resolution (PANGO_SIMPLE_FONT_MAP (instance->fontmap), opt_dpi);
       for (int i = 0; opt_font_file[i]; i++)
         pango_simple_font_map_add_file (PANGO_SIMPLE_FONT_MAP (instance->fontmap), opt_font_file[i], 0);
+
+      fam = pango_font_map_get_family (instance->fontmap, "Cantarell");
+      if (fam)
+        {
+          PangoFontFace *face = pango_font_family_get_face (fam, "Regular");
+          PangoHbFace *slanted;
+          PangoMatrix matrix = { 1., -0.2,
+                                 0., 1.,
+                                 0., 0. };
+
+          slanted = pango_hb_face_new_transformed (PANGO_HB_FACE (face), "Italic", &matrix);
+          pango_simple_font_map_add_face (PANGO_SIMPLE_FONT_MAP (instance->fontmap), slanted);
+          g_object_unref (slanted);
+        }
     }
   else
     {


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