summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-05 20:48:40 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-11-05 20:48:40 -0400
commit64b7b2c8d91577b56282bc65551090bd005f4ca1 (patch)
tree9710ebcb733aa2edfdb59a598b8a2e5cee72f9d2
parent0fb9d7159e4b18667c4a2351b9aaa62409b81f95 (diff)
downloadpango-64b7b2c8d91577b56282bc65551090bd005f4ca1.tar.gz
fc: Implement PANGO_VARIANT_SMALL_CAPS
Arrange for PANGO_VARIANT_SMALL_CAPS to be translated into the OpenType feature smcp=1 and back. This makes small caps survive a roundtrip from font description to font and back.
-rw-r--r--pango/pangofc-fontmap.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 1d67485a..113142fd 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -1854,6 +1854,7 @@ pango_fc_make_pattern (const PangoFontDescription *description,
int slant;
double weight;
PangoGravity gravity;
+ PangoVariant variant;
char **families;
int i;
int width;
@@ -1864,6 +1865,7 @@ pango_fc_make_pattern (const PangoFontDescription *description,
width = pango_fc_convert_width_to_fc (pango_font_description_get_stretch (description));
gravity = pango_font_description_get_gravity (description);
+ variant = pango_font_description_get_variant (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
@@ -1913,6 +1915,9 @@ pango_fc_make_pattern (const PangoFontDescription *description,
if (prgname)
FcPatternAddString (pattern, PANGO_FC_PRGNAME, (FcChar8*) prgname);
+ if (variant == PANGO_VARIANT_SMALL_CAPS)
+ FcPatternAddString (pattern, PANGO_FC_FONT_FEATURES, (FcChar8*) "smcp=1");
+
return pattern;
}
@@ -2787,6 +2792,22 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz
pango_font_description_set_variant (desc, PANGO_VARIANT_NORMAL);
+ for (int i = 0; i < 32; i++)
+ {
+ const char *s;
+
+ if (FcPatternGetString (pattern, PANGO_FC_FONT_FEATURES, i, (FcChar8 **)&s) == FcResultMatch)
+ {
+ if (strcmp (s, "smcp=1") == 0)
+ {
+ pango_font_description_set_variant (desc, PANGO_VARIANT_SMALL_CAPS);
+ break;
+ }
+ }
+ else
+ break;
+ }
+
if (include_size && FcPatternGetDouble (pattern, FC_SIZE, 0, &size) == FcResultMatch)
{
FcMatrix *fc_matrix;