[gtk+] css: Implement font-variant-position
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Implement font-variant-position
- Date: Mon, 18 Sep 2017 18:29:42 +0000 (UTC)
commit 01ed84fbefcb2cec8518daef73d7621249ab05a8
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Sep 18 00:01:39 2017 -0400
css: Implement font-variant-position
This gets translated to the corresponding OpenType features.
gtk/gtkcssstyle.c | 14 ++++++++++++++
gtk/gtkcssstylepropertyimpl.c | 22 +++++++++++++++++++++-
gtk/gtkcsstypesprivate.h | 1 +
3 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index 44a9f1c..a0bdc8d 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 a07fe1b..3514dc2 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 2ff6750..cb340ea 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]