X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=2f4a2cf05bcd19937dd315ae4b43eb2b719ae3cd;hb=ad60d7e0a361c58fc9872753cfb872c3cc54b82f;hp=2d80cb24e2e7c3fe3b1e51e190f2961151e911c5;hpb=580c48fef10df9184cf2728338e89f7db0fef2f5;p=swftools.git diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 2d80cb2..2f4a2cf 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -1416,10 +1416,35 @@ 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); + 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) { + int space = this->current_fontinfo->space_char; + if(config_extrafontdata && space>=0 && m.m00 && !m.m01) { + /* space char detection */ + if(last_char_gfxfont == current_gfxfont && + last_char_y == m.ty && + !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", + m.tx-expected_x, + (m.tx-expected_x)/m.m00, + last_char, glyphid); + gfxmatrix_t m2 = m; + m2.tx = expected_x + (m.tx - expected_x - current_gfxfont->glyphs[space].advance*m.m00)/2; + if(m2.tx < expected_x) m2.tx = expected_x; + device->drawchar(device, current_gfxfont, space, &col, &m2); + } + } + last_char_gfxfont = current_gfxfont; + last_char = glyphid; + last_char_x = m.tx; + last_char_y = m.ty; + last_char_was_space = GLYPH_IS_SPACE(¤t_gfxfont->glyphs[glyphid]); + } device->drawchar(device, current_gfxfont, glyphid, &col, &m); } else { msg(" Drawing glyph %d as shape", charid); @@ -1605,6 +1630,8 @@ void GFXOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, doubl states[statepos].dashPattern = 0; states[statepos].dashLength = 0; states[statepos].dashStart = 0; + + this->last_char_gfxfont = 0; } @@ -1850,6 +1877,13 @@ void GFXOutputDev::restoreState(GfxState *state) { } if(states[statepos].state!=state) { msg(" bad state nesting"); + if(verbose) { + int t; + for(t=0;t<=statepos;t++) { + printf("%08x ", states[t].state); + } + printf("\n"); + } exit(1); } states[statepos].state=0; @@ -2627,11 +2661,7 @@ void GFXOutputDev::endTransparencyGroup(GfxState *state) this->device = states[statepos].olddevice; if(!this->device) { - msg(" Bad state nesting in transparency group"); - msg(" Notice: this is a known problem, which will be fixed in 0.9.1"); - msg(" In the meantime, please convert the file with -s poly2bitmap"); - restoreState(state); - this->device = states[statepos].olddevice; + msg(" Invalid state nesting"); } states[statepos].olddevice = 0;