X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=bdd42fbb7886dad5ec8fdd3a1b9e1412ebbb3ea1;hb=c463a165247bcc2d902f1af1ea0f5566d3bef942;hp=0f070ac062d2b9b81bb486a604bf952a4c2aeb60;hpb=4499caa9287f6ad9b1c96e007504478c1f6089b5;p=swftools.git diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 0f070ac..bdd42fb 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -31,9 +31,6 @@ #ifdef HAVE_SYS_STAT_H #include #endif -#ifdef HAVE_FONTCONFIG -#include -#endif //xpdf header files #include "config.h" #include "gfile.h" @@ -338,8 +335,12 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) return GlobalParams::getDisplayFont(fontName); } -GFXOutputDev::GFXOutputDev(parameter_t*p) +GFXOutputDev::GFXOutputDev(InfoOutputDev*info, PDFDoc*doc) { + this->info = info; + this->doc = doc; + this->xref = doc->getXRef(); + this->jpeginfo = 0; this->textmodeinfo = 0; this->linkinfo = 0; @@ -363,52 +364,39 @@ GFXOutputDev::GFXOutputDev(parameter_t*p) this->pages = 0; this->pagebuflen = 0; this->pagepos = 0; - this->config_use_fontconfig=1; this->config_break_on_warning=0; this->config_remapunicode=0; this->config_transparent=0; this->config_extrafontdata = 0; - this->parameters = p; - this->gfxfontlist = gfxfontlist_create(); memset(states, 0, sizeof(states)); - - /* configure device */ - while(p) { - setParameter(p->name, p->value); - p = p->next; - } }; void GFXOutputDev::setParameter(const char*key, const char*value) { if(!strcmp(key,"breakonwarning")) { this->config_break_on_warning = atoi(value); - } else if(!strcmp(key,"fontconfig")) { - this->config_use_fontconfig = atoi(value); } else if(!strcmp(key,"remapunicode")) { this->config_remapunicode = atoi(value); } else if(!strcmp(key,"transparent")) { this->config_transparent = atoi(value); } else if(!strcmp(key,"extrafontdata")) { this->config_extrafontdata = atoi(value); + } else if(!strcmp(key,"help")) { + printf("\nPDF layer options:\n"); + printf("breakonwarning=0/1 Abort conversion if graphic objects are found which\n"); + printf(" are not 100%% supported\n"); + printf("transparent=0/1 Make PDF transparent (alpha background)\n"); + printf("extrafontdata=0/1 Store Type3 characters and capture characters\n"); } + } void GFXOutputDev::setDevice(gfxdevice_t*dev) { - parameter_t*p = this->parameters; - - /* pass parameters to output device */ this->device = dev; - if(this->device) { - while(p) { - this->device->setparameter(this->device, p->name, p->value); - p = p->next; - } - } } void GFXOutputDev::setMove(int x,int y) @@ -657,6 +645,10 @@ GBool GFXOutputDev::needNonText() void GFXOutputDev::endPage() { msg(" endPage"); + if(outer_clip_box) { + device->endclip(device); + outer_clip_box = 0; + } } #define STROKE_FILL 1 @@ -826,14 +818,6 @@ void GFXOutputDev::clipToStrokePath(GfxState *state) gfxline_free(line); } -void GFXOutputDev::endframe() -{ - if(outer_clip_box) { - device->endclip(device); - outer_clip_box = 0; - } -} - void GFXOutputDev::finish() { if(outer_clip_box) { @@ -852,7 +836,7 @@ GFXOutputDev::~GFXOutputDev() free(this->pages); this->pages = 0; } - gfxfontlist_free(this->gfxfontlist); + gfxfontlist_free(this->gfxfontlist, 1);this->gfxfontlist = 0; }; GBool GFXOutputDev::upsideDown() { @@ -866,12 +850,6 @@ GBool GFXOutputDev::useDrawChar() const char*renderModeDesc[]= {"fill", "stroke", "fill+stroke", "invisible", "clip+fill", "stroke+clip", "fill+stroke+clip", "clip"}; -#define RENDER_FILL 0 -#define RENDER_STROKE 1 -#define RENDER_FILLSTROKE 2 -#define RENDER_INVISIBLE 3 -#define RENDER_CLIP 4 - static char tmp_printstr[4096]; char* makeStringPrintable(char*str) { @@ -965,6 +943,8 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, // check for invisible text -- this is used by Acrobat Capture if (render == RENDER_INVISIBLE) { col.a = 0; + if(!config_extrafontdata) + return; } GfxFont*font = state->getFont(); @@ -1085,7 +1065,7 @@ GBool GFXOutputDev::beginType3Char(GfxState *state, double x, double y, double d msg(" Invalid charid %d for font %s", charid, current_font_id); return gFalse; } - gfxcolor_t col={128,0,0,0}; + gfxcolor_t col={0,0,0,0}; CharCode glyphid = current_fontinfo->glyphs[charid]->glyphid; device->drawchar(device, current_gfxfont, glyphid, &col, &m); } @@ -1106,18 +1086,6 @@ void GFXOutputDev::endType3Char(GfxState *state) msg(" endType3Char"); } -void GFXOutputDev::startFrame(int width, int height) -{ - if(outer_clip_box) { - device->endclip(device); - outer_clip_box = 0; - } - - device->startpage(device, width, height); - this->width = width; - this->height = height; -} - void GFXOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2) { this->currentpage = pageNum; @@ -1450,11 +1418,6 @@ void GFXOutputDev::updateStrokeColor(GfxState *state) state->getStrokeRGB(&rgb); } -void GFXOutputDev::setXRef(PDFDoc*doc, XRef *xref) -{ - this->doc = doc; - this->xref = xref; -} gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src) { @@ -1465,7 +1428,7 @@ gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src) memset(font->glyphs, 0, sizeof(gfxglyph_t)*src->num_glyphs); font->id = strdup(getFontID(xpdffont)); int t; - double quality = (INTERNAL_FONT_SIZE * 0.05) / src->max_size; + double quality = (INTERNAL_FONT_SIZE * 20) / src->max_size; double scale = 1; //printf("%d glyphs\n", font->num_glyphs); font->num_glyphs = 0; @@ -1547,6 +1510,9 @@ void GFXOutputDev::updateFont(GfxState *state) } this->current_fontinfo = this->info->getFont(id); + if(!this->current_fontinfo) { + msg(" Internal Error: no fontinfo for font %s\n", id); + } if(!this->current_fontinfo->seen) { dumpFontInfo("", gfxFont); } @@ -1554,7 +1520,8 @@ void GFXOutputDev::updateFont(GfxState *state) gfxfont_t*font = gfxfontlist_findfont(this->gfxfontlist,id); if(!font) { font = createGfxFont(gfxFont, current_fontinfo); - gfxfontlist_addfont(this->gfxfontlist, font); + font->id = strdup(id); + this->gfxfontlist = gfxfontlist_addfont(this->gfxfontlist, font); device->addfont(device, font); } current_gfxfont = font; @@ -2216,13 +2183,11 @@ void GFXOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, GBool forSoftMask) { const char*colormodename = ""; - BBox rect = mkBBox(state, bbox, this->width, this->height); if(blendingColorSpace) { colormodename = GfxColorSpace::getColorSpaceModeName(blendingColorSpace->getMode()); } dbg("beginTransparencyGroup %.1f/%.1f/%.1f/%.1f %s isolated=%d knockout=%d forsoftmask=%d", bbox[0],bbox[1],bbox[2],bbox[3], colormodename, isolated, knockout, forSoftMask); - dbg("using clipping rect %f/%f/%f/%f\n", rect.posx,rect.posy,rect.width,rect.height); msg(" beginTransparencyGroup %.1f/%.1f/%.1f/%.1f %s isolated=%d knockout=%d forsoftmask=%d", bbox[0],bbox[1],bbox[2],bbox[3], colormodename, isolated, knockout, forSoftMask); states[statepos].createsoftmask |= forSoftMask;