diff options
author | Matthias Clasen <mclasen@redhat.com> | 2018-11-19 21:25:58 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2018-11-19 21:25:58 +0000 |
commit | 1305d8905102d327eecb38f3a4d4c55dd4ed9909 (patch) | |
tree | daa1ceaf6cf95c1ad0fe8e9ac67ee77849633068 | |
parent | 4788a3410da86640bd6cf65cebee4ae19bd1adac (diff) | |
parent | 73d2c5abd43586291f1c896447123df5c73ac291 (diff) | |
download | pango-1305d8905102d327eecb38f3a4d4c55dd4ed9909.tar.gz |
Merge branch 'variable-face' into 'master'
Variable face
See merge request GNOME/pango!25
-rw-r--r-- | pango/fonts.c | 22 | ||||
-rw-r--r-- | pango/pango-font.h | 4 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 35 | ||||
-rw-r--r-- | utils/pango-list.c | 18 |
4 files changed, 76 insertions, 3 deletions
diff --git a/pango/fonts.c b/pango/fonts.c index d9a07c0b..63e7c7b9 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -2147,6 +2147,28 @@ pango_font_family_is_monospace (PangoFontFamily *family) return FALSE; } +/** + * pango_font_family_is_variable: + * @family: a #PangoFontFamily + * + * A variable font is a font which has axes that can be modified to + * produce different faces. + * + * Return value: %TRUE if the family is variable + * + * Since: 1.44 + **/ +gboolean +pango_font_family_is_variable (PangoFontFamily *family) +{ + g_return_val_if_fail (PANGO_IS_FONT_FAMILY (family), FALSE); + + if (PANGO_FONT_FAMILY_GET_CLASS (family)->is_variable) + return PANGO_FONT_FAMILY_GET_CLASS (family)->is_variable (family); + else + return FALSE; +} + /* * PangoFontFace */ diff --git a/pango/pango-font.h b/pango/pango-font.h index 4af31a95..1b85c386 100644 --- a/pango/pango-font.h +++ b/pango/pango-font.h @@ -409,6 +409,8 @@ PANGO_AVAILABLE_IN_ALL const char *pango_font_family_get_name (PangoFontFamily *family) G_GNUC_PURE; PANGO_AVAILABLE_IN_1_4 gboolean pango_font_family_is_monospace (PangoFontFamily *family) G_GNUC_PURE; +PANGO_AVAILABLE_IN_1_44 +gboolean pango_font_family_is_variable (PangoFontFamily *family) G_GNUC_PURE; #ifdef PANGO_ENABLE_BACKEND @@ -442,13 +444,13 @@ struct _PangoFontFamilyClass int *n_faces); const char * (*get_name) (PangoFontFamily *family); gboolean (*is_monospace) (PangoFontFamily *family); + gboolean (*is_variable) (PangoFontFamily *family); /*< private >*/ /* Padding for future expansion */ void (*_pango_reserved2) (void); void (*_pango_reserved3) (void); - void (*_pango_reserved4) (void); }; #endif /* PANGO_ENABLE_BACKEND */ diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 8b41018b..7d75f6f9 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -189,6 +189,7 @@ struct _PangoFcFamily int n_faces; /* -1 == uninitialized */ int spacing; /* FC_SPACING */ + gboolean variable; }; struct _PangoFcFindFuncInfo @@ -1274,6 +1275,7 @@ create_family (PangoFcFontMap *fcfontmap, family->fontmap = fcfontmap; family->family_name = g_strdup (family_name); family->spacing = spacing; + family->variable = FALSE; family->patterns = FcFontSetCreate (); return family; @@ -1319,7 +1321,11 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap, if (priv->n_families < 0) { - FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_SPACING, FC_STYLE, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL); + FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_SPACING, FC_STYLE, FC_WEIGHT, FC_WIDTH, FC_SLANT, +#ifdef FC_VARIABLE + FC_VARIABLE, +#endif + NULL); FcPattern *pat = FcPatternCreate (); GHashTable *temp_family_hash; @@ -1337,6 +1343,7 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap, char *s; FcResult res; int spacing; + int variable; PangoFcFamily *temp_family; res = FcPatternGetString (fontset->fonts[i], FC_FAMILY, 0, (FcChar8 **)(void*)&s); @@ -1357,6 +1364,13 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap, if (temp_family) { + variable = FALSE; +#ifdef FC_VARIABLE + res = FcPatternGetBool (fontset->fonts[i], FC_VARIABLE, 0, &variable); +#endif + if (variable) + temp_family->variable = TRUE; + FcPatternReference (fontset->fonts[i]); FcFontSetAdd (temp_family->patterns, fontset->fonts[i]); } @@ -2542,6 +2556,16 @@ pango_fc_family_list_faces (PangoFontFamily *family, if (FcPatternGetInteger(fontset->fonts[i], FC_SLANT, 0, &slant) != FcResultMatch) slant = FC_SLANT_ROMAN; +#ifdef FC_VARIABLE + { + gboolean variable; + if (FcPatternGetBool(fontset->fonts[i], FC_VARIABLE, 0, &variable) != FcResultMatch) + variable = FALSE; + if (variable) /* skip the variable face */ + continue; + } +#endif + if (FcPatternGetString (fontset->fonts[i], FC_STYLE, 0, (FcChar8 **)(void*)&font_style) != FcResultMatch) font_style = NULL; @@ -2620,6 +2644,14 @@ pango_fc_family_is_monospace (PangoFontFamily *family) fcfamily->spacing == FC_CHARCELL; } +static gboolean +pango_fc_family_is_variable (PangoFontFamily *family) +{ + PangoFcFamily *fcfamily = PANGO_FC_FAMILY (family); + + return fcfamily->variable; +} + static void pango_fc_family_finalize (GObject *object) { @@ -2649,6 +2681,7 @@ pango_fc_family_class_init (PangoFcFamilyClass *class) class->list_faces = pango_fc_family_list_faces; class->get_name = pango_fc_family_get_name; class->is_monospace = pango_fc_family_is_monospace; + class->is_variable = pango_fc_family_is_variable; } static void diff --git a/utils/pango-list.c b/utils/pango-list.c index cb92767e..6f80b521 100644 --- a/utils/pango-list.c +++ b/utils/pango-list.c @@ -46,9 +46,25 @@ main (int argc, { PangoFontFace **faces; int n_faces; + const char *kind; const char *family_name = pango_font_family_get_name (families[i]); - g_print ("%s\n", family_name); + if (pango_font_family_is_monospace (families[i])) + { + if (pango_font_family_is_variable (families[i])) + kind = "(monospace, variable)"; + else + kind = "(monospace)"; + } + else + { + if (pango_font_family_is_variable (families[i])) + kind = "(variable)"; + else + kind = ""; + } + + g_print ("%s %s\n", family_name, kind); pango_font_family_list_faces (families[i], &faces, &n_faces); for (j = 0; j < n_faces; j++) |