better scripting; working on encoding

This commit is contained in:
Lu Wang 2012-08-07 01:52:31 +08:00
parent 965c5d4c5a
commit 210aef28ac
4 changed files with 25 additions and 42 deletions

View File

@ -1,2 +1,3 @@
Open($1);
Reencode("unicode");
Generate($1:r+".ttf");

View File

@ -6,11 +6,22 @@ SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"/
# Execute
${SCRIPT_DIR}/pdftohtmlEX $*
echo -n "Converting fonts: "
for f in *.ttf; do
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
if [ -f $f ]; then
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
echo -n "."
fi
done
for f in *.pfa; do
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
# rm $f
if [ -f $f ]; then
fontforge -script "${SCRIPT_DIR}/convert.pe" $f 2>/dev/null
rm $f
echo -n "."
fi
done
echo
echo "Done."

View File

@ -143,20 +143,16 @@ void TextString::addChars(GfxState *state, double x, double y,
height += dy;
}
void TextString::addChar(GfxState *state, double x, double y,
double dx, double dy, Unicode u)
void TextString::addUnicodes(GfxState *state, double x, double y,
double dx, double dy, Unicode * u, int uLen)
{
/*
if (0 < u && u != 9 && u < 32) // skip non-printable not-tab character
return;
*/
/*
if (unicodes.empty())
{
this->x = x;
this->y = y;
}
*/
unicodes.push_back(u);
for(int i = 0; i < uLen; ++i)
unicodes.push_back(u[i]);
width += dx;
height += dy;
@ -226,7 +222,6 @@ void HTMLRenderer::process(PDFDoc *doc)
delete bg_renderer;
std::cerr << std::endl;
std::cerr << "Done." << std::endl;
}
void HTMLRenderer::startPage(int pageNum, GfxState *state)
@ -459,29 +454,12 @@ void HTMLRenderer::drawChar(GfxState *state, double x, double y,
double originX, double originY,
CharCode code, int nBytes, Unicode *u, int uLen)
{
double x1, y1, w1, h1;
x1 = x;
y1 = y;
// if it is hidden, then return
if ((state->getRender() & 3) == 3)
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]);
}
*/
//cur_string->addChars(state, x, y, dx, dy, code, nBytes);
cur_string->addUnicodes(state, x, y, dx, dy, u, uLen);
}
// TODO
@ -546,11 +524,6 @@ long long HTMLRenderer::install_font(GfxFont * font)
return new_fn_id;
}
//debug
{
std::cerr << "install font: " << new_fn_id << ' ' << font->getID()->num << std::endl;
}
string new_fn = (boost::format("f%|1$x|") % new_fn_id).str();
if(font->getType() == fontType3) {

View File

@ -52,11 +52,9 @@ class 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,
void addUnicodes(GfxState *state, double x, double y,
double dx, double dy,
Unicode u);
Unicode *u, int uLen);
double getX() const {return x;}
double getY() const {return y;}
double getWidth() const {return width;}