]> granicus.if.org Git - libass/commitdiff
Improve font mismatch message
authorwm4 <wm4@nowhere>
Mon, 17 Jun 2013 21:52:49 +0000 (23:52 +0200)
committerwm4 <wm4@nowhere>
Sat, 22 Jun 2013 17:07:58 +0000 (19:07 +0200)
Example for an old message:

 [ass] fontconfig: Selected font is not the requested one: 'DejaVu Sans' != 'Wingdings'

it was hard to tell which was the selected and the requested font.
Also, it's not really clear what's the problem at all. Why would it
select a different font? Obviously, the issue is that it can't find
the font in the first place.

Now it prints:

 [ass] fontconfig: cannot find glyph U+006C in font 'Wingdings', falling back to 'DejaVu Sans'

Or if the code parameter for select_font() is 0:

 [ass] fontconfig: cannot find font 'Wingdings', falling back to 'DejaVu Sans'

I'm not sure if this message is really accurate in all cases. It's
possible that there are more reasons for failure. But all things
considered, this should be easier to understand.

libass/ass_fontconfig.c

index d3dddea72937c67104a714d2045bf7b087981862..b8ad9ec59391cc02882f4992bb02bc4e2ef5c37b 100644 (file)
@@ -257,11 +257,18 @@ static char *select_font(ASS_Library *library, FCInstance *priv,
 
     if (!treat_family_as_pattern &&
         !(r_family && strcasecmp((const char *) r_family, family) == 0) &&
-        !(r_fullname && strcasecmp((const char *) r_fullname, family) == 0))
-        ass_msg(library, MSGL_WARN,
-               "fontconfig: Selected font is not the requested one: "
-               "'%s' != '%s'",
-               (const char *) (r_fullname ? r_fullname : r_family), family);
+        !(r_fullname && strcasecmp((const char *) r_fullname, family) == 0)) {
+        char *fallback = (char *) (r_fullname ? r_fullname : r_family);
+        if (code) {
+            ass_msg(library, MSGL_WARN,
+                    "fontconfig: cannot find glyph U+%04X in font '%s', falling back to '%s'",
+                    (unsigned int)code, family, fallback);
+        } else {
+            ass_msg(library, MSGL_WARN,
+                    "fontconfig: cannot find font '%s', falling back to '%s'",
+                    family, fallback);
+        }
+    }
 
     result = FcPatternGetString(rpat, FC_STYLE, 0, &r_style);
     if (result != FcResultMatch)