mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
better positioning
need to check: Q1Q2.pdf on FF simple.pdf
This commit is contained in:
parent
f661aa5d8a
commit
1492d815ad
2
TODO
2
TODO
@ -1,5 +1,3 @@
|
||||
check exact asc/dsc
|
||||
|
||||
option to embed local matched fonts for non-embedded ones
|
||||
|
||||
fake space detection
|
||||
|
@ -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;
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
@ -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("<span class=\"f%|1$x| s%|2$x| c%|3$x| l%|4$x| w%|5$x| r%|6$x|\">")
|
||||
% 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("<div style=\"left:%1%px;bottom:%2%px;height:%4%px;line-height:%5%px;\" class=\"l t%|3$x|\">")
|
||||
% 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("");
|
||||
|
Loading…
Reference in New Issue
Block a user