diff --git a/share/all.css b/share/all.css index f242772..0634946 100644 --- a/share/all.css +++ b/share/all.css @@ -20,6 +20,16 @@ #pdf-main .l { position:absolute; white-space:pre; + font-size:0; + transform-origin:0% 100%; + -ms-transform-origin:0% 100%; + -moz-transform-origin:0% 100%; + -webkit-transform-origin:0% 100%; + -o-transform-origin:0% 100%; +} +#pdf-main span { + vertical-align: baseline; + line-height:0; } #pdf-main ._ { color:transparent; diff --git a/src/BackgroundRenderer.cc b/src/BackgroundRenderer.cc index 602ff68..130e9cd 100644 --- a/src/BackgroundRenderer.cc +++ b/src/BackgroundRenderer.cc @@ -19,11 +19,13 @@ 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()) || (uLen == 0) || (!all_of(u, u+uLen, isLegalUnicode)) ) + */ { SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen); } diff --git a/src/HTMLRenderer/export.cc b/src/HTMLRenderer/export.cc index c45b97a..8b313fc 100644 --- a/src/HTMLRenderer/export.cc +++ b/src/HTMLRenderer/export.cc @@ -31,17 +31,6 @@ void HTMLRenderer::export_remote_font(long long fn_id, const string & suffix, co allcss_fout << format(")format(\"%1%\");}.f%|2$x|{font-family:f%|2$x|;") % fontfileformat % fn_id; - double a = font->getAscent(); - double d = font->getDescent(); - double r = _is_positive(a-d) ? (a/(a-d)) : 1.0; - - for(const string & prefix : {"", "-ms-", "-moz-", "-webkit-", "-o-"}) - { - allcss_fout << prefix << "transform-origin:0% " << (r*100.0) << "%;"; - } - - allcss_fout << "line-height:" << (a-d) << ";"; - allcss_fout << "}" << endl; } @@ -74,17 +63,6 @@ void HTMLRenderer::export_local_font(long long fn_id, GfxFont * font, const stri else if(font->isItalic()) allcss_fout << "font-style:italic;"; - double a = font->getAscent(); - double d = font->getDescent(); - double r = _is_positive(a-d) ? (a/(a-d)) : 1.0; - - for(const string & prefix : {"", "-ms-", "-moz-", "-webkit-", "-o-"}) - { - allcss_fout << prefix << "transform-origin:0% " << (r*100.0) << "%;"; - } - - allcss_fout << "line-height:" << (a-d) << ";"; - allcss_fout << "}" << endl; } diff --git a/src/HTMLRenderer/state.cc b/src/HTMLRenderer/state.cc index f5b33c7..46e69fd 100644 --- a/src/HTMLRenderer/state.cc +++ b/src/HTMLRenderer/state.cc @@ -102,7 +102,7 @@ void HTMLRenderer::check_state_change(GfxState * state) if(!(new_fn_id == cur_fn_id)) { - new_line_status = max(new_line_status, LineStatus::DIV); + new_line_status = max(new_line_status, LineStatus::SPAN); cur_fn_id = new_fn_id; } @@ -166,7 +166,7 @@ void HTMLRenderer::check_state_change(GfxState * state) if(!(_equal(new_draw_font_size, draw_font_size))) { - new_line_status = max(new_line_status, LineStatus::DIV); + new_line_status = max(new_line_status, LineStatus::SPAN); draw_font_size = new_draw_font_size; cur_fs_id = install_font_size(draw_font_size); } @@ -328,7 +328,7 @@ void HTMLRenderer::prepare_line(GfxState * state) // horizontal position // try to merge with the last line if possible - double target = (cur_tx - draw_tx) * draw_scale; + double target = cur_tx - draw_tx; if(abs(target) < param->h_eps) { // ignore it @@ -338,7 +338,7 @@ void HTMLRenderer::prepare_line(GfxState * state) // don't close a pending span here, keep the styling double w; - auto wid = install_whitespace(target, w); + auto wid = install_whitespace(target * draw_scale, w); html_fout << format("%2%") % wid % (target > 0 ? " " : ""); draw_tx += w / draw_scale; } @@ -348,33 +348,30 @@ void HTMLRenderer::prepare_line(GfxState * state) { // have to open a new tag - if(new_line_status == LineStatus::SPAN) - { - html_fout << "transform(state->getCurX(), state->getCurY(), &x, &y); - html_fout << format("
getFont()->getDescent() * draw_font_size) - % (pageHeight - y - state->getFont()->getAscent() * draw_font_size) - % x; + html_fout << format("
") + % y % x % cur_tm_id; - html_fout << format("t%|1$x| f%|2$x| s%|3$x| ") % cur_tm_id % cur_fn_id % cur_fs_id; + } + else if(new_line_status == LineStatus::SPAN) + { + // pass } else { assert(false && "Bad value of new_line_status"); } - html_fout << format("c%|1$x| l%|2$x| w%|3$x|") % cur_color_id % cur_ls_id % cur_ws_id; + html_fout << format("") + % cur_fn_id % cur_fs_id % cur_color_id % cur_ls_id % cur_ws_id; - html_fout << "\">"; - - line_status = new_line_status; + //line_status = new_line_status; + line_status = LineStatus::SPAN; } }