diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc index 811a120..f8004c3 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -185,6 +185,10 @@ get_poppler_datadir (void) if (p) { if (stricmp ((const char *) (p+1), "bin") == 0) *p = '\0'; + if (stricmp ((const char *) (p+1), "debug") == 0) + *p = '\0'; + if (stricmp ((const char *) (p+1), "release") == 0) + *p = '\0'; } strcat (retval, "\\share\\poppler"); @@ -196,6 +200,44 @@ get_poppler_datadir (void) #undef POPPLER_DATADIR #define POPPLER_DATADIR get_poppler_datadir () +// On Windows, we don't have suitable system fonts for all 14 standard fonts as +// required by the PDF standard. Hence, applications should provide suitable +// additional replacement fonts (since poppler doesn't ship them). This function +// returns the path to the folder that should contain those fonts. +static char * +get_poppler_fontdir (void) +{ + static char retval[MAX_PATH]; + static int beenhere = 0; + + unsigned char *p; + + if (beenhere) + return retval; + + if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 32)) + return NULL; + + p = _mbsrchr ((unsigned char *) retval, '\\'); + *p = '\0'; + p = _mbsrchr ((unsigned char *) retval, '\\'); + if (p) { + if (stricmp ((const char *) (p+1), "bin") == 0) + *p = '\0'; + if (stricmp ((const char *) (p+1), "debug") == 0) + *p = '\0'; + if (stricmp ((const char *) (p+1), "release") == 0) + *p = '\0'; + } + strcat (retval, "\\share\\fonts\\type1\\gsfonts"); + + beenhere = 1; + + return retval; +} + +#undef POPPLER_FONTDIR +#define POPPLER_FONTDIR get_poppler_fontdir () #endif //------------------------------------------------------------------------ @@ -1130,7 +1172,7 @@ GooString *GlobalParams::findFontFile(GooString *fontName) { FILE *f; int i, j; - setupBaseFonts(NULL); + setupBaseFonts(POPPLER_FONTDIR); lockGlobalParams; if ((path = (GooString *)fontFiles->lookup(fontName))) { path = path->copy(); diff --git a/poppler/GlobalParams.h b/poppler/GlobalParams.h index 375ac2c..4fc83ee 100644 --- a/poppler/GlobalParams.h +++ b/poppler/GlobalParams.h @@ -38,6 +38,8 @@ #pragma interface #endif +#define POPPLER_FONTDIR NULL + #include #include "poppler-config.h" #include diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc index d8065e0..c92fa91 100644 --- a/poppler/GlobalParamsWin.cc +++ b/poppler/GlobalParamsWin.cc @@ -86,14 +86,17 @@ static struct { {"Helvetica-Bold", "n019004l.pfb", "arialbd.ttf", gTrue}, {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf", gTrue}, {"Helvetica-Oblique", "n019023l.pfb", "ariali.ttf", gTrue}, - // TODO: not sure if "symbol.ttf" is right + // "symbol.ttf" can be used as a fallback, but some symbols are differently + // encoded (e.g., the glyphs for 'f', 'j', 'v'), while most other glyphs + // have a fairly different appearance {"Symbol", "s050000l.pfb", "symbol.ttf", gTrue}, {"Times-Bold", "n021004l.pfb", "timesbd.ttf", gTrue}, {"Times-BoldItalic", "n021024l.pfb", "timesbi.ttf", gTrue}, {"Times-Italic", "n021023l.pfb", "timesi.ttf", gTrue}, {"Times-Roman", "n021003l.pfb", "times.ttf", gTrue}, - // TODO: not sure if "wingding.ttf" is right - {"ZapfDingbats", "d050000l.pfb", "wingding.ttf", gTrue}, + // "wingding.ttf" has a totally different encoding and hence can't be used + // instead of ZapfDingbats + {"ZapfDingbats", "d050000l.pfb", "zdingbats.ttf", gTrue}, // those seem to be frequently accessed by PDF files and I kind of guess // which font file do the refer to @@ -421,7 +424,7 @@ void GlobalParams::setupBaseFonts(char * dir) if (fontFiles->lookup(fontName)) continue; - if (dir) { + if (dir && displayFontTab[i].t1FileName) { GooString *fontPath = appendToPath(new GooString(dir), displayFontTab[i].t1FileName); if (FileExists(fontPath->getCString()) || FileExists(replaceSuffix(fontPath, ".pfb", ".pfa")->getCString())) { @@ -560,7 +563,7 @@ GooString *GlobalParams::findSystemFontFile(GfxFont *font, GooString *fontName = font->getName(); if (!fontName) return NULL; lockGlobalParams; - setupBaseFonts(NULL); + setupBaseFonts(POPPLER_FONTDIR); // TODO: base14Name should be changed? // In the system using FontConfig, findSystemFontFile() uses