From 28908369203be43c32bd1ac499fa3dc825b78c96 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 17 Jun 2013 23:52:49 +0200 Subject: Improve font mismatch message 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 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c index d3dddea..b8ad9ec 100644 --- a/libass/ass_fontconfig.c +++ b/libass/ass_fontconfig.c @@ -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) -- cgit v1.2.3