static fontfile_t fonts[2048];
static int fontnum = 0;
+static int config_use_fontconfig = 1;
+
// swf <-> pdf pages
// TODO: move into pdf_doc_t
static int*pages = 0;
// check for invisible text -- this is used by Acrobat Capture
if ((state->getRender() & 3) == 3)
return;
-
+ Gushort *CIDToGIDMap = 0;
GfxFont*font = state->getFont();
if(font->getType() == fontType3) {
state->transform(x, y, &x1, &y1);
Unicode u=0;
- if(_u && uLen)
+ char*name=0;
+
+ if(_u && uLen) {
u = *_u;
+ if (u) {
+ int t;
+ /* find out char name from unicode index
+ TODO: should be precomputed
+ */
+ for(t=0;t<sizeof(nameToUnicodeTab)/sizeof(nameToUnicodeTab[0]);t++) {
+ if(nameToUnicodeTab[t].u == u) {
+ name = nameToUnicodeTab[t].name;
+ break;
+ }
+ }
+ }
+ }
- /* find out the character name */
- char*name=0;
- if(font->isCIDFont() && u) {
+ if(font->isCIDFont()) {
GfxCIDFont*cfont = (GfxCIDFont*)font;
- int t;
- for(t=0;t<sizeof(nameToUnicodeTab)/sizeof(nameToUnicodeTab[0]);t++) {
- /* todo: should be precomputed */
- if(nameToUnicodeTab[t].u == u) {
- name = nameToUnicodeTab[t].name;
- break;
- }
+
+ if(font->getType() == fontCIDType2) {
+ CIDToGIDMap = cfont->getCIDToGID();
}
} else {
Gfx8BitFont*font8;
if(enc && enc[c])
name = enc[c];
}
-
- msg("<debug> drawChar(%f,%f,c='%c' (%d),u=%d <%d>) CID=%d name=\"%s\"\n",x,y,(c&127)>=32?c:'?',c,u, uLen, font->isCIDFont(), FIXNULL(name));
-
- /*x1 = (int)(x1+0.5);
- y1 = (int)(y1+0.5);*/
-
- int ret = swfoutput_drawchar(&output, x1, y1, name, c, u);
+
+ if (CIDToGIDMap) {
+ msg("<debug> drawChar(%f, %f, c='%c' (%d), GID=%d, u=%d <%d>) CID=%d name=\"%s\"\n", x, y, (c&127)>=32?c:'?', c, CIDToGIDMap[c], u, uLen, font->isCIDFont(), FIXNULL(name));
+ swfoutput_drawchar(&output, x1, y1, name, CIDToGIDMap[c], u);
+ } else {
+ msg("<debug> drawChar(%f,%f,c='%c' (%d), u=%d <%d>) CID=%d name=\"%s\"\n",x,y,(c&127)>=32?c:'?',c,u, uLen, font->isCIDFont(), FIXNULL(name));
+ swfoutput_drawchar(&output, x1, y1, name, c, u);
+ }
}
void SWFOutputDev::endString(GfxState *state) {
char*name = getFontName(gfxFont);
char*fontname = 0;
char*filename = 0;
+
+ if(!config_use_fontconfig)
+ return 0;
#ifdef HAVE_FONTCONFIG
FcPattern *pattern, *match;
FcChar8 *v;
static int fcinitcalled = false;
+
+ msg("<debug> searchForSuitableFont(%s)", name);
// call init ony once
if (!fcinitcalled) {
+ msg("<debug> Initializing FontConfig...");
fcinitcalled = true;
- FcInit(); //leaks
+ if(FcInit()) {
+ msg("<debug> FontConfig Initialization failed. Disabling.");
+ config_use_fontconfig = 0;
+ return 0;
+ }
+ msg("<debug> ...initialized FontConfig");
}
+ msg("<debug> FontConfig: Create \"%s\" Family Pattern", name);
pattern = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, name, NULL);
if (gfxFont->isItalic()) // check for italic
+ msg("<debug> FontConfig: Adding Italic Slant");
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
if (gfxFont->isBold()) // check for bold
+ msg("<debug> FontConfig: Adding Bold Weight");
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
+ msg("<debug> FontConfig: Try to match...");
// configure and match using the original font name
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
match = FcFontMatch(0, pattern, &result);
if (FcPatternGetString(match, "family", 0, &v) == FcResultMatch) {
+ msg("<debug> FontConfig: family=%s", (char*)v);
// if we get an exact match
if (strcmp((char *)v, name) == 0) {
if (FcPatternGetString(match, "file", 0, &v) == FcResultMatch) {
if(nfn) fontname = strdup(nfn+1);
else fontname = filename;
}
+ msg("<debug> FontConfig: Returning \"%s\"", fontname);
} else {
// initialize patterns
FcPatternDestroy(pattern);
// now match against serif etc.
if (gfxFont->isSerif()) {
+ msg("<debug> FontConfig: Create Serif Family Pattern");
pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, "serif", NULL);
} else if (gfxFont->isFixedWidth()) {
+ msg("<debug> FontConfig: Create Monospace Family Pattern");
pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, "monospace", NULL);
} else {
+ msg("<debug> FontConfig: Create Sans Family Pattern");
pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, "sans", NULL);
}
// check for italic
if (gfxFont->isItalic()) {
+ msg("<debug> FontConfig: Adding Italic Slant");
int bb = FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
}
// check for bold
if (gfxFont->isBold()) {
+ msg("<debug> FontConfig: Adding Bold Weight");
int bb = FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
}
+ msg("<debug> FontConfig: Try to match... (2)");
// configure and match using serif etc
FcConfigSubstitute (0, pattern, FcMatchPattern);
FcDefaultSubstitute (pattern);
if(nfn) fontname = strdup(nfn+1);
else fontname = filename;
}
+ msg("<debug> FontConfig: Returning \"%s\"", fontname);
}
}
pdfswf_addfontdir(value);
} else if(!strcmp(name, "languagedir")) {
pdfswf_addlanguagedir(value);
+ } else if(!strcmp(name, "fontconfig")) {
+ config_use_fontconfig = atoi(value);
} else {
swfoutput_setparameter(name, value);
}