X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=pdf2swf%2FSWFOutputDev.cc;h=0769800f9a77208412e793e76528714e97968a7a;hb=ae8a7acad94dd9c9d7b5d477ce96c5674935ff9b;hp=fe6f296858dfb9219933974d3437fdf7d4f4bb88;hpb=eefb969ffecd09cf1a1b1801e9932685b4804539;p=swftools.git diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index fe6f296..0769800 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -90,7 +90,7 @@ static int pagepos = 0; /* config */ static double caplinewidth = 3.0; -static int zoom = 72; /* xpdf: 86 */ +static double zoom = 72; /* xpdf: 86 */ static int forceType0Fonts = 1; static void printInfoString(Dict *infoDict, char *key, char *fmt); @@ -273,6 +273,7 @@ public: int user_clipx1,user_clipx2,user_clipy1,user_clipy2; gfxline_t* current_text_stroke; + gfxline_t* current_text_clip; char* current_font_id; gfxfont_t* current_gfxfont; gfxmatrix_t current_font_matrix; @@ -361,6 +362,7 @@ SWFOutputDev::SWFOutputDev() user_clipx2 = 0; user_clipy2 = 0; current_text_stroke = 0; + current_text_clip = 0; fontlist = 0; memset(&output, 0, sizeof(output)); // printf("SWFOutputDev::SWFOutputDev() \n"); @@ -737,6 +739,8 @@ void SWFOutputDev::strokeGfxline(GfxState *state, gfxline_t*line) double * ldash = 0; state->getLineDash(&ldash, &dashnum, &dashphase); + gfxline_t*line2 = 0; + if(dashnum && ldash) { float * dash = (float*)malloc(sizeof(float)*(dashnum+1)); int t; @@ -753,8 +757,7 @@ void SWFOutputDev::strokeGfxline(GfxState *state, gfxline_t*line) dump_outline(line); } - gfxline_t*line2 = gfxtool_dash_line(line, dash, dashphase); - gfxline_free(line); + line2 = gfxtool_dash_line(line, dash, dashphase); line = line2; msg(" After dashing:"); } @@ -774,6 +777,9 @@ void SWFOutputDev::strokeGfxline(GfxState *state, gfxline_t*line) } swfoutput_drawgfxline(&output, line, width, &col, capType, joinType, miterLimit); + + if(line2) + gfxline_free(line2); } gfxcolor_t getFillColor(GfxState * state) @@ -978,8 +984,9 @@ int getGfxCharID(gfxfont_t*font, int charnr, char *charname, int u) void SWFOutputDev::beginString(GfxState *state, GString *s) { int render = state->getRender(); - if(current_text_stroke) + if(current_text_stroke) { msg(" Error: Incompatible change of text rendering to %d while inside cliptext", render); + } msg(" beginString(%s) render=%d", makeStringPrintable(s->getCString()), render); double m11,m21,m12,m22; @@ -1081,7 +1088,15 @@ void SWFOutputDev::drawChar(GfxState *state, double x, double y, gfxline_t*glyph = current_gfxfont->glyphs[charid].line; gfxline_t*tglyph = gfxline_clone(glyph); gfxline_transform(tglyph, &m); - current_text_stroke = gfxline_append(current_text_stroke, tglyph); + if((render&3) != RENDER_INVISIBLE) { + gfxline_t*add = gfxline_clone(tglyph); + current_text_stroke = gfxline_append(current_text_stroke, add); + } + if(render&RENDER_CLIP) { + gfxline_t*add = gfxline_clone(tglyph); + current_text_clip = gfxline_append(current_text_clip, add); + } + gfxline_free(tglyph); } } @@ -1097,12 +1112,16 @@ void SWFOutputDev::endString(GfxState *state) now (as there may be texts of other rendering modes in this text object)- clipping objects have to wait until endTextObject, however */ - if(render == RENDER_FILLSTROKE) { + if((render&3) == RENDER_FILL) { + fillGfxLine(state, current_text_stroke); + gfxline_free(current_text_stroke); + current_text_stroke = 0; + } else if((render&3) == RENDER_FILLSTROKE) { fillGfxLine(state, current_text_stroke); strokeGfxline(state, current_text_stroke); gfxline_free(current_text_stroke); current_text_stroke = 0; - } else if(render == RENDER_STROKE) { + } else if((render&3) == RENDER_STROKE) { strokeGfxline(state, current_text_stroke); gfxline_free(current_text_stroke); current_text_stroke = 0; @@ -1113,22 +1132,14 @@ void SWFOutputDev::endString(GfxState *state) void SWFOutputDev::endTextObject(GfxState *state) { int render = state->getRender(); - msg(" endTextObject() render=%d textstroke=%08x", render, current_text_stroke); + msg(" endTextObject() render=%d textstroke=%08x clipstroke=%08x", render, current_text_stroke, current_text_clip); if(states[statepos].textRender != render) msg(" Internal error: drawChar.render!=beginString.render"); - if(current_text_stroke) { - if((render&3) == RENDER_FILL || (render&3) == RENDER_FILLSTROKE) { - fillGfxLine(state, current_text_stroke); - } - if((render&3) == RENDER_STROKE || (render&3) == RENDER_FILLSTROKE) { - strokeGfxline(state, current_text_stroke); - } - if((render&4) == RENDER_CLIP) { - clipToGfxLine(state, current_text_stroke); - } - gfxline_free(current_text_stroke); - current_text_stroke = 0; + if(current_text_clip) { + clipToGfxLine(state, current_text_clip); + gfxline_free(current_text_clip); + current_text_clip = 0; } } @@ -1486,7 +1497,8 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) msg(" Collection: %s", c.getCString()); }*/ - if (font->getType() == fontType1C) { + //if (font->getType() == fontType1C) { + if (0) { //font->getType() == fontType1C) { if (!(fontBuf = font->readEmbFontFile(xref, &fontLen))) { fclose(f); msg(" Couldn't read embedded font file"); @@ -2198,7 +2210,7 @@ void pdfswf_setparameter(char*name, char*value) caplinewidth = atof(value); } else if(!strcmp(name, "zoom")) { char buf[80]; - zoom = atoi(value); + zoom = atof(value); sprintf(buf, "%f", (double)jpeg_dpi/(double)zoom); swfoutput_setparameter("jpegsubpixels", buf); sprintf(buf, "%f", (double)ppm_dpi/(double)zoom);