X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=2c90c92d460059349d8162f2c81f7457ddc3ba4e;hp=2d80cb24e2e7c3fe3b1e51e190f2961151e911c5;hb=727449f065760e1d99735f44638c25678cd8bc52;hpb=9188f342f67f399dbb7857dd1970ab44a8c24138 diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 2d80cb2..2c90c92 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; }