mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
whitespace
This commit is contained in:
parent
b18f59af6d
commit
6c7229f514
@ -318,6 +318,7 @@ class HTMLRenderer : public OutputDev
|
||||
bool rise_changed;
|
||||
RiseManager rise_manager;
|
||||
|
||||
WhitespaceManager whitespace_manager;
|
||||
HeightManager height_manager;
|
||||
|
||||
// optimize for web
|
||||
@ -358,7 +359,6 @@ class HTMLRenderer : public OutputDev
|
||||
std::unordered_map<long long, FontInfo> font_name_map;
|
||||
std::map<Matrix, long long, Matrix_less> transform_matrix_map;
|
||||
std::unordered_map<GfxRGB, long long, GfxRGB_hash, GfxRGB_equal> fill_color_map, stroke_color_map;
|
||||
std::map<double, long long> whitespace_map;
|
||||
std::map<double, long long> left_map;
|
||||
|
||||
const Param * param;
|
||||
|
@ -145,9 +145,11 @@ void HTMLRenderer::TextLineBuffer::flush(void)
|
||||
if(cur_text_idx >= cur_offset_iter->start_idx)
|
||||
{
|
||||
double target = cur_offset_iter->width + dx;
|
||||
double w;
|
||||
|
||||
auto wid = renderer->install_whitespace(target, w);
|
||||
auto & wm = renderer->whitespace_manager;
|
||||
wm.install(target);
|
||||
auto wid = wm.get_id();
|
||||
double w = wm.get_actual_value();
|
||||
|
||||
if(w < 0)
|
||||
last_text_pos_with_negative_offset = cur_text_idx;
|
||||
|
@ -60,6 +60,7 @@ HTMLRenderer::HTMLRenderer(const Param * param)
|
||||
letter_space_manager.set_param(CSS::LETTER_SPACE_CN, EPS );
|
||||
word_space_manager .set_param(CSS::WORD_SPACE_CN , EPS );
|
||||
rise_manager .set_param(CSS::RISE_CN , param->v_eps);
|
||||
whitespace_manager .set_param(CSS::WHITESPACE_CN , param->h_eps);
|
||||
height_manager .set_param(CSS::HEIGHT_CN , EPS );
|
||||
}
|
||||
|
||||
@ -342,6 +343,7 @@ void HTMLRenderer::post_process()
|
||||
letter_space_manager.dump_css(f_css.fs);
|
||||
word_space_manager .dump_css(f_css.fs);
|
||||
rise_manager .dump_css(f_css.fs);
|
||||
whitespace_manager .dump_css(f_css.fs);
|
||||
height_manager .dump_css(f_css.fs);
|
||||
|
||||
// close files
|
||||
|
@ -263,23 +263,6 @@ long long HTMLRenderer::install_stroke_color(const GfxRGB * rgb)
|
||||
return new_color_id;
|
||||
}
|
||||
|
||||
long long HTMLRenderer::install_whitespace(double ws_width, double & actual_width)
|
||||
{
|
||||
// ws_width is already mulitpled by draw_scale
|
||||
auto iter = whitespace_map.lower_bound(ws_width - param->h_eps);
|
||||
if((iter != whitespace_map.end()) && (abs(iter->first - ws_width) <= param->h_eps))
|
||||
{
|
||||
actual_width = iter->first;
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
actual_width = ws_width;
|
||||
long long new_ws_id = whitespace_map.size();
|
||||
whitespace_map.insert(make_pair(ws_width, new_ws_id));
|
||||
export_whitespace(new_ws_id, ws_width);
|
||||
return new_ws_id;
|
||||
}
|
||||
|
||||
long long HTMLRenderer::install_left(double left)
|
||||
{
|
||||
auto iter = left_map.lower_bound(left - param->h_eps);
|
||||
|
@ -121,6 +121,13 @@ public:
|
||||
void dump_value(std::ostream & out, double value) { out << "top:" << round(-value) << "px;"; }
|
||||
};
|
||||
|
||||
class WhitespaceManager : public StateManager<double, WhitespaceManager>
|
||||
{
|
||||
public:
|
||||
double default_value(void) { return 0; }
|
||||
void dump_value(std::ostream & out, double value) { out << "top:" << round(-value) << "px;"; }
|
||||
};
|
||||
|
||||
class HeightManager : public StateManager<double, HeightManager>
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user