diff --git a/TODO b/TODO index 5ff7f61..27c056a 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ better solution for ascent/descent (cross-platform, embeded/not) +option to embed local matched fonts for non-embedded ones + fake space detection take care of spaces (simulate by ) diff --git a/share/all.css b/share/all.css index 5da34eb..9d5b559 100644 --- a/share/all.css +++ b/share/all.css @@ -20,11 +20,11 @@ position:absolute; white-space:pre; font-size:0; - transform-origin:0% 0%; - -ms-transform-origin:0% 0%; - -moz-transform-origin:0% 0%; - -webkit-transform-origin:0% 0%; - -o-transform-origin:0% 0%; + transform-origin:0% 190%; + -ms-transform-origin:0% 100%; + -moz-transform-origin:0% 100%; + -webkit-transform-origin:0% 100%; + -o-transform-origin:0% 100%; } span { position:relative; diff --git a/src/HTMLRenderer/export.cc b/src/HTMLRenderer/export.cc index 55b6cbb..59a81ea 100644 --- a/src/HTMLRenderer/export.cc +++ b/src/HTMLRenderer/export.cc @@ -30,7 +30,7 @@ void HTMLRenderer::export_remote_font(long long fn_id, const string & suffix, co allcss_fout << fn; } - allcss_fout << format(")format(\"%1%\");}.f%|2$x|{font-family:f%|2$x|;}") % fontfileformat % fn_id << endl; + allcss_fout << format(")format(\"%1%\");}.f%|2$x|{font-family:f%|2$x|;line-height:%3%;}") % fontfileformat % fn_id % (font->getAscent() - font->getDescent()) << endl; } static string general_font_family(GfxFont * font) @@ -62,6 +62,8 @@ void HTMLRenderer::export_local_font(long long fn_id, GfxFont * font, const stri else if(font->isItalic() || ifind_first(original_font_name, "italic")) allcss_fout << "font-style:italic;"; + allcss_fout << "line-height:" << (font->getAscent() - font->getDescent()) << ";"; + allcss_fout << "}" << endl; } diff --git a/src/HTMLRenderer/install.cc b/src/HTMLRenderer/install.cc index c4e43a9..9835ceb 100644 --- a/src/HTMLRenderer/install.cc +++ b/src/HTMLRenderer/install.cc @@ -247,23 +247,6 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix, if(ctu) ctu->decRefCnt(); - /* - * Fontforge cannot set the ***Ascent value for nonTTF fonts - * So save to a temp ttf file and open it again - */ - string tmpfn = fn + "_.ttf"; - add_tmp_file(tmpfn); - - script_fout << format("Generate(%1%)") % (tmp_dir / tmpfn) << endl; - script_fout << format("Open(%1%)") % (tmp_dir / tmpfn) << endl; - - for(const string & key : {"Win", "Typo", "HHead"}) - { - script_fout << format("SetOS2Value(\"%1%Ascent\", %2%)") % key % (int)round(font->getAscent() * 1000) << endl; - script_fout << format("SetOS2Value(\"%1%AscentIsOffset\", 0)") % key << endl; - script_fout << format("SetOS2Value(\"%1%Descent\", %2%)") % key % (int)round(-font->getDescent() * 1000) << endl; - script_fout << format("SetOS2Value(\"%1%DescentIsOffset\", 0)") % key << endl; - } script_fout << format("Generate(%1%)") % ((param->single_html ? tmp_dir : dest_dir) / (fn+".ttf")) << endl; if(param->single_html) add_tmp_file(fn+".ttf"); diff --git a/src/HTMLRenderer/state.cc b/src/HTMLRenderer/state.cc index a5bb1b9..1c24a43 100644 --- a/src/HTMLRenderer/state.cc +++ b/src/HTMLRenderer/state.cc @@ -352,11 +352,14 @@ void HTMLRenderer::prepare_line(GfxState * state) double x,y; // in user space state->transform(state->getCurX(), state->getCurY(), &x, &y); - html_fout << format("
") + // TODO class for height + html_fout << format("
") % x - % (pageHeight - y - state->getFont()->getAscent() * draw_font_size) - % (y + state->getFont()->getDescent() * draw_font_size) - % cur_tm_id; + % y + % cur_tm_id + % (state->getFont()->getAscent() * draw_font_size) + % (2*(state->getFont()->getAscent() * draw_font_size)) + ; //resync position draw_ty = cur_ty;