forked from AuroraMiddleware/gtk
css: Implement font-kerning
This gets translated to the OpenType feature kern.
This commit is contained in:
parent
6420dd934f
commit
cee4622567
@ -225,6 +225,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
|
||||
const GdkRGBA *color;
|
||||
const GdkRGBA *decoration_color;
|
||||
gint letter_spacing;
|
||||
GtkCssValue *kerning;
|
||||
|
||||
/* text-decoration */
|
||||
decoration_line = _gtk_css_text_decoration_line_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_TEXT_DECORATION_LINE));
|
||||
@ -260,6 +261,12 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
|
||||
attrs = add_pango_attr (attrs, pango_attr_letter_spacing_new (letter_spacing * PANGO_SCALE));
|
||||
}
|
||||
|
||||
kerning = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_KERNING);
|
||||
if (strcmp (_gtk_css_ident_value_get (kerning), "normal") == 0)
|
||||
attrs = add_pango_attr (attrs, pango_attr_font_features_new ("kern 1"));
|
||||
else if (strcmp (_gtk_css_ident_value_get (kerning), "none") == 0)
|
||||
attrs = add_pango_attr (attrs, pango_attr_font_features_new ("kern 0"));
|
||||
|
||||
return attrs;
|
||||
}
|
||||
|
||||
|
@ -530,6 +530,19 @@ parse_text_decoration_style (GtkCssStyleProperty *property,
|
||||
return value;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
parse_font_kerning (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
GtkCssValue *value = NULL;
|
||||
|
||||
value = _gtk_css_ident_value_try (parser, "auto", "normal", "none", 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)
|
||||
@ -1015,6 +1028,14 @@ _gtk_css_style_property_init_properties (void)
|
||||
parse_text_decoration_style,
|
||||
NULL,
|
||||
_gtk_css_text_decoration_style_value_new (GTK_CSS_TEXT_DECORATION_STYLE_SOLID));
|
||||
gtk_css_style_property_register ("font-kerning",
|
||||
GTK_CSS_PROPERTY_FONT_KERNING,
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
|
||||
parse_font_kerning,
|
||||
NULL,
|
||||
_gtk_css_ident_value_new ("auto"));
|
||||
|
||||
gtk_css_style_property_register ("text-shadow",
|
||||
GTK_CSS_PROPERTY_TEXT_SHADOW,
|
||||
|
@ -163,6 +163,7 @@ enum { /*< skip >*/
|
||||
GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
|
||||
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
|
||||
GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
|
||||
GTK_CSS_PROPERTY_FONT_KERNING,
|
||||
GTK_CSS_PROPERTY_TEXT_SHADOW,
|
||||
GTK_CSS_PROPERTY_BOX_SHADOW,
|
||||
GTK_CSS_PROPERTY_MARGIN_TOP,
|
||||
|
Loading…
Reference in New Issue
Block a user