X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=b450e546cb84c23a6a155da6088c07634697cfc2;hp=441a92b003e72bd1f4c2779baba3af01c311b43c;hb=2391d7ae5d8a145a250a8b80ab8c93ba74eba030;hpb=711659af8759d3939ef395e04f81191a43049a19 diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 441a92b..b450e54 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -335,6 +335,19 @@ GFXGlobalParams::~GFXGlobalParams() #endif } #ifdef HAVE_FONTCONFIG +static char stralphacmp(const char*s1, const char*s2) +{ + while(*s1 && *s2) { + /* skip over space, minus, comma etc. */ + while(*s1>=32 && *s1<=63) s1++; + while(*s2>=32 && *s2<=63) s2++; + if(*s1!=*s2) + break; + s1++;s2++; + } + return *s1 - *s2; +} + static char fc_ismatch(FcPattern*match, char*family, char*style) { char*fcfamily=0,*fcstyle=0,*fcfullname=0,*filename=0; @@ -348,7 +361,7 @@ static char fc_ismatch(FcPattern*match, char*family, char*style) if(scalable!=FcTrue || outline!=FcTrue) return 0; - if (!strcasecmp(fcfamily, family)) { + if (!stralphacmp(fcfamily, family)) { msg(" Font %s-%s (%s) is a match for %s%s%s", fcfamily, fcstyle, filename, family, style?"-":"", style?style:""); return 1; } else { @@ -612,6 +625,7 @@ GFXOutputDev::GFXOutputDev(InfoOutputDev*info, PDFDoc*doc) this->config_drawonlyshapes = 0; this->config_disable_polygon_conversion = 0; this->config_multiply = 1; + this->config_linkdatafile = 0; this->page2page = 0; this->num_pages = 0; @@ -630,6 +644,8 @@ void GFXOutputDev::setParameter(const char*key, const char*value) this->config_drawonlyshapes = atoi(value); } else if(!strcmp(key,"extrafontdata")) { this->config_extrafontdata = atoi(value); + } else if(!strcmp(key,"linkdatafile")) { + this->config_linkdatafile = strdup(value); } else if(!strcmp(key,"convertgradients")) { this->config_convertgradients = atoi(value); } else if(!strcmp(key,"multiply")) { @@ -1426,10 +1442,13 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, gfxmatrix_t m = this->current_font_matrix; this->transformXY(state, x-originX, y-originY, &m.tx, &m.ty); //m.tx += originX; m.ty += originY; - - msg(" drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%08x",m.tx,m.ty,(charid&127)>=32?charid:'?', charid, u, uLen, font->isCIDFont(), render, glyphid, current_gfxfont); - if((render == RENDER_FILL && !config_drawonlyshapes) || render == RENDER_INVISIBLE) { + msg(" drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%08x",m.tx,m.ty,(charid&127)>=32?charid:'?', charid, u, uLen, font->isCIDFont(), render, glyphid, current_gfxfont); + + if((render == RENDER_FILL && !config_drawonlyshapes) || + (render == RENDER_FILLSTROKE && state->getTransformedLineWidth()<1.0) || + (render == RENDER_INVISIBLE)) { + int space = this->current_fontinfo->space_char; if(config_extrafontdata && space>=0 && m.m00 && !m.m01) { /* space char detection */ @@ -1438,10 +1457,11 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, !last_char_was_space) { double expected_x = last_char_x + current_gfxfont->glyphs[last_char].advance*m.m00; int space = this->current_fontinfo->space_char; - if(m.tx - expected_x >= m.m00*64) { - msg(" There's a %f (%f) pixel gap between char %d and char %d, I'm inserting a space here", + float width = this->current_fontinfo->average_advance; + if(m.tx - expected_x >= m.m00*width*4/10) { + msg(" There's a %f pixel gap between char %d and char %d (expected no more than %f), I'm inserting a space here", m.tx-expected_x, - (m.tx-expected_x)/m.m00, + width*m.m00*4/10, last_char, glyphid); gfxmatrix_t m2 = m; m2.tx = expected_x + (m.tx - expected_x - current_gfxfont->glyphs[space].advance*m.m00)/2; @@ -1462,6 +1482,7 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, msg(" Some texts will be rendered as shape"); gfxglobals->textmodeinfo = 1; } + gfxline_t*glyph = current_gfxfont->glyphs[glyphid].line; gfxline_t*tglyph = gfxline_clone(glyph); gfxline_transform(tglyph, &m); @@ -1545,10 +1566,11 @@ GBool GFXOutputDev::beginType3Char(GfxState *state, double x, double y, double d gfxmatrix_t m = this->current_font_matrix; this->transformXY(state, 0, 0, &m.tx, &m.ty); - m.m00*=INTERNAL_FONT_SIZE; + + /*m.m00*=INTERNAL_FONT_SIZE; m.m01*=INTERNAL_FONT_SIZE; m.m10*=INTERNAL_FONT_SIZE; - m.m11*=INTERNAL_FONT_SIZE; + m.m11*=INTERNAL_FONT_SIZE;*/ if(!current_fontinfo || (unsigned)charid >= current_fontinfo->num_glyphs || !current_fontinfo->glyphs[charid]) { msg(" Invalid charid %d for font", charid); @@ -1830,8 +1852,13 @@ void GFXOutputDev::processLink(Link *link, Catalog *catalog) else if(s) { device->drawlink(device, points, s); + if(this->config_linkdatafile) { + FILE*fi = fopen(config_linkdatafile, "ab+"); + fprintf(fi, "%s\n", s); + fclose(fi); + } } - + msg(" \"%s\" link to \"%s\" (%d)", type, FIXNULL(s), page); free(s);s=0; } @@ -1890,7 +1917,7 @@ void GFXOutputDev::restoreState(GfxState *state) { if(verbose) { int t; for(t=0;t<=statepos;t++) { - printf("%08x ", states[t].state); + printf("%08x ", (unsigned int)states[t].state); } printf("\n"); } @@ -2018,7 +2045,7 @@ void GFXOutputDev::updateFont(GfxState *state) current_gfxfont = this->current_fontinfo->getGfxFont(); device->addfont(device, current_gfxfont); free(id); - + updateFontMatrix(state); } @@ -2364,38 +2391,18 @@ void GFXOutputDev::drawGeneralImage(GfxState *state, Object *ref, Stream *str, for(t=0;t<256;t++) { pixBuf[0] = t; colorMap->getRGB(pixBuf, &rgb); - - {/*if(maskColors && *maskColors==t) { - msg(" Color %d is transparent", t); - if (imgData->maskColors) { - *alpha = 0; - for (i = 0; i < imgData->colorMap->getNumPixelComps(); ++i) { - if (pix[i] < imgData->maskColors[2*i] || - pix[i] > imgData->maskColors[2*i+1]) { - *alpha = 1; - break; - } - } - } else { - *alpha = 1; - } - if(!*alpha) { - pal[t].r = 0; - pal[t].g = 0; - pal[t].b = 0; - pal[t].a = 0; - } - } else {*/ - pal[t].r = (unsigned char)(colToByte(rgb.r)); - pal[t].g = (unsigned char)(colToByte(rgb.g)); - pal[t].b = (unsigned char)(colToByte(rgb.b)); - pal[t].a = 255;//(U8)(rgb.b * 255 + 0.5); - } + pal[t].r = (unsigned char)(colToByte(rgb.r)); + pal[t].g = (unsigned char)(colToByte(rgb.g)); + pal[t].b = (unsigned char)(colToByte(rgb.b)); + pal[t].a = 255;//(U8)(rgb.b * 255 + 0.5); } for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { imgStr->getPixel(pixBuf); pic[width*y+x] = pal[pixBuf[0]]; + if(maskColors && *maskColors==pixBuf[0]) { + pic[width*y+x].a = 0; + } } } if(maskbitmap) {