]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
label-freetype: fix fallback not working when fc-match isn't available
authorFerdinand Bachmann <ferdinand.bachmann@yrlf.at>
Tue, 16 Jan 2024 00:52:11 +0000 (01:52 +0100)
committerFerdinand Bachmann <ferdinand.bachmann@yrlf.at>
Tue, 16 Jan 2024 01:13:40 +0000 (02:13 +0100)
The new font loading functions introduced in
544e62ac41a490f04d8e6b4e85f8b9fa1171b0cc assume that popen() returns
NULL when fc-match is unavailable or fails. This is incorrect, since
popen() will always start a shell to run the passed command and return a
stream to that shell's stdin and stdout.

This results in an non-null but empty font name being passed to
FT_New_Face(), which fails.

This commit fixes this by also using the fallback font when the font
path read from the popen() stream is empty.

Fixes #239
Fixes regression caused by 544e62ac41a490f04d8e6b4e85f8b9fa1171b0cc

src/plugins/controls/label-freetype/plugin.c

index 917b04c0c991b42ee432f963ea9dca7561331f03..be206207996864c33e60aed089d0fee7420edc13 100644 (file)
@@ -135,6 +135,9 @@ find_default_font_path (void)
 
         pclose (fp);
 
+        if (strcmp (fc_match_out, "") == 0)
+                return FONT_FALLBACK;
+
         return fc_match_out;
 }
 
@@ -152,6 +155,9 @@ find_default_monospace_font_path (void)
 
         pclose (fp);
 
+        if (strcmp (fc_match_out, "") == 0)
+                return FONT_FALLBACK;
+
         return fc_match_out;
 }