diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-09-18 00:01:39 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-09-18 14:26:57 -0400 |
commit | 01ed84fbefcb2cec8518daef73d7621249ab05a8 (patch) | |
tree | 72687255f5361c0acc3d6888d6b732b77f45efd8 | |
parent | c4cbe5fecafcd2b244981769086081d4fbfb1fc2 (diff) | |
download | gtk+-01ed84fbefcb2cec8518daef73d7621249ab05a8.tar.gz |
css: Implement font-variant-position
This gets translated to the corresponding OpenType features.
-rw-r--r-- | gtk/gtkcssstyle.c | 14 | ||||
-rw-r--r-- | gtk/gtkcssstylepropertyimpl.c | 22 | ||||
-rw-r--r-- | gtk/gtkcsstypesprivate.h | 1 |
3 files changed, 36 insertions, 1 deletions
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c index 44a9f1c972..a0bdc8d536 100644 --- a/gtk/gtkcssstyle.c +++ b/gtk/gtkcssstyle.c @@ -227,6 +227,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style) gint letter_spacing; GtkCssValue *kerning; GtkCssValue *ligatures; + GtkCssValue *position; GString *s; int i; @@ -265,6 +266,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style) } /* OpenType features */ + s = g_string_new (""); kerning = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_KERNING); @@ -298,6 +300,18 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style) g_string_append (s, "calt 0"); } + position = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_POSITION); + if (strcmp (_gtk_css_ident_value_get (position), "sub") == 0) + { + if (s->len > 0) g_string_append (s, ", "); + g_string_append (s, "subs 1"); + } + else if (strcmp (_gtk_css_ident_value_get (kerning), "super") == 0) + { + if (s->len > 0) g_string_append (s, ", "); + g_string_append (s, "sups 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 a07fe1b527..3514dc28f7 100644 --- a/gtk/gtkcssstylepropertyimpl.c +++ b/gtk/gtkcssstylepropertyimpl.c @@ -629,6 +629,19 @@ parse_font_variant_ligatures (GtkCssStyleProperty *property, } static GtkCssValue * +parse_font_variant_position (GtkCssStyleProperty *property, + GtkCssParser *parser) +{ + GtkCssValue *value = NULL; + + value = _gtk_css_ident_value_try (parser, "normal", "sub", "super", NULL); + if (value == NULL) + _gtk_css_parser_error (parser, "unknown value for property"); + + return value; +} + +static GtkCssValue * box_shadow_value_parse (GtkCssStyleProperty *property, GtkCssParser *parser) { @@ -1129,7 +1142,14 @@ _gtk_css_style_property_init_properties (void) parse_font_variant_ligatures, NULL, _gtk_css_array_value_new (_gtk_css_ident_value_new ("normal"))); - + gtk_css_style_property_register ("font-variant-position", + GTK_CSS_PROPERTY_FONT_VARIANT_POSITION, + G_TYPE_NONE, + 0, + GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS, + parse_font_variant_position, + NULL, + _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 2ff67500c3..cb340ea05e 100644 --- a/gtk/gtkcsstypesprivate.h +++ b/gtk/gtkcsstypesprivate.h @@ -165,6 +165,7 @@ enum { /*< skip >*/ GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE, GTK_CSS_PROPERTY_FONT_KERNING, GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES, + GTK_CSS_PROPERTY_FONT_VARIANT_POSITION, GTK_CSS_PROPERTY_TEXT_SHADOW, GTK_CSS_PROPERTY_BOX_SHADOW, GTK_CSS_PROPERTY_MARGIN_TOP, |