X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FGFXOutputDev.cc;h=deb6f0a6c3622395f66bde381b18578b9008620f;hb=339d6e2778383e1eb7807e0cc16f2e93e402e877;hp=def11a62d8617bf14851db440908a4b5d2b52234;hpb=0e482bea37ed1f38e592247984b6e064158c8ea1;p=swftools.git diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index def11a6..deb6f0a 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -93,12 +93,13 @@ 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 */ -static char* lastfontdir = 0; - struct fontentry { const char*pdffont; const char*filename; @@ -394,6 +395,17 @@ 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 @@ -524,7 +536,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 approach */ fontfile_t*f = global_fonts; while(f) { if(strstr(f->filename, name)) { @@ -535,6 +549,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 +561,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 +595,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 +779,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); @@ -1882,6 +1906,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 +1915,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); @@ -2468,7 +2493,6 @@ 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); @@ -2502,8 +2526,18 @@ void addGlobalFontDir(const char*dirname) } closedir(dir); #else - msg(" No dirent.h- unable to add font dir %s", dirname); + 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,