From 09fcba365e7453082f476af64067ab4a4506a2c8 Mon Sep 17 00:00:00 2001 From: kramm Date: Sat, 12 Jun 2004 16:07:40 +0000 Subject: [PATCH] fixed tempfile handling, support for buggy ttf2pt1 argument parser. --- pdf2swf/SWFOutputDev.cc | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index 8624e6c..b9454d0 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -976,19 +976,6 @@ void SWFOutputDev::updateStrokeColor(GfxState *state) (char)(rgb.b*255), (char)(opaq*255)); } -static char* tempFile(char*filename) -{ - char*dir = getenv("TMP"); - if(!dir) dir = getenv("TEMP"); - if(!dir) dir = getenv("tmp"); - if(!dir) dir = getenv("temp"); - if(!dir) dir = "C:\\"; - static char buf[512]; - strcpy(buf, dir); - strcat(buf, filename); - return buf; -} - char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) { char*tmpFileName = NULL; @@ -999,11 +986,8 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) Type1CFontFile *cvt; Ref embRef; Object refObj, strObj; -#ifdef WIN32 - tmpFileName = tempFile("tmpfont"); -#else - tmpFileName = "/tmp/tmpfont"; -#endif + char namebuf[512]; + tmpFileName = mktmpname(namebuf); int ret; ret = font->getEmbeddedFontID(&embRef); @@ -1072,25 +1056,25 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) msg(" File contains TrueType fonts"); ttfinfo = 1; } - char name2[80]; + char name2[512]; char*tmp; tmp = strdup(mktmpname((char*)name2)); sprintf(name2, "%s", tmp); - char*a[] = {"./ttf2pt1", "-W0", + char*a[] = {"./ttf2pt1", "-W", "0", #ifndef USE_FREETYPE - "-pttf", + "-p", "ttf", #else - "-pft", + "-p", "ft", #endif "-b", tmpFileName, name2}; - msg(" Invoking %s %s %s %s %s %s",a[0],a[1],a[2],a[3],a[4],a[5]); - ttf2pt1_main(6,a); + msg(" Invoking %s %s %s %s %s %s %s %s",a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]); + ttf2pt1_main(8,a); unlink(tmpFileName); sprintf(name2,"%s.pfb",tmp); tmpFileName = strdup(name2); } - return tmpFileName; + return strdup(tmpFileName); } char* gfxFontName(GfxFont* gfxFont) -- 1.7.10.4