git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
small fixes
[swftools.git]
/
lib
/
pdf
/
GFXOutputDev.cc
diff --git
a/lib/pdf/GFXOutputDev.cc
b/lib/pdf/GFXOutputDev.cc
index
2b0e892
..
9c8b9c7
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) {
@@
-1318,7
+1328,6
@@
void GFXOutputDev::beginString(GfxState *state, GString *s)
if(current_text_stroke) {
msg("<error> Error: Incompatible change of text rendering to %d while inside cliptext", render);
}
if(current_text_stroke) {
msg("<error> Error: Incompatible change of text rendering to %d while inside cliptext", render);
}
-
msg("<trace> beginString(%s) render=%d", makeStringPrintable(s->getCString()), render);
}
msg("<trace> beginString(%s) render=%d", makeStringPrintable(s->getCString()), render);
}
@@
-1353,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) {
// check for invisible text -- this is used by Acrobat Capture
if (render == RENDER_INVISIBLE) {
- col.a = 255;
+ col.a = 0;
if(!config_extrafontdata)
return;
}
if(!config_extrafontdata)
return;
}
@@
-1367,11
+1376,12
@@
void GFXOutputDev::drawChar(GfxState *state, double x, double y,
}
Unicode u = uLen?(_u[0]):0;
}
Unicode u = uLen?(_u[0]):0;
- msg("<debug> 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;
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("<debug> 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);
if(render == RENDER_FILL || render == RENDER_INVISIBLE) {
device->drawchar(device, current_gfxfont, glyphid, &col, &m);
@@
-1529,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("<verbose> Using user clip box %f/%f/%f/%f",x1,y1,x2,y2);
/*if(user_clipy1 > y1)*/ y1 = user_clipy1;
/*if(user_clipy2 < y2)*/ y2 = user_clipy2;
msg("<verbose> 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("<verbose> Bounding box is (%f,%f)-(%f,%f) [shifted by %d/%d]", x1,y1,x2,y2, user_movex, user_movey);
}
//msg("<verbose> Bounding box is (%f,%f)-(%f,%f) [shifted by %d/%d]", x1,y1,x2,y2, user_movex, user_movey);
@@
-1617,7
+1632,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();
@@
-1626,6
+1642,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;
@@
-2445,7
+2462,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;
@@
-2476,14
+2493,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)
@@
-2507,11
+2523,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
}