X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=9c8b9c7bf5f8237c0862217c75559dbb2e984e41;hb=ab2f7a4cd0eda09ff3af29058c45d098f869b598;hp=deb6f0a6c3622395f66bde381b18578b9008620f;hpb=339d6e2778383e1eb7807e0cc16f2e93e402e877;p=swftools.git diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index deb6f0a..9c8b9c7 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -93,9 +93,6 @@ typedef struct _fontfile static fontfile_t* global_fonts = 0; static fontfile_t* global_fonts_next = 0; -static fontfile_t* global_fontdirs = 0; -static fontfile_t* global_fontdirs_next = 0; - static int fontnum = 0; /* config */ @@ -395,17 +392,6 @@ char* fontconfig_searchForFont(char*name) fprintf(fi, "WINDOWSFONTDIR\n"); #endif fprintf(fi, "~/.fonts\n"); - - /* add external font dirs to fontconfig's config. Maybe fc will make more out - of them than we did - FIXME: we don't do that yet if there's a system config file - */ - fontfile_t*fd = global_fontdirs; - while(fd) { - fprintf(fi, "%s\n", fd->filename); - fd = fd->next; - } - #ifdef WIN32 fprintf(fi, "WINDOWSTEMPDIR_FONTCONFIG_CACHE\n"); #endif @@ -428,6 +414,14 @@ char* fontconfig_searchForFont(char*name) config_use_fontconfig = 0; return 0; } + + /* add external fonts to fontconfig's config, too. */ + fontfile_t*fd = global_fonts; + while(fd) { + FcConfigAppFontAddFile(config, (FcChar8*)fd->filename); + fd = fd->next; + } + FcFontSet * set = FcConfigGetFonts(config, FcSetSystem); msg(" FontConfig initialized. Found %d fonts", set?set->nfont:0); if(!set || !set->nfont) { @@ -538,7 +532,7 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) const char*bestfilename = 0; #ifndef HAVE_FONTCONFIG - /* if we don't have fontconfig, try a simple approach */ + /* if we don't have fontconfig, try a simple filename-comparison approach */ fontfile_t*f = global_fonts; while(f) { if(strstr(f->filename, name)) { @@ -1334,7 +1328,6 @@ void GFXOutputDev::beginString(GfxState *state, GString *s) if(current_text_stroke) { msg(" Error: Incompatible change of text rendering to %d while inside cliptext", render); } - msg(" beginString(%s) render=%d", makeStringPrintable(s->getCString()), render); } @@ -1369,7 +1362,7 @@ 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 = 255; + col.a = 0; if(!config_extrafontdata) return; } @@ -1383,11 +1376,12 @@ void GFXOutputDev::drawChar(GfxState *state, double x, double y, } Unicode u = uLen?(_u[0]):0; - msg(" drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%08x",x,y,(charid&127)>=32?charid:'?', charid, u, uLen, font->isCIDFont(), render, glyphid, current_gfxfont); gfxmatrix_t m = this->current_font_matrix; this->transformXY(state, x-originX, y-originY, &m.tx, &m.ty); //m.tx += originX; m.ty += originY; + + msg(" drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d render=%d glyphid=%d font=%08x",m.tx,m.ty,(charid&127)>=32?charid:'?', charid, u, uLen, font->isCIDFont(), render, glyphid, current_gfxfont); if(render == RENDER_FILL || render == RENDER_INVISIBLE) { device->drawchar(device, current_gfxfont, glyphid, &col, &m); @@ -1545,6 +1539,11 @@ void GFXOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, doubl /*if(user_clipy1 > y1)*/ y1 = user_clipy1; /*if(user_clipy2 < y2)*/ y2 = user_clipy2; msg(" Using user clip box %f/%f/%f/%f",x1,y1,x2,y2); + } else { + x1 += this->clipmovex; + y1 += this->clipmovey; + x2 += this->clipmovex; + y2 += this->clipmovey; } //msg(" Bounding box is (%f,%f)-(%f,%f) [shifted by %d/%d]", x1,y1,x2,y2, user_movex, user_movey); @@ -1633,7 +1632,8 @@ void GFXOutputDev::processLink(Link *link, Catalog *catalog) LinkDest *dest=NULL; if (ha->getDest()==NULL) dest=catalog->findDest(ha->getNamedDest()); - else dest=ha->getDest(); + else + dest=ha->getDest()->copy(); if (dest){ if (dest->isPageRef()){ Ref pageref=dest->getPageRef(); @@ -1642,6 +1642,7 @@ void GFXOutputDev::processLink(Link *link, Catalog *catalog) else page=dest->getPageNum(); sprintf(buf, "%d", page); s = strdup(buf); + delete dest; } } break; @@ -2461,7 +2462,7 @@ void addGlobalFont(const char*filename) } f->len = len; - msg(" Adding font \"%s\".", filename); + msg(" Adding font \"%s\".", filename); if(global_fonts_next) { global_fonts_next->next = f; global_fonts_next = global_fonts_next->next; @@ -2492,13 +2493,13 @@ void addGlobalLanguageDir(const char*dir) void addGlobalFontDir(const char*dirname) { #ifdef HAVE_DIRENT_H - msg(" Adding %s to font directories", dirname); DIR*dir = opendir(dirname); if(!dir) { msg(" Couldn't open directory %s", dirname); return; } struct dirent*ent; + int fonts = 0; while(1) { ent = readdir (dir); if (!ent) @@ -2522,22 +2523,14 @@ void addGlobalFontDir(const char*dirname) strcat(fontname, dirseparator()); strcat(fontname, name); addGlobalFont(fontname); + fonts++; } } + msg(" Added %s to font directories (%d fonts)", dirname, fonts); closedir(dir); #else msg(" No dirent.h"); #endif - - fontfile_t* f = (fontfile_t*)malloc(sizeof(fontfile_t)); - memset(f, 0, sizeof(fontfile_t)); - f->filename = dirname; - if(global_fontdirs_next) { - global_fontdirs_next->next = f; - global_fontdirs_next = global_fontdirs_next->next; - } else { - global_fontdirs_next = global_fontdirs = f; - } } void GFXOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,