X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2FSWFOutputDev.cc;h=885733acc83726743c3cd6c0d3b841dd185c7810;hb=c35e8732e32009c9e2e8067e78c6f41502a79450;hp=d5d0d94f2c4d640172f1f48173685fe9222c19d1;hpb=d92d0a7daa8794b189aff0673da002eb2f26cb2e;p=swftools.git diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index d5d0d94..885733a 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -132,7 +132,7 @@ public: // Does this device use drawChar() or drawString()? virtual GBool useDrawChar(); - virtual GBool interpretType3Chars() {return gFalse;} + virtual GBool interpretType3Chars() {return gTrue;} //----- initialization and control @@ -176,9 +176,9 @@ public: virtual void beginString(GfxState *state, GString *s) ; virtual void endString(GfxState *state) ; virtual void drawChar(GfxState *state, double x, double y, - double dx, double dy, Guchar c) ; - virtual void drawChar16(GfxState *state, double x, double y, - double dx, double dy, int c) ; + double dx, double dy, + double originX, double originY, + CharCode code, Unicode *u, int uLen); //----- image drawing virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, @@ -186,7 +186,11 @@ public: GBool inlineImg); virtual void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, - GBool inlineImg); + int *maskColors, GBool inlineImg); + + virtual GBool beginType3Char(GfxState *state, + CharCode code, Unicode *u, int uLen); + virtual void endType3Char(GfxState *state); private: void drawGeneralImage(GfxState *state, Object *ref, Stream *str, @@ -206,6 +210,8 @@ public: int linkinfo; // did we write "File contains links" yet? int ttfinfo; // did we write "File contains TrueType Fonts" yet? + int type3active; // are we between beginType3()/endType3()? + GfxState *laststate; }; @@ -339,7 +345,7 @@ void showFontError(GfxFont*font, int nr) else if(nr == 1) logf(" The following font caused problems (substituting):"); else if(nr == 2) - logf(" This document contains Type 3 Fonts: (some text may be incorrectly displayed)"); + logf(" The following Type 3 Font will be rendered as bitmap:"); dumpFontInfo("", font); } @@ -355,7 +361,7 @@ void dumpFontInfo(char*loglevel, GfxFont*font) if(gstr) logf("%sTag: %s\n", loglevel, FIXNULL(gstr->getCString())); - //if(font->is16Bit()) logf("%sis 16 bit\n", loglevel); //FIXME: not existing in xpdf 1.01 + if(font->isCIDFont()) logf("%sis CID font\n", loglevel); GfxFontType type=font->getType(); switch(type) { @@ -413,9 +419,11 @@ SWFOutputDev::SWFOutputDev() ttfinfo = 0; linkinfo = 0; pbminfo = 0; + type3active = 0; clippos = 0; clipping[clippos] = 0; outputstarted = 0; + xref = 0; // printf("SWFOutputDev::SWFOutputDev() \n"); }; @@ -566,7 +574,10 @@ void SWFOutputDev::beginString(GfxState *state, GString *s) } int charcounter = 0; -void SWFOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, Guchar c) +void SWFOutputDev::drawChar(GfxState *state, double x, double y, + double dx, double dy, + double originX, double originY, + CharCode c, Unicode *u, int uLen) { logf(" drawChar(%f,%f,%f,%f,'%c')\n",x,y,dx,dy,c); // check for invisible text -- this is used by Acrobat Capture @@ -575,7 +586,11 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, double dx, doub GfxFont*font = state->getFont(); Gfx8BitFont*font8; if(font->isCIDFont()) { - logf(" CID Font\n"); + logf(" CID Font"); + return; + } + if(font->getType() == fontType3) { + /* type 3 chars are passed primarily as graphics */ return; } font8 = (Gfx8BitFont*)font; @@ -594,17 +609,28 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, double dx, doub } } -void SWFOutputDev::drawChar16(GfxState *state, double x, double y, double dx, double dy, int c) -{ - printf(" drawChar16(%f,%f,%f,%f,%08x)\n",x,y,dx,dy,c); - exit(1); -} - void SWFOutputDev::endString(GfxState *state) { logf(" endstring\n"); } + +GBool SWFOutputDev::beginType3Char(GfxState *state, + CharCode code, Unicode *u, int uLen) +{ + logf(" beginType3Char %d, %08x, %d", code, *u, uLen); + type3active = 1; + /* the character itself is going to be passed using + drawImageMask() */ + return gFalse; +} + +void SWFOutputDev::endType3Char(GfxState *state) +{ + type3active = 0; + logf(" endType3Char"); +} + void SWFOutputDev::startPage(int pageNum, GfxState *state) { double x1,y1,x2,y2; @@ -1135,7 +1161,7 @@ void SWFOutputDev::updateFont(GfxState *state) Ref embRef; GBool embedded = gfxFont->getEmbeddedFontID(&embRef); if(embedded) { - if (//!gfxFont->is16Bit() && FIXME: not in xpdf 1.01 + if (!gfxFont->isCIDFont() && (gfxFont->getType() == fontType1 || gfxFont->getType() == fontType1C || gfxFont->getType() == fontTrueType)) { @@ -1235,10 +1261,12 @@ void SWFOutputDev::drawGeneralImage(GfxState *state, Object *ref, Stream *str, state->transform(1, 1, &x4, &y4); if(!pbminfo && !(str->getKind()==strDCT)) { - logf(" file contains pbm pictures %s",mask?"(masked)":""); + if(!type3active) { + logf(" file contains pbm pictures %s",mask?"(masked)":""); + pbminfo = 1; + } if(mask) logf(" drawing %d by %d masked picture\n", width, height); - pbminfo = 1; } if(!jpeginfo && (str->getKind()==strDCT)) { logf(" file contains jpeg pictures"); @@ -1401,11 +1429,13 @@ void SWFOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, } void SWFOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, - int width, int height, - GfxImageColorMap *colorMap, GBool inlineImg) + int width, int height, GfxImageColorMap *colorMap, + int *maskColors, GBool inlineImg) { - logf(" drawImage %dx%d, %s, inline=%d", width, height, - colorMap?"colorMap":"no colorMap", inlineImg); + logf(" drawImage %dx%d, %s %s, inline=%d", width, height, + colorMap?"colorMap":"no colorMap", + maskColors?"maskColors":"no maskColors", + inlineImg); if(colorMap) logf(" colorMap pixcomps:%d bits:%d mode:%d\n", colorMap->getNumPixelComps(), colorMap->getBits(),colorMap->getColorSpace()->getMode()); @@ -1461,8 +1491,6 @@ void pdfswf_init(char*filename, char*userPassword) GString *fileName = new GString(filename); GString *userPW; Object info; - // init error file - //errorInit(); FIXME xpdf 1.01 // read config file globalParams = new GlobalParams(""); @@ -1529,6 +1557,7 @@ void pdfswf_init(char*filename, char*userPassword) output = new SWFOutputDev(); + output->startDoc(doc->getXRef()); } void pdfswf_drawonlyshapes()