[gtk/small-caps: 2/3] css: Change the way case variants are handled
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/small-caps: 2/3] css: Change the way case variants are handled
- Date: Mon, 8 Nov 2021 13:11:59 +0000 (UTC)
commit 26e445666337a9907d6eca55d66a2f44e5f4585e
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Nov 8 08:08:19 2021 -0500
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]