st: Add support for font-feature-settings

Cantarell now supports tabular figures, which are useful in places
where digits should either align or not use different widths. In
order to allow elements to request the feature, add support for
the corresponding CSS property[0].

[0] https://www.w3.org/TR/css-fonts-3/#font-rend-desc

https://gitlab.gnome.org/GNOME/gnome-shell/issues/34
This commit is contained in:
Ryan Hendrickson
2018-05-17 10:45:02 -04:00
committed by Florian Müllner
parent 5ac6201d91
commit f56ba0877a
5 changed files with 90 additions and 0 deletions

View File

@ -3019,6 +3019,39 @@ st_theme_node_get_font (StThemeNode *node)
return node->font_desc;
}
gchar *
st_theme_node_get_font_features (StThemeNode *node)
{
int i;
ensure_properties (node);
for (i = node->n_properties - 1; i >= 0; i--)
{
CRDeclaration *decl = node->properties[i];
if (strcmp (decl->property->stryng->str, "font-feature-settings") == 0)
{
CRTerm *term = decl->value;
if (!term->next && term->type == TERM_IDENT)
{
gchar *ident = term->content.str->stryng->str;
if (strcmp (ident, "inherit") == 0)
break;
if (strcmp (ident, "normal") == 0)
return NULL;
}
return (gchar *)cr_term_to_string (term);
}
}
return node->parent_node ? st_theme_node_get_font_features (node->parent_node) : NULL;
}
/**
* st_theme_node_get_border_image:
* @node: a #StThemeNode