mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
don't mapp to unicode
This commit is contained in:
parent
0d6fb82f7c
commit
2172025354
@ -6,11 +6,10 @@ SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"/
|
|||||||
# Execute
|
# Execute
|
||||||
${SCRIPT_DIR}/pdftohtmlEX $*
|
${SCRIPT_DIR}/pdftohtmlEX $*
|
||||||
|
|
||||||
# for ttf files, convert the encoding
|
|
||||||
for f in *.ttf; do
|
for f in *.ttf; do
|
||||||
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
|
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
|
||||||
done
|
done
|
||||||
# convert to ttf
|
|
||||||
for f in *.pfa; do
|
for f in *.pfa; do
|
||||||
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
|
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
|
||||||
rm $f
|
rm $f
|
||||||
|
@ -14,7 +14,7 @@ void BackgroundRenderer::drawChar(GfxState *state, double x, double y,
|
|||||||
CharCode code, int nBytes, Unicode *u, int uLen)
|
CharCode code, int nBytes, Unicode *u, int uLen)
|
||||||
{
|
{
|
||||||
auto font = state->getFont();
|
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);
|
SplashOutputDev::drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,24 @@ TextString::~TextString()
|
|||||||
state = nullptr;
|
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,
|
void TextString::addChar(GfxState *state, double x, double y,
|
||||||
double dx, double dy, Unicode u)
|
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));
|
memcpy(draw_ctm, id_matrix, sizeof(draw_ctm));
|
||||||
draw_font_size = 0;
|
draw_font_size = 0;
|
||||||
|
draw_scale = 1.0;
|
||||||
|
|
||||||
pos_changed = false;
|
pos_changed = false;
|
||||||
ctm_changed = false;
|
ctm_changed = false;
|
||||||
@ -373,7 +392,7 @@ void HTMLRenderer::endString(GfxState *state) {
|
|||||||
{
|
{
|
||||||
double x1 = cur_line->getX() + cur_line->getWidth();
|
double x1 = cur_line->getX() + cur_line->getWidth();
|
||||||
double x2 = cur_string->getX();
|
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)
|
if(target > -param->h_eps)
|
||||||
{
|
{
|
||||||
@ -445,7 +464,7 @@ void HTMLRenderer::endString(GfxState *state) {
|
|||||||
void HTMLRenderer::drawChar(GfxState *state, double x, double y,
|
void HTMLRenderer::drawChar(GfxState *state, double x, double y,
|
||||||
double dx, double dy,
|
double dx, double dy,
|
||||||
double originX, double originY,
|
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;
|
double x1, y1, w1, h1;
|
||||||
|
|
||||||
@ -457,17 +476,19 @@ void HTMLRenderer::drawChar(GfxState *state, double x, double y,
|
|||||||
return ;
|
return ;
|
||||||
|
|
||||||
w1 = dx - state->getCharSpace() * state->getHorizScaling(),
|
w1 = dx - state->getCharSpace() * state->getHorizScaling(),
|
||||||
|
|
||||||
h1 = dy;
|
h1 = dy;
|
||||||
|
|
||||||
|
cur_string->addChars(state, x1, y1, w1, h1, code, nBytes);
|
||||||
|
|
||||||
|
/*
|
||||||
if (uLen != 0) {
|
if (uLen != 0) {
|
||||||
w1 /= uLen;
|
w1 /= uLen;
|
||||||
h1 /= uLen;
|
h1 /= uLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < uLen; ++i) {
|
for (int i = 0; i < uLen; ++i) {
|
||||||
cur_string->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u[i]);
|
cur_string->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u[i]);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
@ -1014,24 +1035,17 @@ void HTMLRenderer::check_state_change(GfxState * state)
|
|||||||
|
|
||||||
if(need_rescale_font)
|
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;
|
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)
|
for(int i = 0; i < 4; ++i)
|
||||||
new_ctm[i] /= scale;
|
new_ctm[i] /= draw_scale;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
//debug
|
|
||||||
if(new_draw_font_size > 100)
|
|
||||||
{
|
{
|
||||||
cerr << "Font size too big: " << new_draw_font_size << endl;
|
draw_scale = 1.0;
|
||||||
cerr << "scale: " << scale << endl;
|
|
||||||
cerr << "ctm:";
|
|
||||||
for(int i = 0; i < 6; ++i)
|
|
||||||
cerr << ' ' << new_ctm[i];
|
|
||||||
cerr << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
|
@ -49,6 +49,10 @@ class TextString
|
|||||||
TextString(GfxState *state);
|
TextString(GfxState *state);
|
||||||
~TextString();
|
~TextString();
|
||||||
|
|
||||||
|
void addChars(GfxState * state, double x, double y,
|
||||||
|
double dx, double dy,
|
||||||
|
CharCode code, int nbytes);
|
||||||
|
|
||||||
// Add a character to the string.
|
// Add a character to the string.
|
||||||
void addChar(GfxState *state, double x, double y,
|
void addChar(GfxState *state, double x, double y,
|
||||||
double dx, double dy,
|
double dx, double dy,
|
||||||
@ -207,9 +211,12 @@ class HTMLRenderer : public OutputDev
|
|||||||
bool text_mat_changed;
|
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_ctm[6];
|
||||||
double draw_font_size;
|
double draw_font_size;
|
||||||
|
double draw_scale;
|
||||||
|
|
||||||
ofstream html_fout, allcss_fout;
|
ofstream html_fout, allcss_fout;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user