mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-01 00:11:29 +00:00
css: Implement font-variant-caps
This gets translated to the corresponding OpenType features.
This commit is contained in:
parent
01ed84fbef
commit
8525afc408
@ -228,6 +228,7 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
|
||||
GtkCssValue *kerning;
|
||||
GtkCssValue *ligatures;
|
||||
GtkCssValue *position;
|
||||
GtkCssValue *caps;
|
||||
GString *s;
|
||||
int i;
|
||||
|
||||
@ -312,6 +313,38 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
|
||||
g_string_append (s, "sups 1");
|
||||
}
|
||||
|
||||
caps = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_VARIANT_CAPS);
|
||||
if (strcmp (_gtk_css_ident_value_get (caps), "small-caps") == 0)
|
||||
{
|
||||
if (s->len > 0) g_string_append (s, ", ");
|
||||
g_string_append (s, "smcp 1");
|
||||
}
|
||||
else if (strcmp (_gtk_css_ident_value_get (caps), "all-small-caps") == 0)
|
||||
{
|
||||
if (s->len > 0) g_string_append (s, ", ");
|
||||
g_string_append (s, "c2sc 1, smcp 1");
|
||||
}
|
||||
else if (strcmp (_gtk_css_ident_value_get (caps), "petite-caps") == 0)
|
||||
{
|
||||
if (s->len > 0) g_string_append (s, ", ");
|
||||
g_string_append (s, "pcap 1");
|
||||
}
|
||||
else if (strcmp (_gtk_css_ident_value_get (caps), "all-petite-caps") == 0)
|
||||
{
|
||||
if (s->len > 0) g_string_append (s, ", ");
|
||||
g_string_append (s, "c2pc 1, pcap 1");
|
||||
}
|
||||
else if (strcmp (_gtk_css_ident_value_get (caps), "unicase") == 0)
|
||||
{
|
||||
if (s->len > 0) g_string_append (s, ", ");
|
||||
g_string_append (s, "unic 1");
|
||||
}
|
||||
else if (strcmp (_gtk_css_ident_value_get (caps), "titling-caps") == 0)
|
||||
{
|
||||
if (s->len > 0) g_string_append (s, ", ");
|
||||
g_string_append (s, "titl 1");
|
||||
}
|
||||
|
||||
attrs = add_pango_attr (attrs, pango_attr_font_features_new (s->str));
|
||||
g_string_free (s, TRUE);
|
||||
|
||||
|
@ -641,6 +641,22 @@ parse_font_variant_position (GtkCssStyleProperty *property,
|
||||
return value;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
parse_font_variant_caps (GtkCssStyleProperty *property,
|
||||
GtkCssParser *parser)
|
||||
{
|
||||
GtkCssValue *value = NULL;
|
||||
|
||||
value = _gtk_css_ident_value_try (parser, "normal",
|
||||
"small-caps", "all-small-caps",
|
||||
"petite-caps", "all-petite-caps",
|
||||
"unicase", "titling-caps", 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)
|
||||
@ -1150,6 +1166,14 @@ _gtk_css_style_property_init_properties (void)
|
||||
parse_font_variant_position,
|
||||
NULL,
|
||||
_gtk_css_ident_value_new ("normal"));
|
||||
gtk_css_style_property_register ("font-variant-caps",
|
||||
GTK_CSS_PROPERTY_FONT_VARIANT_CAPS,
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
GTK_CSS_AFFECTS_TEXT | GTK_CSS_AFFECTS_TEXT_ATTRS,
|
||||
parse_font_variant_caps,
|
||||
NULL,
|
||||
_gtk_css_ident_value_new ("normal"));
|
||||
gtk_css_style_property_register ("text-shadow",
|
||||
GTK_CSS_PROPERTY_TEXT_SHADOW,
|
||||
G_TYPE_NONE,
|
||||
|
@ -166,6 +166,7 @@ enum { /*< skip >*/
|
||||
GTK_CSS_PROPERTY_FONT_KERNING,
|
||||
GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES,
|
||||
GTK_CSS_PROPERTY_FONT_VARIANT_POSITION,
|
||||
GTK_CSS_PROPERTY_FONT_VARIANT_CAPS,
|
||||
GTK_CSS_PROPERTY_TEXT_SHADOW,
|
||||
GTK_CSS_PROPERTY_BOX_SHADOW,
|
||||
GTK_CSS_PROPERTY_MARGIN_TOP,
|
||||
|
Loading…
Reference in New Issue
Block a user