X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=eb16720be5f3dbff90a70c48c71b2b01db18dd06;hb=d6a3eec37c76d337682ab7bd93f9e06decf670b3;hp=5f4b111161c8c8136dd6df6d4de24a268d28bb1e;hpb=c24ecd9bc561623d9ffedc810f719aede47b3f00;p=swftools.git diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 5f4b111..eb16720 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -69,6 +69,10 @@ #include "../devices/ops.h" #include "../devices/arts.h" #include "../devices/render.h" + +#include "../art/libart.h" +#include "../devices/artsutils.c" + #include "../png.h" #include "fonts.h" @@ -191,7 +195,7 @@ GFXOutputState::GFXOutputState() { GBool GFXOutputDev::interpretType3Chars() { - return gTrue; + return this->do_interpretType3Chars; } typedef struct _drawnchar @@ -269,6 +273,7 @@ GFXOutputDev::GFXOutputDev(parameter_t*p) this->pagepos = 0; this->config_use_fontconfig=1; this->config_break_on_warning=0; + this->do_interpretType3Chars = gTrue; this->parameters = p; @@ -276,14 +281,23 @@ GFXOutputDev::GFXOutputDev(parameter_t*p) /* configure device */ while(p) { - if(!strcmp(p->name,"fontconfig")) { - this->config_use_fontconfig = atoi(p->value); - } else if(!strcmp(p->name,"breakonwarning")) { - this->config_break_on_warning = atoi(p->value); - } + setParameter(p->name, p->value); p = p->next; } }; + +void GFXOutputDev::setParameter(char*key, char*value) +{ + if(!strcmp(key,"rawtext")) { + this->do_interpretType3Chars = atoi(value)^1; + } else if(!strcmp(key,"breakonwarning")) { + this->config_break_on_warning = atoi(value); + } else if(!strcmp(key,"fontconfig")) { + this->config_use_fontconfig = atoi(value); + } else { + msg(" Ignored parameter: %s=%s", key, value); + } +} void GFXOutputDev::setDevice(gfxdevice_t*dev) { @@ -485,7 +499,7 @@ static void showFontError(GfxFont*font, int nr) else if(nr == 1) msg(" The following font caused problems (substituting):"); else if(nr == 2) - msg(" The following Type 3 Font will be rendered as bitmap:"); + msg(" The following Type 3 Font will be rendered as graphics:"); dumpFontInfo("", font); } @@ -651,7 +665,9 @@ GBool GFXOutputDev::useShadedFills() return gFalse; } -void GFXOutputDev::strokeGfxline(GfxState *state, gfxline_t*line) +#define STROKE_FILL 1 +#define STROKE_CLIP 2 +void GFXOutputDev::strokeGfxline(GfxState *state, gfxline_t*line, int flags) { int lineCap = state->getLineCap(); // 0=butt, 1=round 2=square int lineJoin = state->getLineJoin(); // 0=miter, 1=round 2=bevel @@ -719,9 +735,23 @@ void GFXOutputDev::strokeGfxline(GfxState *state, gfxline_t*line) ); dump_outline(line); } - - //swfoutput_drawgfxline(output, line, width, &col, capType, joinType, miterLimit); - device->stroke(device, line, width, &col, capType, joinType, miterLimit); + + if(flags&STROKE_FILL) { + ArtSVP* svp = gfxstrokeToSVP(line, width, capType, joinType, miterLimit); + gfxline_t*gfxline = SVPtogfxline(svp); + if(flags&STROKE_CLIP) { + device->startclip(device, gfxline); + states[statepos].clipping++; + } else { + device->fill(device, gfxline, &col); + } + free(gfxline); + art_svp_free(svp); + } else { + if(flags&STROKE_CLIP) + msg(" Stroke&clip not supported at the same time"); + device->stroke(device, line, width, &col, capType, joinType, miterLimit); + } if(line2) gfxline_free(line2); @@ -784,6 +814,13 @@ void GFXOutputDev::eoClip(GfxState *state) states[statepos].clipping++; gfxline_free(line); } +void GFXOutputDev::clipToStrokePath(GfxState *state) +{ + GfxPath * path = state->getPath(); + gfxline_t*line= gfxPath_to_gfxline(state, path, 0, user_movex + clipmovex, user_movey + clipmovey); + strokeGfxline(state, line, STROKE_FILL|STROKE_CLIP); + gfxline_free(line); +} void GFXOutputDev::endframe() { @@ -791,8 +828,6 @@ void GFXOutputDev::endframe() device->endclip(device); outer_clip_box = 0; } - - device->endpage(device); } void GFXOutputDev::finish() @@ -872,6 +907,8 @@ char* makeStringPrintable(char*str) int getGfxCharID(gfxfont_t*font, int charnr, char *charname, int u) { char*uniname = 0; + if(!font) + return charnr; if(u>0) { int t; /* find out char name from unicode index @@ -982,7 +1019,7 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, Gushort *CIDToGIDMap = 0; GfxFont*font = state->getFont(); - if(font->getType() == fontType3) { + if(font->getType() == fontType3 && do_interpretType3Chars) { /* type 3 chars are passed as graphics */ msg(" type3 char at %f/%f", x, y); return; @@ -1084,11 +1121,11 @@ void GFXOutputDev::endString(GfxState *state) current_text_stroke = 0; } else if((render&3) == RENDER_FILLSTROKE) { fillGfxLine(state, current_text_stroke); - strokeGfxline(state, current_text_stroke); + strokeGfxline(state, current_text_stroke,0); gfxline_free(current_text_stroke); current_text_stroke = 0; } else if((render&3) == RENDER_STROKE) { - strokeGfxline(state, current_text_stroke); + strokeGfxline(state, current_text_stroke,0); gfxline_free(current_text_stroke); current_text_stroke = 0; } @@ -1127,6 +1164,16 @@ GBool GFXOutputDev::beginType3Char(GfxState *state, double x, double y, double d { msg(" beginType3Char %d, %08x, %d", code, *u, uLen); type3active = 1; + + /*int t; + + gfxcolor_t col={255,0,0,0}; + gfxmatrix_t m = {1,0,0, 0,1,0}; + + for(t=0;tdrawchar(device, 0, u[t], &col, &m); + }*/ + /* the character itself is going to be passed using the draw functions */ return gFalse; /* gTrue= is_in_cache? */ } @@ -2423,7 +2470,7 @@ void GFXOutputDev::stroke(GfxState *state) GfxPath * path = state->getPath(); gfxline_t*line= gfxPath_to_gfxline(state, path, 0, user_movex + clipmovex, user_movey + clipmovey); - strokeGfxline(state, line); + strokeGfxline(state, line, 0); gfxline_free(line); } @@ -2784,6 +2831,8 @@ void GFXOutputDev::clearSoftMask(GfxState *state) #endif int width = (int)bbox.xmax,height = (int)bbox.ymax; + if(width<=0 || height<=0) + return; gfxdevice_t belowrender; gfxdevice_render_init(&belowrender);