git.asbjorn.biz
/
swftools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
436555d
)
add font dirs to fontconfig's config
author
Matthias Kramm
<kramm@quiss.org>
Thu, 22 Jan 2009 22:15:14 +0000
(14:15 -0800)
committer
Matthias Kramm
<kramm@quiss.org>
Thu, 22 Jan 2009 22:15:14 +0000
(14:15 -0800)
lib/pdf/GFXOutputDev.cc
patch
|
blob
|
history
diff --git
a/lib/pdf/GFXOutputDev.cc
b/lib/pdf/GFXOutputDev.cc
index
2b0e892
..
deb6f0a
100644
(file)
--- 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_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 int fontnum = 0;
/* config */
-static char* lastfontdir = 0;
-
struct fontentry {
const char*pdffont;
const char*filename;
struct fontentry {
const char*pdffont;
const char*filename;
@@
-394,6
+395,17
@@
char* fontconfig_searchForFont(char*name)
fprintf(fi, "<dir>WINDOWSFONTDIR</dir>\n");
#endif
fprintf(fi, "<dir>~/.fonts</dir>\n");
fprintf(fi, "<dir>WINDOWSFONTDIR</dir>\n");
#endif
fprintf(fi, "<dir>~/.fonts</dir>\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, "<dir>%s</dir>\n", fd->filename);
+ fd = fd->next;
+ }
+
#ifdef WIN32
fprintf(fi, "<cachedir>WINDOWSTEMPDIR_FONTCONFIG_CACHE</cachedir>\n");
#endif
#ifdef WIN32
fprintf(fi, "<cachedir>WINDOWSTEMPDIR_FONTCONFIG_CACHE</cachedir>\n");
#endif
@@
-524,7
+536,9
@@
DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName)
int bestlen = 0x7fffffff;
const char*bestfilename = 0;
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)) {
fontfile_t*f = global_fonts;
while(f) {
if(strstr(f->filename, name)) {
@@
-535,6
+549,7
@@
DisplayFontParam *GFXGlobalParams::getDisplayFont(GString *fontName)
}
f = f->next;
}
}
f = f->next;
}
+#endif
/* if we didn't find anything up to now, try looking for the
font via fontconfig */
/* 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) {
}
if(filename) {
+ msg("<verbose> Font %s maps to %s\n", name, filename);
DisplayFontParamKind kind = detectFontType(filename);
DisplayFontParam *dfp = new DisplayFontParam(new GString(fontName), kind);
if(kind == displayFontTT) {
DisplayFontParamKind kind = detectFontType(filename);
DisplayFontParam *dfp = new DisplayFontParam(new GString(fontName), kind);
if(kind == displayFontTT) {
@@
-2477,7
+2493,6
@@
void addGlobalFontDir(const char*dirname)
{
#ifdef HAVE_DIRENT_H
msg("<notice> Adding %s to font directories", dirname);
{
#ifdef HAVE_DIRENT_H
msg("<notice> Adding %s to font directories", dirname);
- lastfontdir = strdup(dirname);
DIR*dir = opendir(dirname);
if(!dir) {
msg("<warning> Couldn't open directory %s", dirname);
DIR*dir = opendir(dirname);
if(!dir) {
msg("<warning> Couldn't open directory %s", dirname);
@@
-2511,8
+2526,18
@@
void addGlobalFontDir(const char*dirname)
}
closedir(dir);
#else
}
closedir(dir);
#else
- msg("<warning> No dirent.h- unable to add font dir %s", dirname);
+ msg("<warning> No dirent.h");
#endif
#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,
}
void GFXOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,