git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
finished inner function implementation
[swftools.git]
/
lib
/
pdf
/
GFXOutputDev.cc
diff --git
a/lib/pdf/GFXOutputDev.cc
b/lib/pdf/GFXOutputDev.cc
index
def11a6
..
5f397f1
100644
(file)
--- a/
lib/pdf/GFXOutputDev.cc
+++ b/
lib/pdf/GFXOutputDev.cc
@@
-97,8
+97,6
@@
static int fontnum = 0;
/* config */
/* config */
-static char* lastfontdir = 0;
-
struct fontentry {
const char*pdffont;
const char*filename;
struct fontentry {
const char*pdffont;
const char*filename;
@@
-416,6
+414,14
@@
char* fontconfig_searchForFont(char*name)
config_use_fontconfig = 0;
return 0;
}
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("<verbose> FontConfig initialized. Found %d fonts", set?set->nfont:0);
if(!set || !set->nfont) {
FcFontSet * set = FcConfigGetFonts(config, FcSetSystem);
msg("<verbose> 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;
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)) {
fontfile_t*f = global_fonts;
while(f) {
if(strstr(f->filename, name)) {
@@
-535,6
+543,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
+555,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) {
@@
-579,6
+589,7
@@
GFXOutputDev::GFXOutputDev(InfoOutputDev*info, PDFDoc*doc)
this->user_clipy1 = 0;
this->user_clipx2 = 0;
this->user_clipy2 = 0;
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;
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)
{
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("<debug> | moveTo %.2f %.2f", line->x,line->y);
while(line) {
if(line->type == gfx_moveTo) {
msg("<debug> | moveTo %.2f %.2f", line->x,line->y);
@@
-1609,7
+1627,8
@@
void GFXOutputDev::processLink(Link *link, Catalog *catalog)
LinkDest *dest=NULL;
if (ha->getDest()==NULL)
dest=catalog->findDest(ha->getNamedDest());
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();
if (dest){
if (dest->isPageRef()){
Ref pageref=dest->getPageRef();
@@
-1618,6
+1637,7
@@
void GFXOutputDev::processLink(Link *link, Catalog *catalog)
else page=dest->getPageNum();
sprintf(buf, "%d", page);
s = strdup(buf);
else page=dest->getPageNum();
sprintf(buf, "%d", page);
s = strdup(buf);
+ delete dest;
}
}
break;
}
}
break;
@@
-1882,6
+1902,7
@@
void GFXOutputDev::updateFont(GfxState *state)
}
this->current_fontinfo = this->info->getFont(id);
}
this->current_fontinfo = this->info->getFont(id);
+
if(!this->current_fontinfo) {
msg("<error> Internal Error: no fontinfo for font %s", id);
return;
if(!this->current_fontinfo) {
msg("<error> Internal Error: no fontinfo for font %s", id);
return;
@@
-1890,7
+1911,7
@@
void GFXOutputDev::updateFont(GfxState *state)
dumpFontInfo("<verbose>", gfxFont);
}
dumpFontInfo("<verbose>", gfxFont);
}
- current_gfxfont = this->current_fontinfo->gfxfont;
+ current_gfxfont = this->current_fontinfo->getGfxFont();
device->addfont(device, current_gfxfont);
free(id);
device->addfont(device, current_gfxfont);
free(id);
@@
-2436,7
+2457,7
@@
void addGlobalFont(const char*filename)
}
f->len = len;
}
f->len = len;
- msg("<notice> Adding font \"%s\".", filename);
+ msg("<verbose> Adding font \"%s\".", filename);
if(global_fonts_next) {
global_fonts_next->next = f;
global_fonts_next = global_fonts_next->next;
if(global_fonts_next) {
global_fonts_next->next = f;
global_fonts_next = global_fonts_next->next;
@@
-2467,14
+2488,13
@@
void addGlobalLanguageDir(const char*dir)
void addGlobalFontDir(const char*dirname)
{
#ifdef HAVE_DIRENT_H
void addGlobalFontDir(const char*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);
return;
}
struct dirent*ent;
DIR*dir = opendir(dirname);
if(!dir) {
msg("<warning> Couldn't open directory %s", dirname);
return;
}
struct dirent*ent;
+ int fonts = 0;
while(1) {
ent = readdir (dir);
if (!ent)
while(1) {
ent = readdir (dir);
if (!ent)
@@
-2498,11
+2518,13
@@
void addGlobalFontDir(const char*dirname)
strcat(fontname, dirseparator());
strcat(fontname, name);
addGlobalFont(fontname);
strcat(fontname, dirseparator());
strcat(fontname, name);
addGlobalFont(fontname);
+ fonts++;
}
}
}
}
+ msg("<notice> Added %s to font directories (%d fonts)", dirname, fonts);
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
}