- msg("<debug> 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 || render == RENDER_INVISIBLE) {
+ msg("<debug> drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%p",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 */
+ 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;
+ float width = this->current_fontinfo->average_advance;
+ if(m.tx - expected_x >= m.m00*width*4/10) {
+ msg("<debug> 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,
+ 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;
+ 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]);
+ }