forked from AuroraMiddleware/gtk
css: Implement font-variant-position
This gets translated to the corresponding OpenType features.
This commit is contained in:
parent
c4cbe5feca
commit
01ed84fbef
@ -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);
|
||||
|
||||
|
@ -628,6 +628,19 @@ parse_font_variant_ligatures (GtkCssStyleProperty *property,
|
||||
return value;
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user