X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2FSWFOutputDev.cc;h=6f7d910ed24c773620ab44d51fe3687f10f560ee;hb=f7e02fdcc5f94e3129124abb157037d7b54553e9;hp=04676e15b3777de278293432ee1dc414b1a44372;hpb=de33f30e51e402a889d32738dfbbf524fe6412c9;p=swftools.git diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index 04676e1..6f7d910 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -624,8 +624,6 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, double originX, double originY, CharCode c, Unicode *_u, int uLen) { - msg(" drawChar(%f,%f,%f,%f,'%c')\n",x,y,dx,dy,c); - // check for invisible text -- this is used by Acrobat Capture if ((state->getRender() & 3) == 3) return; @@ -640,13 +638,16 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, x1 = x; y1 = y; state->transform(x, y, &x1, &y1); + + Unicode u=0; + if(_u) + u = *_u; + + msg(" drawChar(%f,%f,%f,%f,'%c',%d)\n",x,y,dx,dy,c,u); if(font->isCIDFont()) { GfxCIDFont*cfont = (GfxCIDFont*)font; - Unicode u=0; char*name=0; - if(_u) - u = *_u; if(u) { int t; for(t=0;tgetName()->getCString(), - cfont->getType());*/ if(name) swfoutput_drawchar(&output, x1, y1, name, c); @@ -983,10 +982,10 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) int c; char *fontBuf; int fontLen; - Type1CFontFile *cvt; Ref embRef; Object refObj, strObj; - tmpFileName = "/tmp/tmpfont"; + char namebuf[512]; + tmpFileName = mktmpname(namebuf); int ret; ret = font->getEmbeddedFontID(&embRef); @@ -1008,10 +1007,21 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) msg(" Couldn't read embedded font file"); return 0; } - cvt = new Type1CFontFile(fontBuf, fontLen); + Type1CFontFile *cvt = new Type1CFontFile(fontBuf, fontLen); cvt->convertToType1(f); delete cvt; gfree(fontBuf); + } else if(font->getType() == fontTrueType) { + msg(" writing font using TrueTypeFontFile::writeTTF"); + if (!(fontBuf = font->readEmbFontFile(xref, &fontLen))) { + fclose(f); + msg(" Couldn't read embedded font file"); + return 0; + } + TrueTypeFontFile *cvt = new TrueTypeFontFile(fontBuf, fontLen); + cvt->writeTTF(f); + delete cvt; + gfree(fontBuf); } else { font->getEmbeddedFontID(&embRef); refObj.initRef(embRef.num, embRef.gen); @@ -1055,25 +1065,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); - unlink(tmpFileName); + 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) @@ -1292,7 +1302,7 @@ void SWFOutputDev::updateFont(GfxState *state) } this->t1id = T1_AddFont(fileName); if(this->t1id<0) { - msg(" Couldn't load font from file"); + msg(" Couldn't load font from file %s", fileName); showFontError(gfxFont,0); unlinkfont(fileName); return ;