added Windows version for temp files.
[swftools.git] / pdf2swf / SWFOutputDev.cc
index b0472ba..8624e6c 100644 (file)
@@ -663,6 +663,7 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y,
           swfoutput_drawchar(&output, x1, y1, name, c);
        else
           msg("<warning> couldn't get name for CID character %02x from Encoding", c);
+          swfoutput_drawchar(&output, x1, y1, "<unknown>", c);
     } else {
        Gfx8BitFont*font8;
        font8 = (Gfx8BitFont*)font;
@@ -672,6 +673,7 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y,
           swfoutput_drawchar(&output, x1, y1, enc[c], c);
        else {
           msg("<warning> couldn't get name for character %02x from Encoding", c);
+          swfoutput_drawchar(&output, x1, y1, "<unknown>", c);
        }
     }
 }
@@ -708,6 +710,7 @@ void SWFOutputDev::startPage(int pageNum, GfxState *state)
   state->transform(state->getX1(),state->getY1(),&x1,&y1);
   state->transform(state->getX2(),state->getY2(),&x2,&y2);
   if(!outputstarted) {
+    msg("<verbose> Bounding box is (%f,%f)-(%f,%f)", x1,y1,x2,y2);
     swfoutput_init(&output, swffilename, abs((int)(x2-x1)),abs((int)(y2-y1)));
     outputstarted = 1;
   }
@@ -888,6 +891,8 @@ int SWFOutputDev::searchT1Font(char*name)
     int i;
     int mapid=-1;
     char*filename=0;
+       
+    msg("<verbose> SearchT1Font(%s)", name);
 
     for(i=0;i<sizeof(pdf2t1map)/sizeof(mapping);i++) 
     {
@@ -971,6 +976,19 @@ 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;
@@ -981,7 +999,11 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font)
       Type1CFontFile *cvt;
       Ref embRef;
       Object refObj, strObj;
+#ifdef WIN32
+      tmpFileName = tempFile("tmpfont");
+#else
       tmpFileName = "/tmp/tmpfont";
+#endif
       int ret;
 
       ret = font->getEmbeddedFontID(&embRef);
@@ -1061,7 +1083,7 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font)
              "-pft",
 #endif
              "-b", tmpFileName, name2};
-         msg("<verbose> Invoking ttf2pt1...");
+         msg("<verbose> Invoking %s %s %s %s %s %s",a[0],a[1],a[2],a[3],a[4],a[5]);
          ttf2pt1_main(6,a);
          unlink(tmpFileName);
          sprintf(name2,"%s.pfb",tmp);
@@ -1277,7 +1299,7 @@ void SWFOutputDev::updateFont(GfxState *state)
     if (gfxFont->getType() == fontType1 ||
        gfxFont->getType() == fontType1C ||
        gfxFont->getType() == fontTrueType ||
-       gfxFont->getType() == fontCIDType2) 
+       gfxFont->getType() == fontCIDType2)
     {
        fileName = writeEmbeddedFontToFile(xref, gfxFont);
        if(!fileName) {
@@ -1287,7 +1309,7 @@ void SWFOutputDev::updateFont(GfxState *state)
        }
        this->t1id = T1_AddFont(fileName);
        if(this->t1id<0) {
-         msg("<error> Couldn't load font from file");
+         msg("<error> Couldn't load font from file %s", fileName);
          showFontError(gfxFont,0);
          unlinkfont(fileName);
          return ;