X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=93eda131034ede986de2636b3eeb0b63cdbc3bfb;hb=e8732af08c0ea32ee3b0292c28bba6fd4c1de91a;hp=2b0e8928719e05c4de07948a72a6751b198a7c8b;hpb=cdcf434411b35bb57bc3de9dffa6314d6ac70d5f;p=swftools.git diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 2b0e892..93eda13 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -97,8 +97,6 @@ static int fontnum = 0; /* config */ -static char* lastfontdir = 0; - struct fontentry { const char*pdffont; const char*filename; @@ -416,6 +414,14 @@ char* fontconfig_searchForFont(char*name) config_use_fontconfig = 0; return 0; } + + /* add external fonts to fontconfig's config, too. */ + fontfile_t*fd = global_fonts; + while(fd) { + FcConfigAppFontAddFile(config, (FcChar8*)fd->filename); + fd = fd->next; + } + FcFontSet * set = FcConfigGetFonts(config, FcSetSystem); msg(" FontConfig initialized. Found %d fonts", set?set->nfont:0); if(!set || !set->nfont) { @@ -524,7 +530,9 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) int bestlen = 0x7fffffff; const char*bestfilename = 0; - + +#ifndef HAVE_FONTCONFIG + /* if we don't have fontconfig, try a simple filename-comparison approach */ fontfile_t*f = global_fonts; while(f) { if(strstr(f->filename, name)) { @@ -535,6 +543,7 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) } f = f->next; } +#endif /* if we didn't find anything up to now, try looking for the font via fontconfig */ @@ -546,6 +555,7 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) } if(filename) { + msg(" Font %s maps to %s\n", name, filename); DisplayFontParamKind kind = detectFontType(filename); DisplayFontParam *dfp = new DisplayFontParam(new GString(fontName), kind); if(kind == displayFontTT) { @@ -2445,7 +2455,7 @@ void addGlobalFont(const char*filename) } f->len = len; - msg(" Adding font \"%s\".", filename); + msg(" Adding font \"%s\".", filename); if(global_fonts_next) { global_fonts_next->next = f; global_fonts_next = global_fonts_next->next; @@ -2476,14 +2486,13 @@ void addGlobalLanguageDir(const char*dir) void addGlobalFontDir(const char*dirname) { #ifdef HAVE_DIRENT_H - msg(" Adding %s to font directories", dirname); - lastfontdir = strdup(dirname); DIR*dir = opendir(dirname); if(!dir) { msg(" Couldn't open directory %s", dirname); return; } struct dirent*ent; + int fonts = 0; while(1) { ent = readdir (dir); if (!ent) @@ -2507,11 +2516,13 @@ void addGlobalFontDir(const char*dirname) strcat(fontname, dirseparator()); strcat(fontname, name); addGlobalFont(fontname); + fonts++; } } + msg(" Added %s to font directories (%d fonts)", dirname, fonts); closedir(dir); #else - msg(" No dirent.h- unable to add font dir %s", dirname); + msg(" No dirent.h"); #endif }