diff --git a/bin/pdf2htmlEX b/bin/pdf2htmlEX index 96ba05e..eec482c 100755 --- a/bin/pdf2htmlEX +++ b/bin/pdf2htmlEX @@ -12,7 +12,6 @@ echo -n "Converting fonts: " for f in *.ttf; do if [ -f $f ]; then - cp $f $f.old fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null echo -n "." fi @@ -20,7 +19,6 @@ done for f in *.pfa; do if [ -f $f ]; then - cp $f $f.old fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null rm $f echo -n "." diff --git a/src/BackgroundRenderer.cc b/src/BackgroundRenderer.cc index 2913947..1044a63 100644 --- a/src/BackgroundRenderer.cc +++ b/src/BackgroundRenderer.cc @@ -14,7 +14,7 @@ void BackgroundRenderer::drawChar(GfxState *state, double x, double y, CharCode code, int nBytes, Unicode *u, int uLen) { auto font = state->getFont(); - if((font->getType() == fontType3) || (font->getWMode())) + if((font->getType() == fontType3) || (font->getWMode()) || (uLen == 0)) { SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen); } diff --git a/src/HTMLRenderer.cc b/src/HTMLRenderer.cc index 76047a5..80f4a60 100644 --- a/src/HTMLRenderer.cc +++ b/src/HTMLRenderer.cc @@ -206,6 +206,9 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s) // if the line is still open, try to merge with it if(line_opened) { + //debug + html_fout << ""; + double target = -cur_line_x_offset * draw_scale; if(target > -param->h_eps) { @@ -213,17 +216,17 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s) { double w; auto wid = install_whitespace(target, w); - cur_tx += w / draw_scale; cur_line_x_offset = (w - target) / draw_scale; html_fout << boost::format(" ") % wid; } } else { + //debug + html_fout << ""; + // can we shift left using simple tags? close_cur_line(); - cur_tx = state->getLineX(); - cur_line_x_offset = 0; } } @@ -270,6 +273,8 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s) html_fout << "\">"; line_opened = true; + + cur_line_x_offset = 0; } @@ -691,7 +696,7 @@ void HTMLRenderer::export_remote_font(long long fn_id, const string & suffix, Gf // TODO: this function is called when some font is unable to process, may use the name there as a hint void HTMLRenderer::export_remote_default_font(long long fn_id) { - allcss_fout << boost::format(".f%|1$x|{font-family:sans-serif;color:transparent;}")%fn_id; + allcss_fout << boost::format(".f%|1$x|{font-family:sans-serif;color:transparent;visibility:hidden;}")%fn_id; if(param->readable) allcss_fout << endl; } @@ -802,7 +807,8 @@ void HTMLRenderer::check_state_change(GfxState * state) else { // LineY remains unchanged - cur_line_x_offset += cur_tx - tx; + cur_line_x_offset = cur_tx - tx; + cur_tx = tx; } } diff --git a/src/HTMLRenderer.h b/src/HTMLRenderer.h index 637e77d..a154979 100644 --- a/src/HTMLRenderer.h +++ b/src/HTMLRenderer.h @@ -97,7 +97,11 @@ class HTMLRenderer : public OutputDev virtual void updateTextMat(GfxState * state) { text_mat_changed = true; } virtual void updateCTM(GfxState * state, double m11, double m12, double m21, double m22, double m31, double m32) { ctm_changed = true; } virtual void updateTextPos(GfxState * state) { line_pos_changed = true; } - virtual void updateTextShift(GfxState * state, double shift) { cur_line_x_offset += shift * 0.001 * state->getFontSize() * state->getHorizScaling(); } + virtual void updateTextShift(GfxState * state, double shift) { + double off = shift * 0.001 * state->getFontSize() * state->getHorizScaling(); + cur_line_x_offset += off; + cur_tx -= off; + } virtual void updateFillColor(GfxState * state) { color_changed = true; } //----- text drawing