From 737f22a391a278758e81628cf7180e792381f7bb Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Tue, 21 Aug 2012 21:44:48 +0200 Subject: [PATCH] leave space for illegal unicodes --- src/HTMLRenderer/text.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc index 8d80aa2..83af78c 100644 --- a/src/HTMLRenderer/text.cc +++ b/src/HTMLRenderer/text.cc @@ -190,20 +190,34 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s) ++nSpaces; } - if(uLen > 0) + if((uLen > 0) && (all_of(u, u+uLen, isLegalUnicode))) { - if(all_of(u, u+uLen, isLegalUnicode)) - outputUnicodes(html_fout, u, uLen); + outputUnicodes(html_fout, u, uLen); + dx += dx1; + dy += dy1; + } + else + { + // TODO: consider horiz scaling + double target = dx1 + state->getCharSpace(); + if(n == 1 && *p == ' ') + target += state->getWordSpace(); + + double w; + auto wid = install_whitespace(target * draw_scale, w); + html_fout << format("%2%") % wid % (target > 0 ? " " : ""); + dx += target; + dy += dy1; } - dx += dx1; - dy += dy1; ++nChars; p += n; len -= n; } + // TODO, horiz_scaling is merged into ctm now, + // so the coordinate system is ugly dx = (dx * state->getFontSize() + nChars * state->getCharSpace() + nSpaces * state->getWordSpace()) * state->getHorizScaling();