bounding boxes are not required to start at zero anymore.
[swftools.git] / pdf2swf / SWFOutputDev.cc
index 6f7d910..da2899f 100644 (file)
@@ -643,7 +643,7 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y,
     if(_u) 
        u = *_u;
     
-    msg("<debug> drawChar(%f,%f,%f,%f,'%c',%d)\n",x,y,dx,dy,c,u);
+    msg("<debug> drawChar(%f,%f,%f,%f,'%c',%d) CID=%d\n",x,y,dx,dy,c,u, font->isCIDFont());
 
     if(font->isCIDFont()) {
        GfxCIDFont*cfont = (GfxCIDFont*)font;
@@ -660,9 +660,10 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y,
 
        if(name)
           swfoutput_drawchar(&output, x1, y1, name, c);
-       else
+       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;
@@ -708,9 +709,12 @@ void SWFOutputDev::startPage(int pageNum, GfxState *state)
 
   state->transform(state->getX1(),state->getY1(),&x1,&y1);
   state->transform(state->getX2(),state->getY2(),&x2,&y2);
+  if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
+  if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
+
   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)));
+    swfoutput_init(&output, swffilename,(int)x1,(int)y1,(int)y2,(int)y2);
     outputstarted = 1;
   }
   else
@@ -1001,7 +1005,8 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font)
        msg("<error> Couldn't create temporary Type 1 font file");
          return 0;
       }
-      if (font->getType() == fontType1C) {
+      if (font->getType() == fontType1C ||
+         font->getType() == fontCIDType0C) {
        if (!(fontBuf = font->readEmbFontFile(xref, &fontLen))) {
          fclose(f);
          msg("<error> Couldn't read embedded font file");
@@ -1078,7 +1083,7 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font)
              "-b", tmpFileName, name2};
          msg("<verbose> 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);
+         unlink(tmpFileName);
          sprintf(name2,"%s.pfb",tmp);
          tmpFileName = strdup(name2);
       }
@@ -1290,9 +1295,11 @@ void SWFOutputDev::updateFont(GfxState *state)
   GBool embedded = gfxFont->getEmbeddedFontID(&embRef);
   if(embedded) {
     if (gfxFont->getType() == fontType1 ||
+       gfxFont->getType() == fontCIDType0C ||
        gfxFont->getType() == fontType1C ||
        gfxFont->getType() == fontTrueType ||
-       gfxFont->getType() == fontCIDType2)
+       gfxFont->getType() == fontCIDType2
+       )
     {
        fileName = writeEmbeddedFontToFile(xref, gfxFont);
        if(!fileName) {
@@ -1314,6 +1321,7 @@ void SWFOutputDev::updateFont(GfxState *state)
           font directories */
        int newt1id = searchT1Font(fontname);
        if(newt1id<0) {
+           msg("<error> Couldn't find any suitable replacement for %s",fontname);
            showFontError(gfxFont,0);
            fontname = substituteFont(gfxFont, fontname);
        } else
@@ -1335,7 +1343,8 @@ void SWFOutputDev::updateFont(GfxState *state)
   }
 
   if(t1id<0) {
-      showFontError(gfxFont,0);
+      msg("<error> Current font's t1id is %d", t1id);
+      //showFontError(gfxFont,0);
       return;
   }