From 57466dec7684e1251448caafb1aae986da3b70d3 Mon Sep 17 00:00:00 2001 From: kramm Date: Fri, 22 Oct 2004 16:38:20 +0000 Subject: [PATCH] added some log messages to the font directory routines. --- pdf2swf/SWFOutputDev.cc | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index 9fd6ee0..00499a9 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -23,6 +23,12 @@ #include #include #include "../config.h" +#ifdef HAVE_DIRENT_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif #ifdef HAVE_FONTCONFIG_H #include #endif @@ -1908,6 +1914,8 @@ void pdfswf_setparameter(char*name, char*value) caplinewidth = atof(value); } else if(!strcmp(name, "zoom")) { zoom = atoi(value); + } else if(!strcmp(name, "fontdir")) { + pdfswf_addfontdir(value); } else { swfoutput_setparameter(name, value); } @@ -1924,6 +1932,54 @@ void pdfswf_addfont(char*filename) } } +void pdfswf_addfontdir(char*dirname) +{ +#ifdef HAVE_DIRENT_H + msg(" Adding %s to font directories", dirname); + DIR*dir = opendir(dirname); + if(!dir) { + msg(" Couldn't open directory %s\n", dirname); + return; + } + struct dirent*ent; + while(1) { + ent = readdir (dir); + if (!ent) + break; + int l; + char*name = ent->d_name; + char type = 0; + if(!name) continue; + l=strlen(name); + if(l<4) + continue; + if(!strncasecmp(&name[l-4], ".pfa", 4)) + type=1; + if(!strncasecmp(&name[l-4], ".pfb", 4)) + type=3; + if(!strncasecmp(&name[l-4], ".ttf", 4)) + type=2; + if(type) + { + char*fontname = (char*)malloc(strlen(dirname)+strlen(name)+2); + strcpy(fontname, dirname); +#ifdef WIN32 + strcat(fontname, "\\"); +#else + strcat(fontname, "/"); +#endif + strcat(fontname, name); + msg(" Adding %s to fonts", fontname); + pdfswf_addfont(fontname); + } + } + closedir(dir); +#else + msg(" No dirent.h- unable to add font dir %s"); +#endif +} + + typedef struct _pdf_doc_internal { int protect; -- 1.7.10.4