diff --git a/bin/pdf2htmlEX b/bin/pdf2htmlEX
index bc0f212..b6bb525 100755
--- a/bin/pdf2htmlEX
+++ b/bin/pdf2htmlEX
@@ -6,11 +6,10 @@ SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"/
# Execute
${SCRIPT_DIR}/pdftohtmlEX $*
-# for ttf files, convert the encoding
for f in *.ttf; do
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
done
-# convert to ttf
+
for f in *.pfa; do
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
rm $f
diff --git a/src/BackgroundRenderer.cc b/src/BackgroundRenderer.cc
index 2913947..5941eee 100644
--- a/src/BackgroundRenderer.cc
+++ b/src/BackgroundRenderer.cc
@@ -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()))
{
SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
}
diff --git a/src/HTMLRenderer.cc b/src/HTMLRenderer.cc
index 5005f61..b52fe3a 100644
--- a/src/HTMLRenderer.cc
+++ b/src/HTMLRenderer.cc
@@ -131,6 +131,24 @@ TextString::~TextString()
state = nullptr;
}
+void TextString::addChars(GfxState *state, double x, double y,
+ double dx, double dy, CharCode code, int nbytes)
+{
+ if(nbytes > 0)
+ {
+ CharCode mask = 0xff << (8*(nbytes-1));
+ while(nbytes > 0)
+ {
+ unicodes.push_back((Unicode)((code & mask) >> (8 * (nbytes-1))));
+ --nbytes;
+ mask >>= 8;
+ }
+ }
+
+ width += dx;
+ height += dy;
+}
+
void TextString::addChar(GfxState *state, double x, double y,
double dx, double dy, Unicode u)
{
@@ -236,6 +254,7 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state)
memcpy(draw_ctm, id_matrix, sizeof(draw_ctm));
draw_font_size = 0;
+ draw_scale = 1.0;
pos_changed = false;
ctm_changed = false;
@@ -373,7 +392,7 @@ void HTMLRenderer::endString(GfxState *state) {
{
double x1 = cur_line->getX() + cur_line->getWidth();
double x2 = cur_string->getX();
- double target = x2-x1-cur_line_x_offset;
+ double target = (x2-x1-cur_line_x_offset) * draw_scale;
if(target > -param->h_eps)
{
@@ -445,7 +464,7 @@ void HTMLRenderer::endString(GfxState *state) {
void HTMLRenderer::drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
- CharCode code, int /*nBytes*/, Unicode *u, int uLen)
+ CharCode code, int nBytes, Unicode *u, int uLen)
{
double x1, y1, w1, h1;
@@ -457,17 +476,19 @@ void HTMLRenderer::drawChar(GfxState *state, double x, double y,
return ;
w1 = dx - state->getCharSpace() * state->getHorizScaling(),
-
h1 = dy;
+ cur_string->addChars(state, x1, y1, w1, h1, code, nBytes);
+
+ /*
if (uLen != 0) {
w1 /= uLen;
h1 /= uLen;
}
-
for (int i = 0; i < uLen; ++i) {
cur_string->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u[i]);
}
+ */
}
// TODO
@@ -1014,24 +1035,17 @@ void HTMLRenderer::check_state_change(GfxState * state)
if(need_rescale_font)
{
- double scale = std::sqrt(new_ctm[2] * new_ctm[2] + new_ctm[3] * new_ctm[3]);
+ draw_scale = std::sqrt(new_ctm[2] * new_ctm[2] + new_ctm[3] * new_ctm[3]);
double new_draw_font_size = cur_font_size;
- if(_is_positive(scale))
+ if(_is_positive(draw_scale))
{
- new_draw_font_size *= scale;
+ new_draw_font_size *= draw_scale;
for(int i = 0; i < 4; ++i)
- new_ctm[i] /= scale;
+ new_ctm[i] /= draw_scale;
}
-
- //debug
- if(new_draw_font_size > 100)
+ else
{
- cerr << "Font size too big: " << new_draw_font_size << endl;
- cerr << "scale: " << scale << endl;
- cerr << "ctm:";
- for(int i = 0; i < 6; ++i)
- cerr << ' ' << new_ctm[i];
- cerr << endl;
+ draw_scale = 1.0;
}
bool flag = false;
diff --git a/src/HTMLRenderer.h b/src/HTMLRenderer.h
index 94dea06..b4d7792 100644
--- a/src/HTMLRenderer.h
+++ b/src/HTMLRenderer.h
@@ -49,6 +49,10 @@ class TextString
TextString(GfxState *state);
~TextString();
+ void addChars(GfxState * state, double x, double y,
+ double dx, double dy,
+ CharCode code, int nbytes);
+
// Add a character to the string.
void addChar(GfxState *state, double x, double y,
double dx, double dy,
@@ -207,9 +211,12 @@ class HTMLRenderer : public OutputDev
bool text_mat_changed;
- // this is the modified fontsize & ctm for optimzation
+ // optmize for web
+ // we try to render the final font size directly
+ // to reduce the effect of ctm as much as possible
double draw_ctm[6];
double draw_font_size;
+ double draw_scale;
ofstream html_fout, allcss_fout;