From d12b8d086b9b6dd59adcd565f48f5e6257b6f30c Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Fri, 31 Aug 2012 23:46:59 +0800 Subject: [PATCH] fixed a line merging bug --- src/HTMLRenderer/state.cc | 51 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/HTMLRenderer/state.cc b/src/HTMLRenderer/state.cc index 2342775..b91ca81 100644 --- a/src/HTMLRenderer/state.cc +++ b/src/HTMLRenderer/state.cc @@ -190,40 +190,45 @@ void HTMLRenderer::check_state_change(GfxState * state) * TODO, writing mode, set dx and solve dy */ - double dy = cur_ty - draw_ty; - double tdx = old_ctm[4] - cur_ctm[4] - cur_ctm[2] * dy; - double tdy = old_ctm[5] - cur_ctm[5] - cur_ctm[3] * dy; - - if(_equal(cur_ctm[0] * tdy, cur_ctm[1] * tdx)) + bool merged = false; + if(_tm_equal(old_ctm, cur_ctm, 4)) { - if(abs(cur_ctm[0]) > EPS) + double dy = cur_ty - draw_ty; + double tdx = old_ctm[4] - cur_ctm[4] - cur_ctm[2] * dy; + double tdy = old_ctm[5] - cur_ctm[5] - cur_ctm[3] * dy; + + if(_equal(cur_ctm[0] * tdy, cur_ctm[1] * tdx)) { - draw_tx += tdx / cur_ctm[0]; - draw_ty += dy; - } - else if (abs(cur_ctm[1]) > EPS) - { - draw_tx += tdy / cur_ctm[1]; - draw_ty += dy; - } - else - { - if((abs(tdx) < EPS) && (abs(tdy) < EPS)) + if(abs(cur_ctm[0]) > EPS) { - // free - draw_tx = cur_tx; + draw_tx += tdx / cur_ctm[0]; draw_ty += dy; + merged = true; + } + else if (abs(cur_ctm[1]) > EPS) + { + draw_tx += tdy / cur_ctm[1]; + draw_ty += dy; + merged = true; } else { - // fail - new_line_status = max(new_line_status, LineStatus::DIV); + if((abs(tdx) < EPS) && (abs(tdy) < EPS)) + { + // free + draw_tx = cur_tx; + draw_ty += dy; + merged = true; + } + // else fail } } + //else no solution } - else + // else force new lien + + if(!merged) { - // no solution new_line_status = max(new_line_status, LineStatus::DIV); } }