From: kramm Date: Wed, 12 Mar 2008 19:09:51 +0000 (+0000) Subject: choose external fonts based on the shortest filename X-Git-Tag: buttons-working~418 X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=e1ee7f27701a4d6dc8f4133b987a930e3d510a5c;p=swftools.git choose external fonts based on the shortest filename --- diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 4d56590..416bf0b 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -80,6 +80,7 @@ typedef struct _fontfile { const char*filename; + int len; // basename length int used; } fontfile_t; @@ -327,12 +328,21 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) return dfp; } } + + int bestlen = 0x7fffffff; + const char*bestfilename = 0; for(t=0;tt1.fileName = new GString(fonts[t].filename); - return dfp; - } + if(fonts[t].len < bestlen) { + bestlen = fonts[t].len; + bestfilename = fonts[t].filename; + } + } + } + if(bestfilename) { + DisplayFontParam *dfp = new DisplayFontParam(new GString(fontName), displayFontT1); + dfp->t1.fileName = new GString(bestfilename); + return dfp; } return GlobalParams::getDisplayFont(fontName); } @@ -2007,6 +2017,15 @@ void addGlobalFont(const char*filename) fontfile_t f; memset(&f, 0, sizeof(fontfile_t)); f.filename = filename; + int len = strlen(filename); + char*r1 = strrchr(filename, '/'); + char*r2 = strrchr(filename, '\\'); + if(r2>r1) + r1 = r2; + if(r1) { + len = strlen(r1+1); + } + f.len = len; if(fontnum < sizeof(fonts)/sizeof(fonts[0])) { msg(" Adding font \"%s\".", filename); fonts[fontnum++] = f;