1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-21 20:50:07 +00:00

don't mapp to unicode

This commit is contained in:
Lu Wang 2012-08-06 22:46:50 +08:00
parent 0d6fb82f7c
commit 2172025354
4 changed files with 41 additions and 21 deletions

View File

@ -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

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()))
{
SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
}

View File

@ -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;

View File

@ -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;