[pango/wip/matthiasc/font-variations] Push the variation settings into the fontconfig pattern



commit 8ab41e5d5b615c7529f9f2a50b1ff18efe840fab
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Sep 12 12:19:15 2017 -0400

    Push the variation settings into the fontconfig pattern
    
    This is an easy way to ensure that we don't mix up different
    variants when caching and lets us pass the variation settings
    into cairo too.

 pango/pangofc-fontmap.c |    5 ++++-
 pango/pangofc-fontmap.h |   11 +++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index da22463..b7d4a53 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -383,7 +383,7 @@ pango_fc_fontset_key_init (PangoFcFontsetKey          *key,
   key->resolution = pango_fc_font_map_get_resolution (fcfontmap, context);
   key->language = language;
   key->desc = pango_font_description_copy_static (desc);
-  pango_font_description_unset_fields (key->desc, PANGO_FONT_MASK_SIZE);
+  pango_font_description_unset_fields (key->desc, PANGO_FONT_MASK_SIZE | PANGO_FONT_MASK_VARIATIONS);
 
   if (context && PANGO_FC_FONT_MAP_GET_CLASS (fcfontmap)->context_key_get)
     key->context_key = (gpointer)PANGO_FC_FONT_MAP_GET_CLASS (fcfontmap)->context_key_get (fcfontmap, 
context);
@@ -1472,6 +1472,7 @@ pango_fc_make_pattern (const  PangoFontDescription *description,
 #ifdef FC_WIDTH
   int width;
 #endif
+  const char *variations;
 
   prgname = g_get_prgname ();
   slant = pango_fc_convert_slant_to_fc (pango_font_description_get_style (description));
@@ -1482,6 +1483,7 @@ pango_fc_make_pattern (const  PangoFontDescription *description,
 
   gravity = pango_font_description_get_gravity (description);
   vertical = PANGO_GRAVITY_IS_VERTICAL (gravity) ? FcTrue : FcFalse;
+  variations = pango_font_description_get_variations (description);
 
   /* The reason for passing in FC_SIZE as well as FC_PIXEL_SIZE is
    * to work around a bug in libgnomeprint where it doesn't look
@@ -1504,6 +1506,7 @@ pango_fc_make_pattern (const  PangoFontDescription *description,
                            FC_DPI, FcTypeDouble, dpi,
                            FC_SIZE,  FcTypeDouble,  pixel_size * (72. / 1024. / dpi),
                            FC_PIXEL_SIZE,  FcTypeDouble,  pixel_size / 1024.,
+                            PANGO_FC_FONT_VARIATIONS, FcTypeString, variations,
                            NULL);
 
   if (pango_font_description_get_family (description))
diff --git a/pango/pangofc-fontmap.h b/pango/pangofc-fontmap.h
index 24e303a..0654d1f 100644
--- a/pango/pangofc-fontmap.h
+++ b/pango/pangofc-fontmap.h
@@ -313,6 +313,17 @@ PangoFontDescription *pango_fc_font_description_from_pattern (FcPattern *pattern
  */
 #define PANGO_FC_FONT_FEATURES "fontfeatures"
 
+/**
+ * PANGO_FC_FONT_VARIATIONS:
+ *
+ * String representing a fontconfig property name that Pango reads from font
+ * patterns to populate list of OpenType font variations to be used for a font.
+ *
+ * The property will have a number of string elements, each of which is the
+ * OpenType axis setting of the form AXIS=VALUE.
+ */
+#define PANGO_FC_FONT_VARIATIONS "fontvariations"
+
 G_END_DECLS
 
 #endif /* __PANGO_FC_FONT_MAP_H__ */


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