X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=46e9c26a453e6730d394c6574083895ca3ff27e0;hp=def11a62d8617bf14851db440908a4b5d2b52234;hb=648e7ccd78283cb2403a7bb916e5a79bb434d3a1;hpb=0e482bea37ed1f38e592247984b6e064158c8ea1 diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index def11a6..46e9c26 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -97,8 +97,6 @@ static int fontnum = 0; /* config */ -static char* lastfontdir = 0; - struct fontentry { const char*pdffont; const char*filename; @@ -416,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) { @@ -524,7 +530,9 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) int bestlen = 0x7fffffff; const char*bestfilename = 0; - + +#ifndef HAVE_FONTCONFIG + /* if we don't have fontconfig, try a simple filename-comparison approach */ fontfile_t*f = global_fonts; while(f) { if(strstr(f->filename, name)) { @@ -535,6 +543,7 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) } f = f->next; } +#endif /* if we didn't find anything up to now, try looking for the font via fontconfig */ @@ -546,6 +555,7 @@ DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName) } if(filename) { + msg(" Font %s maps to %s\n", name, filename); DisplayFontParamKind kind = detectFontType(filename); DisplayFontParam *dfp = new DisplayFontParam(new GString(fontName), kind); if(kind == displayFontTT) { @@ -579,6 +589,7 @@ GFXOutputDev::GFXOutputDev(InfoOutputDev*info, PDFDoc*doc) this->user_clipy1 = 0; this->user_clipx2 = 0; this->user_clipy2 = 0; + this->current_fontinfo = 0; this->current_text_stroke = 0; this->current_text_clip = 0; this->outer_clip_box = 0; @@ -762,6 +773,13 @@ static void dumpFontInfo(const char*loglevel, GfxFont*font) void dump_outline(gfxline_t*line) { + /*gfxbbox_t*r = gfxline_isrectangle(line); + if(!r) + printf("is not a rectangle\n"); + else + printf("is a rectangle: (%f,%f)-(%f-%f)\n", r->xmin, r->ymin, r->xmax, r->ymax); + */ + while(line) { if(line->type == gfx_moveTo) { msg(" | moveTo %.2f %.2f", line->x,line->y); @@ -1521,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); @@ -1609,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(); @@ -1618,6 +1642,7 @@ void GFXOutputDev::processLink(Link *link, Catalog *catalog) else page=dest->getPageNum(); sprintf(buf, "%d", page); s = strdup(buf); + delete dest; } } break; @@ -1882,6 +1907,7 @@ void GFXOutputDev::updateFont(GfxState *state) } this->current_fontinfo = this->info->getFont(id); + if(!this->current_fontinfo) { msg(" Internal Error: no fontinfo for font %s", id); return; @@ -1890,7 +1916,7 @@ void GFXOutputDev::updateFont(GfxState *state) dumpFontInfo("", gfxFont); } - current_gfxfont = this->current_fontinfo->gfxfont; + current_gfxfont = this->current_fontinfo->getGfxFont(); device->addfont(device, current_gfxfont); free(id); @@ -2436,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; @@ -2467,14 +2493,13 @@ void addGlobalLanguageDir(const char*dir) void addGlobalFontDir(const char*dirname) { #ifdef HAVE_DIRENT_H - msg(" Adding %s to font directories", dirname); - lastfontdir = strdup(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) @@ -2498,11 +2523,13 @@ 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- unable to add font dir %s", dirname); + msg(" No dirent.h"); #endif }