- } else {
- load_default = True;
- }
-
- if (load_default) {
- font = XLoadQueryFont(blackbox->getXDisplay(), defaultFont);
- if (font == NULL) {
- fprintf(stderr,
- i18n(ScreenSet, ScreenDefaultFontLoadFail,
- "BScreen::setCurrentStyle(): couldn't load default font.\n"));
- exit(2);
- }
- }
-
- return font;
-}
-
-
-#ifndef HAVE_STRCASESTR
-static const char * strcasestr(const char *str, const char *ptn) {
- const char *s2, *p2;
- for(; *str; str++) {
- for(s2=str,p2=ptn; ; s2++,p2++) {
- if (! *p2) return str;
- if (toupper(*s2) != toupper(*p2)) break;
- }
- }
- return NULL;
-}
-#endif // HAVE_STRCASESTR
-
-
-static const char *getFontElement(const char *pattern, char *buf,
- int bufsiz, ...) {
- const char *p, *v;
- char *p2;
- va_list va;
-
- va_start(va, bufsiz);
- buf[bufsiz-1] = 0;
- buf[bufsiz-2] = '*';
- while((v = va_arg(va, char *)) != NULL) {
- p = strcasestr(pattern, v);
- if (p) {
- strncpy(buf, p+1, bufsiz-2);
- p2 = strchr(buf, '-');
- if (p2) *p2=0;
- va_end(va);
- return p;
- }
- }
- va_end(va);
- strncpy(buf, "*", bufsiz);
- return NULL;
-}
-
-
-static const char *getFontSize(const char *pattern, int *size) {
- const char *p;
- const char *p2=NULL;
- int n=0;
-
- for (p=pattern; 1; p++) {
- if (! *p) {
- if (p2!=NULL && n>1 && n<72) {
- *size = n; return p2+1;
- } else {
- *size = 16; return NULL;
- }
- } else if (*p=='-') {
- if (n>1 && n<72 && p2!=NULL) {
- *size = n;
- return p2+1;
- }
- p2=p; n=0;
- } else if (*p>='0' && *p<='9' && p2!=NULL) {
- n *= 10;
- n += *p-'0';
- } else {
- p2=NULL; n=0;
- }
- }
-}
-
-
-XFontSet BScreen::createFontSet(const string &fontname) {
- XFontSet fs;
- char **missing, *def = "-";
- int nmissing, pixel_size = 0, buf_size = 0;
- char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE];
-
- fs = XCreateFontSet(blackbox->getXDisplay(),
- fontname.c_str(), &missing, &nmissing, &def);
- if (fs && (! nmissing))
- return fs;
-
- const char *nfontname = fontname.c_str();
-#ifdef HAVE_SETLOCALE
- if (! fs) {
- if (nmissing) XFreeStringList(missing);
-
- setlocale(LC_CTYPE, "C");
- fs = XCreateFontSet(blackbox->getXDisplay(), fontname.c_str(),
- &missing, &nmissing, &def);
- setlocale(LC_CTYPE, "");
- }
-#endif // HAVE_SETLOCALE
-
- if (fs) {
- XFontStruct **fontstructs;
- char **fontnames;
- XFontsOfFontSet(fs, &fontstructs, &fontnames);
- nfontname = fontnames[0];