diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-09-18 10:01:05 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-09-18 14:26:57 -0400 |
commit | 8a7f2ca0bef63a5b637fbf3ca1fae1df48464f02 (patch) | |
tree | f1d386029ed9d5813f77db927ccc9398faadac77 /gtk | |
parent | b99cb70299e9a5148556540dc584ea5535241a6e (diff) | |
download | gtk+-8a7f2ca0bef63a5b637fbf3ca1fae1df48464f02.tar.gz |
css: Implement font-variant-alternatives
This is only a partial implementation, since we don't support
@font-feature-values. The only supported value is historical-forms,
for now.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcssstyle.c | 10 | ||||
-rw-r--r-- | gtk/gtkcssstylepropertyimpl.c | 21 | ||||
-rw-r--r-- | gtk/gtkcsstypesprivate.h | 1 |
3 files changed, 32 insertions, 0 deletions
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index 33960349d8..1fbe5e6bba 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -230,6 +230,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style) GtkCssValue *position; GtkCssValue *caps; GtkCssValue *numeric; + GtkCssValue *alternatives; GString *s; int i; @@ -369,6 +370,15 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style) g_string_append (s, "zero 1"); } + alternatives = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATIVES); + for (i = 0; i < _gtk_css_array_value_get_n_values (alternatives); i++) + { + GtkCssValue *value = _gtk_css_array_value_get_nth (alternatives, i); + if (s->len > 0) g_string_append (s, ", "); + if (strcmp (_gtk_css_ident_value_get (value), "historical-forms") == 0) + g_string_append (s, "hist 1"); + } + attrs = add_pango_attr (attrs, pango_attr_font_features_new (s->str)); g_string_free (s, TRUE); diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c index a0311b37b0..25c66f9b77 100644 --- a/gtk/gtkcssstylepropertyimpl.c +++ b/gtk/gtkcssstylepropertyimpl.c @@ -737,6 +737,19 @@ parse_font_variant_numeric (GtkCssStyleProperty *property, } static GtkCssValue * +parse_font_variant_alternatives (GtkCssStyleProperty *property, + GtkCssParser *parser) +{ + GtkCssValue *value = NULL; + + value = _gtk_css_ident_value_try (parser, "normal", "historical-forms", NULL); + if (value == NULL) + _gtk_css_parser_error (parser, "Not a valid value"); + + return value; +} + +static GtkCssValue * box_shadow_value_parse (GtkCssStyleProperty *property, GtkCssParser *parser) { @@ -1261,6 +1274,14 @@ _gtk_css_style_property_init_properties (void) parse_font_variant_numeric, NULL, _gtk_css_array_value_new (_gtk_css_ident_value_new ("normal"))); + gtk_css_style_property_register ("font-variant-alternatives", + GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATIVES, + G_TYPE_NONE, + 0, + GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS, + parse_font_variant_alternatives, + NULL, + _gtk_css_array_value_new (_gtk_css_ident_value_new ("normal"))); gtk_css_style_property_register ("text-shadow", GTK_CSS_PROPERTY_TEXT_SHADOW, G_TYPE_NONE, diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h index 5ca7b7aa3a..6518a24291 100644 --- a/gtk/gtkcsstypesprivate.h +++ b/gtk/gtkcsstypesprivate.h @@ -168,6 +168,7 @@ enum { /*< skip >*/ GTK_CSS_PROPERTY_FONT_VARIANT_POSITION, GTK_CSS_PROPERTY_FONT_VARIANT_CAPS, GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC, + GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATIVES, GTK_CSS_PROPERTY_TEXT_SHADOW, GTK_CSS_PROPERTY_BOX_SHADOW, GTK_CSS_PROPERTY_MARGIN_TOP, |