diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-09-18 07:34:46 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-09-18 14:26:57 -0400 |
commit | b99cb70299e9a5148556540dc584ea5535241a6e (patch) | |
tree | 138b145292f1ab42e8cd29b6eb9ee16490c121ef /gtk/gtkcssstylepropertyimpl.c | |
parent | 8525afc4081e88ba4e58c7a9f90f8721d2478590 (diff) | |
download | gtk+-b99cb70299e9a5148556540dc584ea5535241a6e.tar.gz |
css: Implement font-variant-numeric
This gets translated to the corresponding OpenType features.
Diffstat (limited to 'gtk/gtkcssstylepropertyimpl.c')
-rw-r--r-- | gtk/gtkcssstylepropertyimpl.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c index 12b4f3ce15..a0311b37b0 100644 --- a/gtk/gtkcssstylepropertyimpl.c +++ b/gtk/gtkcssstylepropertyimpl.c @@ -658,6 +658,85 @@ parse_font_variant_caps (GtkCssStyleProperty *property, } static GtkCssValue * +parse_font_variant_numeric (GtkCssStyleProperty *property, + GtkCssParser *parser) +{ + GtkCssValue *value = NULL; + + if (_gtk_css_parser_try (parser, "normal", TRUE)) + value = _gtk_css_array_value_new (_gtk_css_ident_value_new ("normal")); + else + { + GtkCssValue *values[5] = { NULL, NULL, NULL, NULL }; + guint n_values = 0; + guint old_n; + gboolean figure = FALSE; + gboolean spacing = FALSE; + gboolean fraction = FALSE; + gboolean ordinal = FALSE; + gboolean zero = FALSE; + + do { + old_n = n_values; + if (!figure) + { + values[n_values] = _gtk_css_ident_value_try (parser, "lining-nums", "oldstyle-nums", NULL); + if (values[n_values]) + { + n_values++; + figure = TRUE; + } + } + if (!spacing) + { + values[n_values] = _gtk_css_ident_value_try (parser, "proportional-nums", "tabular-nums", NULL); + if (values[n_values]) + { + n_values++; + spacing = TRUE; + } + } + if (!fraction) + { + values[n_values] = _gtk_css_ident_value_try (parser, "diagonal-fractions", "stacked-fractions", NULL); + if (values[n_values]) + { + n_values++; + fraction = TRUE; + } + } + if (!ordinal) + { + values[n_values] = _gtk_css_ident_value_try (parser, "ordinal", NULL); + if (values[n_values]) + { + n_values++; + ordinal = TRUE; + } + } + if (!zero) + { + values[n_values] = _gtk_css_ident_value_try (parser, "slashed-zero", NULL); + if (values[n_values]) + { + n_values++; + zero = TRUE; + } + } + if (old_n == n_values) + { + _gtk_css_parser_error (parser, "Not a valid value"); + return NULL; + } + } while (!value_is_done_parsing (parser)); + + value = _gtk_css_array_value_new_from_array (values, n_values); + } + + return value; +} + +static GtkCssValue * box_shadow_value_parse (GtkCssStyleProperty *property, GtkCssParser *parser) { @@ -1174,6 +1253,14 @@ _gtk_css_style_property_init_properties (void) parse_font_variant_caps, NULL, _gtk_css_ident_value_new ("normal")); + gtk_css_style_property_register ("font-variant-numeric", + GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC, + G_TYPE_NONE, + 0, + GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS, + parse_font_variant_numeric, + 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, |