From 60c45dac5640eb74839ae4a8c535943c82bbf4af Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 8 Nov 2021 08:08:19 -0500 Subject: [PATCH] css: Change the way case variants are handled Instead of translating font-variant-caps directly to OpenType features, translate them to a PangoVariant, now that that enumeration reflects all the css values. This allows pango to emulate Small Caps for fonts that don't support the OpenType feature. --- gtk/gtkcssstyle.c | 51 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index 31b5d3e2c9..f03d9b4f1a 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -513,31 +513,6 @@ gtk_css_style_compute_font_features (GtkCssStyle *style) break; } - switch (_gtk_css_font_variant_caps_value_get (style->font_variant->font_variant_caps)) - { - case GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS: - append_separated (&s, "smcp 1"); - break; - case GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS: - append_separated (&s, "c2sc 1, smcp 1"); - break; - case GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS: - append_separated (&s, "pcap 1"); - break; - case GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS: - append_separated (&s, "c2pc 1, pcap 1"); - break; - case GTK_CSS_FONT_VARIANT_CAPS_UNICASE: - append_separated (&s, "unic 1"); - break; - case GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS: - append_separated (&s, "titl 1"); - break; - case GTK_CSS_FONT_VARIANT_CAPS_NORMAL: - default: - break; - } - numeric = _gtk_css_font_variant_numeric_value_get (style->font_variant->font_variant_numeric); if (numeric == GTK_CSS_FONT_VARIANT_NUMERIC_NORMAL) { @@ -675,6 +650,32 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style) } } + /* casing variants */ + switch (_gtk_css_font_variant_caps_value_get (style->font_variant->font_variant_caps)) + { + case GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS: + attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_SMALL_CAPS)); + break; + case GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS: + attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_ALL_SMALL_CAPS)); + break; + case GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS: + attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_PETITE_CAPS)); + break; + case GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS: + attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_ALL_PETITE_CAPS)); + break; + case GTK_CSS_FONT_VARIANT_CAPS_UNICASE: + attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_UNICASE)); + break; + case GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS: + attrs = add_pango_attr (attrs, pango_attr_variant_new (PANGO_VARIANT_TITLE_CAPS)); + break; + case GTK_CSS_FONT_VARIANT_CAPS_NORMAL: + default: + break; + } + /* OpenType features */ { char *font_features = gtk_css_style_compute_font_features (style);