diff --git a/TODO b/TODO index 6c5aa73..ddf5dc1 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ -check exact asc/dsc - option to embed local matched fonts for non-embedded ones fake space detection diff --git a/src/HTMLRenderer.h b/src/HTMLRenderer.h index 23aae8e..0298872 100644 --- a/src/HTMLRenderer.h +++ b/src/HTMLRenderer.h @@ -265,7 +265,7 @@ class HTMLRenderer : public OutputDev // TODO: add a class for these double line_x, line_y; long long line_tm_id; - double line_height; + double line_ascent, line_height; std::stringstream line_buf; //////////////////////////////////////////////////// diff --git a/src/HTMLRenderer/install.cc b/src/HTMLRenderer/install.cc index 04f966b..bc61763 100644 --- a/src/HTMLRenderer/install.cc +++ b/src/HTMLRenderer/install.cc @@ -9,6 +9,7 @@ #include #include +#include #include @@ -19,6 +20,8 @@ #include "namespace.h" using std::all_of; +using std::max; +using std::min; FontInfo HTMLRenderer::install_font(GfxFont * font) { @@ -277,8 +280,15 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix, int em = TypoAsc - TypoDes; if(em != 0) { - info.ascent = ((double)HHeadAsc) / em; - info.descent = ((double)HHeadDes) / em; + /* + int a = max(WinAsc, max(TypoAsc, HHeadAsc)); + int d = min(-WinDes, min(TypoDes, HHeadDes)); + */ + int a = WinAsc; + int d = -WinDes; + + info.ascent = ((double)a) / em; + info.descent = ((double)d) / em; } else { diff --git a/src/HTMLRenderer/state.cc b/src/HTMLRenderer/state.cc index ca119f3..51b7132 100644 --- a/src/HTMLRenderer/state.cc +++ b/src/HTMLRenderer/state.cc @@ -350,7 +350,8 @@ void HTMLRenderer::prepare_line(GfxState * state) { state->transform(state->getCurX(), state->getCurY(), &line_x, &line_y); line_tm_id = cur_tm_id; - line_height = cur_font_info.ascent * draw_font_size; + line_ascent = cur_font_info.ascent * draw_font_size; + line_height = (cur_font_info.ascent - cur_font_info.descent) * draw_font_size; //resync position draw_ty = cur_ty; @@ -367,7 +368,8 @@ void HTMLRenderer::prepare_line(GfxState * state) line_buf << format("") % cur_font_info.id % cur_fs_id % cur_color_id % cur_ls_id % cur_ws_id % cur_rise_id; - line_height = max(line_height, cur_font_info.ascent * draw_font_size); + line_ascent = max(line_ascent, cur_font_info.ascent * draw_font_size); + line_height = max(line_height, (cur_font_info.ascent - cur_font_info.descent) * draw_font_size); line_status = LineStatus::SPAN; } @@ -380,10 +382,10 @@ void HTMLRenderer::close_line() // TODO class for height html_fout << format("
") % line_x - % (line_y + 1) + % line_y % line_tm_id - % line_height - % (line_height * 2) + % line_ascent + % (line_ascent * 2) // TODO: why? ; html_fout << line_buf.rdbuf(); line_buf.str("");