[gtk+] css: Implement font-variant-east-asian
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Implement font-variant-east-asian
- Date: Mon, 18 Sep 2017 18:30:02 +0000 (UTC)
commit b91f3ce3312ba23041ee8844b446599bbf62f5e4
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Sep 18 12:42:42 2017 -0400
css: Implement font-variant-east-asian
This is translated to the corresponding OpenType features.
gtk/gtkcssstyle.c | 26 +++++++++++++++
gtk/gtkcssstylepropertyimpl.c | 70 +++++++++++++++++++++++++++++++++++++++++
gtk/gtkcsstypesprivate.h | 1 +
3 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index 1fbe5e6..f6eaa35 100644
--- a/gtk/gtkcssstyle.c
+++ b/gtk/gtkcssstyle.c
@@ -231,6 +231,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
GtkCssValue *caps;
GtkCssValue *numeric;
GtkCssValue *alternatives;
+ GtkCssValue *east_asian;
GString *s;
int i;
@@ -379,6 +380,31 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
g_string_append (s, "hist 1");
}
+ east_asian = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN);
+ for (i = 0; i < _gtk_css_array_value_get_n_values (east_asian); i++)
+ {
+ GtkCssValue *value = _gtk_css_array_value_get_nth (east_asian, i);
+ if (s->len > 0) g_string_append (s, ", ");
+ if (strcmp (_gtk_css_ident_value_get (value), "jis78") == 0)
+ g_string_append (s, "jp78 1");
+ if (strcmp (_gtk_css_ident_value_get (value), "jis83") == 0)
+ g_string_append (s, "jp83 1");
+ if (strcmp (_gtk_css_ident_value_get (value), "jis90") == 0)
+ g_string_append (s, "jp90 1");
+ if (strcmp (_gtk_css_ident_value_get (value), "jis04") == 0)
+ g_string_append (s, "jp04 1");
+ if (strcmp (_gtk_css_ident_value_get (value), "simplified") == 0)
+ g_string_append (s, "smpl 1");
+ if (strcmp (_gtk_css_ident_value_get (value), "traditional") == 0)
+ g_string_append (s, "trad 1");
+ if (strcmp (_gtk_css_ident_value_get (value), "full-width") == 0)
+ g_string_append (s, "fwid 1");
+ if (strcmp (_gtk_css_ident_value_get (value), "proportional-width") == 0)
+ g_string_append (s, "pwid 1");
+ if (strcmp (_gtk_css_ident_value_get (value), "ruby") == 0)
+ g_string_append (s, "ruby 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 25c66f9..a81a5a2 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -750,6 +750,68 @@ parse_font_variant_alternatives (GtkCssStyleProperty *property,
}
static GtkCssValue *
+parse_font_variant_east_asian (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[3] = { NULL, NULL, NULL };
+ guint n_values = 0;
+ guint old_n;
+ gboolean variant = FALSE;
+ gboolean width = FALSE;
+ gboolean ruby = FALSE;
+
+ do {
+ old_n = n_values;
+ if (!variant)
+ {
+ values[n_values] = _gtk_css_ident_value_try (parser, "jis78", "jis83", "jis90", "jis04",
+ "simplified", "traditional", NULL);
+ if (values[n_values])
+ {
+ n_values++;
+ variant = TRUE;
+ }
+ }
+ if (!width)
+ {
+ values[n_values] = _gtk_css_ident_value_try (parser, "full-width"
+ "proportional-width", NULL);
+ if (values[n_values])
+ {
+ n_values++;
+ width = TRUE;
+ }
+ }
+ if (!ruby)
+ {
+ values[n_values] = _gtk_css_ident_value_try (parser, "ruby", NULL);
+ if (values[n_values])
+ {
+ n_values++;
+ ruby = 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)
{
@@ -1282,6 +1344,14 @@ _gtk_css_style_property_init_properties (void)
parse_font_variant_alternatives,
NULL,
_gtk_css_array_value_new (_gtk_css_ident_value_new ("normal")));
+ gtk_css_style_property_register ("font-variant-east-asian",
+ GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN,
+ G_TYPE_NONE,
+ 0,
+ GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
+ parse_font_variant_east_asian,
+ 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 6518a24..8e939f3 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -169,6 +169,7 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_FONT_VARIANT_CAPS,
GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC,
GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATIVES,
+ GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN,
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]