nodeparser: Fix a font handling mishap
When we don't have an embedded font file via a url, then we want to parse fonts "as normal", i.e. allow fallback for aliases like "Monospace 10". This was broken when the url support was added. Make it work again. Update affected tests. In particular, the output of the text-fail test goes back to be the same it was before the url changes.
This commit is contained in:
@@ -854,7 +854,8 @@ parse_mask_mode (GtkCssParser *parser,
|
||||
|
||||
static PangoFont *
|
||||
font_from_string (PangoFontMap *fontmap,
|
||||
const char *string)
|
||||
const char *string,
|
||||
gboolean allow_fallback)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
PangoContext *ctx;
|
||||
@@ -865,7 +866,7 @@ font_from_string (PangoFontMap *fontmap,
|
||||
font = pango_font_map_load_font (fontmap, ctx, desc);
|
||||
g_object_unref (ctx);
|
||||
|
||||
if (font)
|
||||
if (font && !allow_fallback)
|
||||
{
|
||||
PangoFontDescription *desc2;
|
||||
const char *family, *family2;
|
||||
@@ -1081,7 +1082,7 @@ parse_font (GtkCssParser *parser,
|
||||
return FALSE;
|
||||
|
||||
if (context->fontmap)
|
||||
font = font_from_string (context->fontmap, font_name);
|
||||
font = font_from_string (context->fontmap, font_name, FALSE);
|
||||
|
||||
if (gtk_css_parser_has_url (parser))
|
||||
{
|
||||
@@ -1140,7 +1141,7 @@ parse_font (GtkCssParser *parser,
|
||||
|
||||
if (success)
|
||||
{
|
||||
font = font_from_string (context->fontmap, font_name);
|
||||
font = font_from_string (context->fontmap, font_name, FALSE);
|
||||
if (!font)
|
||||
{
|
||||
gtk_css_parser_error (parser,
|
||||
@@ -1156,7 +1157,7 @@ parse_font (GtkCssParser *parser,
|
||||
else
|
||||
{
|
||||
if (!font)
|
||||
font = font_from_string (pango_cairo_font_map_get_default (), font_name);
|
||||
font = font_from_string (pango_cairo_font_map_get_default (), font_name, TRUE);
|
||||
|
||||
if (!font)
|
||||
gtk_css_parser_error_value (parser, "The font \"%s\" does not exist", font_name);
|
||||
@@ -2236,7 +2237,7 @@ parse_text_node (GtkCssParser *parser,
|
||||
|
||||
if (font == NULL)
|
||||
{
|
||||
font = font_from_string (pango_cairo_font_map_get_default (), "Cantarell 11");
|
||||
font = font_from_string (pango_cairo_font_map_get_default (), "Cantarell 11", TRUE);
|
||||
g_assert (font);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<data>:3:11-12: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||
<data>:4:11-12: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||
<data>:4:3-7: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||
<data>:6:3-9: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||
<data>:8:1-2: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
text {
|
||||
color: rgb(50,50,50);
|
||||
font: "Cantarell 11";
|
||||
glyphs: "N";
|
||||
offset: 0 32.0186;
|
||||
color {
|
||||
bounds: 0 0 50 50;
|
||||
color: rgb(255,0,204);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<data>:21:32-36: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||
<data>:50:23-24: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||
<data>:55:24-69:3: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||
<data>:74:24-33: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||
<data>:79:24-38: error: g-io-error-quark 15
|
||||
|
||||
@@ -28,7 +28,7 @@ text {
|
||||
glyphs: "Hello";
|
||||
}
|
||||
text {
|
||||
font: "Cantarell 11";
|
||||
font: "Noto Sans 11";
|
||||
glyphs: "Hello";
|
||||
}
|
||||
text {
|
||||
|
||||
Reference in New Issue
Block a user