X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=a1ddba9e9e7a75b9cdcc59a947bc6bf1150d05cf;hb=232c3195bde361c9f0864997481ef6565bb76c72;hp=24a8f05d0fbf6ee5dd7b992baefe81e1d30fa337;hpb=1f75b5311e88f8a6d71146cf2e709f1f5666dfc8;p=swftools.git diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 24a8f05..a1ddba9 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -328,6 +328,13 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) return dfp; } } + for(t=0;tt1.fileName = new GString(fonts[t].filename); + return dfp; + } + } return GlobalParams::getDisplayFont(fontName); } @@ -845,7 +852,7 @@ GFXOutputDev::~GFXOutputDev() free(this->pages); this->pages = 0; } - gfxfontlist_free(this->gfxfontlist); + gfxfontlist_free(this->gfxfontlist, 1); }; GBool GFXOutputDev::upsideDown() { @@ -893,15 +900,25 @@ char* makeStringPrintable(char*str) #define INTERNAL_FONT_SIZE 1024.0 void GFXOutputDev::updateFontMatrix(GfxState*state) { - double m11,m21,m12,m22; - state->getFontTransMat(&m11, &m12, &m21, &m22); - m11 *= state->getHorizScaling(); - m21 *= state->getHorizScaling(); + double* ctm = state->getCTM(); + double fontSize = state->getFontSize(); + double*textMat = state->getTextMat(); - this->current_font_matrix.m00 = m11 / INTERNAL_FONT_SIZE; - this->current_font_matrix.m01 = m12 / INTERNAL_FONT_SIZE; - this->current_font_matrix.m10 = -m21 / INTERNAL_FONT_SIZE; - this->current_font_matrix.m11 = -m22 / INTERNAL_FONT_SIZE; + /* taking the absolute value of horizScaling seems to be required for + some italic fonts. FIXME: SplashOutputDev doesn't need this- why? */ + double hscale = fabs(state->getHorizScaling()); + + // from xpdf-3.02/SplashOutputDev:updateFont + double mm11 = textMat[0] * fontSize * hscale; + double mm12 = textMat[1] * fontSize * hscale; + double mm21 = textMat[2] * fontSize; + double mm22 = textMat[3] * fontSize; + + // multiply with ctm, like state->getFontTransMat() does + this->current_font_matrix.m00 = (ctm[0]*mm11 + ctm[2]*mm12) / INTERNAL_FONT_SIZE; + this->current_font_matrix.m01 = (ctm[1]*mm11 + ctm[3]*mm12) / INTERNAL_FONT_SIZE; + this->current_font_matrix.m10 = (ctm[0]*mm21 + ctm[2]*mm22) / INTERNAL_FONT_SIZE; + this->current_font_matrix.m11 = (ctm[1]*mm21 + ctm[3]*mm22) / INTERNAL_FONT_SIZE; this->current_font_matrix.tx = 0; this->current_font_matrix.ty = 0; } @@ -914,7 +931,6 @@ void GFXOutputDev::beginString(GfxState *state, GString *s) } msg(" beginString(%s) render=%d", makeStringPrintable(s->getCString()), render); - updateFontMatrix(state); } static gfxline_t* mkEmptyGfxShape(double x, double y) @@ -940,7 +956,7 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, msg(" Invalid charid %d for font %s", charid, current_font_id); return; } - + CharCode glyphid = current_fontinfo->glyphs[charid]->glyphid; int render = state->getRender(); @@ -949,6 +965,8 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, // check for invisible text -- this is used by Acrobat Capture if (render == RENDER_INVISIBLE) { col.a = 0; + if(!config_extrafontdata) + return; } GfxFont*font = state->getFont(); @@ -1472,7 +1490,7 @@ gfxfont_t* createGfxFont(GfxFont*xpdffont, FontInfo*src) Guchar f; double x, y; path->getPoint(s, &x, &y, &f); - if(x > xmax) + if(!s || x > xmax) xmax = x; if(f&splashPathFirst) { drawer.moveTo(&drawer, x*scale, y*scale); @@ -1531,6 +1549,9 @@ void GFXOutputDev::updateFont(GfxState *state) } this->current_fontinfo = this->info->getFont(id); + if(!this->current_fontinfo) { + msg(" Internal Error: no fontinfo for font %s\n", id); + } if(!this->current_fontinfo->seen) { dumpFontInfo("", gfxFont); } @@ -1538,7 +1559,8 @@ void GFXOutputDev::updateFont(GfxState *state) gfxfont_t*font = gfxfontlist_findfont(this->gfxfontlist,id); if(!font) { font = createGfxFont(gfxFont, current_fontinfo); - gfxfontlist_addfont(this->gfxfontlist, font); + font->id = strdup(id); + this->gfxfontlist = gfxfontlist_addfont(this->gfxfontlist, font); device->addfont(device, font); } current_gfxfont = font; @@ -2021,8 +2043,7 @@ void addGlobalFont(const char*filename) memset(&f, 0, sizeof(fontfile_t)); f.filename = filename; if(fontnum < sizeof(fonts)/sizeof(fonts[0])) { - msg(" Adding font \"%s\".", filename); - msg(" External fonts are not supported with this version. Ignoring font %s", filename); + msg(" Adding font \"%s\".", filename); fonts[fontnum++] = f; } else { msg(" Too many external fonts. Not adding font file \"%s\".", filename); @@ -2051,8 +2072,6 @@ void addGlobalLanguageDir(const char*dir) void addGlobalFontDir(const char*dirname) { - msg(" External fonts are not supported with this version. Ignoring directory %s", dirname); - return; #ifdef HAVE_DIRENT_H msg(" Adding %s to font directories", dirname); lastfontdir = strdup(dirname); @@ -2079,8 +2098,7 @@ void addGlobalFontDir(const char*dirname) type=3; if(!strncasecmp(&name[l-4], ".ttf", 4)) type=2; - if(type) - { + if(type) { char*fontname = (char*)malloc(strlen(dirname)+strlen(name)+2); strcpy(fontname, dirname); strcat(fontname, dirseparator());