[pango/small-caps: 1/2] fc: Implement PANGO_VARIANT_SMALL_CAPS
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/small-caps: 1/2] fc: Implement PANGO_VARIANT_SMALL_CAPS
- Date: Sat, 6 Nov 2021 01:16:26 +0000 (UTC)
commit 64b7b2c8d91577b56282bc65551090bd005f4ca1
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Nov 5 20:48:40 2021 -0400
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.
pango/pangofc-fontmap.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
---
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]