css: Implement font-stretch
The font-stretch CSS property is defined in the Level 3 CSS Fonts module, available at: http://dev.w3.org/csswg/css-fonts/#propdef-font-stretch It allows defining a normal, condensed, or expanded face to the font description. Pango already supports it, so this is literally just the CSS parser machinery needed to bridge our CSS to the FontDescription API. https://bugzilla.gnome.org/show_bug.cgi?id=735593
This commit is contained in:
@ -436,6 +436,60 @@ _gtk_css_font_weight_value_get (const GtkCssValue *value)
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* PangoStretch */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_FONT_STRETCH = {
|
||||
gtk_css_value_enum_free,
|
||||
gtk_css_value_enum_compute,
|
||||
gtk_css_value_enum_equal,
|
||||
gtk_css_value_enum_transition,
|
||||
gtk_css_value_enum_print
|
||||
};
|
||||
|
||||
static GtkCssValue font_stretch_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_CONDENSED, "condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_EXPANDED, "expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_font_stretch_value_new (PangoStretch font_stretch)
|
||||
{
|
||||
g_return_val_if_fail (font_stretch < G_N_ELEMENTS (font_stretch_values), NULL);
|
||||
|
||||
return _gtk_css_value_ref (&font_stretch_values[font_stretch]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_font_stretch_value_try_parse (GtkCssParser *parser)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (parser != NULL, NULL);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (font_stretch_values); i++)
|
||||
{
|
||||
if (_gtk_css_parser_try (parser, font_stretch_values[i].name, TRUE))
|
||||
return _gtk_css_value_ref (&font_stretch_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PangoStretch
|
||||
_gtk_css_font_stretch_value_get (const GtkCssValue *value)
|
||||
{
|
||||
g_return_val_if_fail (value->class == >K_CSS_VALUE_FONT_STRETCH, PANGO_STRETCH_NORMAL);
|
||||
|
||||
return value->value;
|
||||
}
|
||||
|
||||
/* GtkCssArea */
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
|
||||
|
||||
Reference in New Issue
Block a user