diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 68 |
1 files changed, 39 insertions, 29 deletions
@@ -566,20 +566,9 @@ GetColorValue(int kind, XColor *what, const char *name) } } -/* - * The following functions are sensible to 'use_fontset'. - * When 'use_fontset' is True, - * - XFontSet-related internationalized functions are used - * so as multibyte languages can be displayed. - * When 'use_fontset' is False, - * - XFontStruct-related conventional functions are used - * so as 8-bit characters can be displayed even when - * locale is not set properly. - */ -void -GetFont(MyFont *font) +static Boolean +FindFontSet(MyFont *font, const char *fontname) { - const char *deffontname = "fixed"; char **missing_charset_list_return; int missing_charset_count_return; char *def_string_return; @@ -596,13 +585,11 @@ GetFont(MyFont *font) XFreeFontSet(dpy, font->fontset); } - if( (font->fontset = XCreateFontSet(dpy, font->name, + if( (font->fontset = XCreateFontSet(dpy, fontname, &missing_charset_list_return, &missing_charset_count_return, &def_string_return)) == NULL) { - fprintf (stderr, "%s: unable to open fontset \"%s\"\n", - ProgramName, font->name); - exit(1); + return False; } for(i=0; i<missing_charset_count_return; i++){ printf("%s: warning: font for charset %s is lacking.\n", @@ -620,29 +607,52 @@ GetFont(MyFont *font) font->y = ascent; font->ascent = ascent; font->descent = descent; - return; + return True; } if (font->font != NULL) XFreeFont(dpy, font->font); - if ((font->font = XLoadQueryFont(dpy, font->name)) == NULL) + if ((font->font = XLoadQueryFont(dpy, fontname)) == NULL) { - if (Scr->DefaultFont.name) { - deffontname = Scr->DefaultFont.name; - } - if ((font->font = XLoadQueryFont(dpy, deffontname)) == NULL) - { - fprintf (stderr, "%s: unable to open fonts \"%s\" or \"%s\"\n", - ProgramName, font->name, deffontname); - exit(1); - } - + return False; } font->height = font->font->ascent + font->font->descent; font->y = font->font->ascent; font->ascent = font->font->ascent; font->descent = font->font->descent; + return True; +} + +/* + * The following functions are sensible to 'use_fontset'. + * When 'use_fontset' is True, + * - XFontSet-related internationalized functions are used + * so as multibyte languages can be displayed. + * When 'use_fontset' is False, + * - XFontStruct-related conventional functions are used + * so as 8-bit characters can be displayed even when + * locale is not set properly. + */ +void +GetFont(MyFont *font) +{ + const char *deffontname = "fixed"; + + if (!FindFontSet(font, font->name)) { + const char *what = "fonts"; + + if (use_fontset) { + what = "fontsets"; + } else if (Scr->DefaultFont.name) { + deffontname = Scr->DefaultFont.name; + } + if (!FindFontSet(font, deffontname)) { + fprintf (stderr, "%s: unable to open %s \"%s\" or \"%s\"\n", + ProgramName, what, font->name, deffontname); + exit(1); + } + } } int |