1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

working on x offset

This commit is contained in:
Lu Wang 2012-08-07 17:59:24 +08:00
parent 9d7046e925
commit 272cf9fa02
4 changed files with 17 additions and 9 deletions

View File

@ -12,7 +12,6 @@ echo -n "Converting fonts: "
for f in *.ttf; do
if [ -f $f ]; then
cp $f $f.old
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
echo -n "."
fi
@ -20,7 +19,6 @@ done
for f in *.pfa; do
if [ -f $f ]; then
cp $f $f.old
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
rm $f
echo -n "."

View File

@ -14,7 +14,7 @@ void BackgroundRenderer::drawChar(GfxState *state, double x, double y,
CharCode code, int nBytes, Unicode *u, int uLen)
{
auto font = state->getFont();
if((font->getType() == fontType3) || (font->getWMode()))
if((font->getType() == fontType3) || (font->getWMode()) || (uLen == 0))
{
SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
}

View File

@ -206,6 +206,9 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
// if the line is still open, try to merge with it
if(line_opened)
{
//debug
html_fout << "<span data-x=\"" << cur_tx << "\"></span>";
double target = -cur_line_x_offset * draw_scale;
if(target > -param->h_eps)
{
@ -213,17 +216,17 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
{
double w;
auto wid = install_whitespace(target, w);
cur_tx += w / draw_scale;
cur_line_x_offset = (w - target) / draw_scale;
html_fout << boost::format("<span class=\"w w%|1$x|\"> </span>") % wid;
}
}
else
{
//debug
html_fout << "<span data-w=\"" << target << "\"></span>";
// can we shift left using simple tags?
close_cur_line();
cur_tx = state->getLineX();
cur_line_x_offset = 0;
}
}
@ -270,6 +273,8 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
html_fout << "\">";
line_opened = true;
cur_line_x_offset = 0;
}
@ -691,7 +696,7 @@ void HTMLRenderer::export_remote_font(long long fn_id, const string & suffix, Gf
// TODO: this function is called when some font is unable to process, may use the name there as a hint
void HTMLRenderer::export_remote_default_font(long long fn_id)
{
allcss_fout << boost::format(".f%|1$x|{font-family:sans-serif;color:transparent;}")%fn_id;
allcss_fout << boost::format(".f%|1$x|{font-family:sans-serif;color:transparent;visibility:hidden;}")%fn_id;
if(param->readable) allcss_fout << endl;
}
@ -802,7 +807,8 @@ void HTMLRenderer::check_state_change(GfxState * state)
else
{
// LineY remains unchanged
cur_line_x_offset += cur_tx - tx;
cur_line_x_offset = cur_tx - tx;
cur_tx = tx;
}
}

View File

@ -97,7 +97,11 @@ class HTMLRenderer : public OutputDev
virtual void updateTextMat(GfxState * state) { text_mat_changed = true; }
virtual void updateCTM(GfxState * state, double m11, double m12, double m21, double m22, double m31, double m32) { ctm_changed = true; }
virtual void updateTextPos(GfxState * state) { line_pos_changed = true; }
virtual void updateTextShift(GfxState * state, double shift) { cur_line_x_offset += shift * 0.001 * state->getFontSize() * state->getHorizScaling(); }
virtual void updateTextShift(GfxState * state, double shift) {
double off = shift * 0.001 * state->getFontSize() * state->getHorizScaling();
cur_line_x_offset += off;
cur_tx -= off;
}
virtual void updateFillColor(GfxState * state) { color_changed = true; }
//----- text drawing