From 097dae851bfc60ac41aa1d43a3218232045cd109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= Date: Sun, 22 Apr 2012 17:55:06 +0200 Subject: [PATCH 1/3] Fix Standard-14 fallback fonts wingding.ttf is totally different from ZapfDingbats. symbol.ttf is only a lousy fallback for Symbol. Based on patch provided by Jonathan Kew. --- poppler/GlobalParamsWin.cc | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc index d8065e0..693d08c 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", NULL, gTrue}, // those seem to be frequently accessed by PDF files and I kind of guess // which font file do the refer to -- 1.7.5.4 From 6121fee9ff7d7b57df15939830614b42db0e4426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= Date: Sun, 22 Apr 2012 17:56:09 +0200 Subject: [PATCH 2/3] Only check for Type1 fonts in custom directory if path is non-NULL Otherwise, programs using poppler may crash --- poppler/GlobalParamsWin.cc | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc index 693d08c..1cbc7f4 100644 --- a/poppler/GlobalParamsWin.cc +++ b/poppler/GlobalParamsWin.cc @@ -424,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())) { -- 1.7.5.4 From dc58e8e02a97eff568efe55be4f3420766a0c0fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= Date: Sun, 22 Apr 2012 17:58:21 +0200 Subject: [PATCH 3/3] Allow custom substitution fonts on Windows Standard-compliant PDF viewers must be able to handle 14 standard fonts even if they are not embedded. For the Symbol and ZapfDingbats fonts, there is no suitable alternative available on Windows by default, so they must be provided separately (and poppler must find them). The search path is share/fonts/type1/gsfonts (relative to poppler) similar to *nix systems and the search path for poppler-data. --- poppler/GlobalParams.cc | 39 +++++++++++++++++++++++++++++++++++++++ poppler/GlobalParamsWin.cc | 2 +- 2 files changed, 40 insertions(+), 1 deletions(-) diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc index 811a120..5e38153 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -198,6 +198,45 @@ get_poppler_datadir (void) #endif +#ifdef _WIN32 + +// 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) +{ +#if !ENABLE_RELOCATABLE + static HMODULE hmodule = 0; +#endif + 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'; + } + strcat (retval, "\\share\\fonts\\type1\\gsfonts"); + + beenhere = 1; + + return retval; +} + +#endif + //------------------------------------------------------------------------ // SysFontInfo //------------------------------------------------------------------------ diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc index 1cbc7f4..419b194 100644 --- a/poppler/GlobalParamsWin.cc +++ b/poppler/GlobalParamsWin.cc @@ -563,7 +563,7 @@ GooString *GlobalParams::findSystemFontFile(GfxFont *font, GooString *fontName = font->getName(); if (!fontName) return NULL; lockGlobalParams; - setupBaseFonts(NULL); + setupBaseFonts(get_poppler_fontdir()); // TODO: base14Name should be changed? // In the system using FontConfig, findSystemFontFile() uses -- 1.7.5.4