diff -u -r swftools-0.6.2/pdf2swf/SWFOutputDev.cc swftools-0.6.2.mod/pdf2swf/SWFOutputDev.cc --- swftools-0.6.2/pdf2swf/SWFOutputDev.cc Tue Sep 28 01:46:30 2004 +++ swftools-0.6.2.mod/pdf2swf/SWFOutputDev.cc Mon Oct 11 01:32:50 2004 @@ -24,12 +24,14 @@ #include #include "../config.h" #ifdef HAVE_FONTCONFIG_H -#include +#include #endif //xpdf header files #include "config.h" #include "gfile.h" #include "GString.h" +#include "GList.h" +#include "GHash.h" #include "gmem.h" #include "Object.h" #include "Stream.h" @@ -1211,10 +1213,10 @@ } } - //printf("FONTCONFIG: pattern"); - //FcPatternPrint(pattern); - //printf("FONTCONFIG: match"); - //FcPatternPrint(match); + // printf("FONTCONFIG: pattern"); + // FcPatternPrint(pattern); + // printf("FONTCONFIG: match"); + // FcPatternPrint(match); FcPatternDestroy(pattern); FcPatternDestroy(match); @@ -1232,7 +1234,11 @@ msg(" subsituteFont(%s)", oldname); if(!(fontname = searchForSuitableFont(gfxFont))) { - fontname = "Times-Roman"; + if (!gfxFont->isCIDFont()) { + fontname = "Times-Roman"; + } else { + fontname = oldname; + } } filename = searchFont(fontname); @@ -1744,15 +1750,18 @@ obj.free(); } -void pdfswf_init(char*filename, char*userPassword) +void pdfswf_init() +{ + // read config file + globalParams = new GlobalParams(""); +} + +void pdfswf_start(char*filename, char*userPassword) { GString *fileName = new GString(filename); GString *userPW; Object info; - // read config file - globalParams = new GlobalParams(""); - // open PDF file if (userPassword && userPassword[0]) { userPW = new GString(userPassword); @@ -1806,6 +1815,53 @@ output = new SWFOutputDev(); output->startDoc(doc->getXRef()); +} + +void pdfswf_addcmapdir(const char *coll, const char *path) +{ + GList *list; + GString *collection = new GString(coll); + + list = (GList *)globalParams->cMapDirs->lookup(collection); + + if (!list) { + list = new GList(); + globalParams->cMapDirs->add(collection, list); + collection = 0; + } + + list->append(new GString(path)); + + delete collection; +} + +void pdfswf_addcid2unicode(const char *coll, const char *path) +{ + GString *collection = new GString(coll); + GString *old; + + if ((old = (GString *)globalParams->cidToUnicodes->remove(collection))) { + delete old; + } + + globalParams->cidToUnicodes->add(collection, new GString(path)); +} + +void pdfswf_addunicodemap(const char *encname, const char *path) +{ + GString *encodingName = new GString(encname); + GString *old; + + if ((old = (GString *)globalParams->unicodeMaps->remove(encodingName))) { + delete old; + } + + globalParams->unicodeMaps->add(encodingName, new GString(path)); +} + +void pdfswf_addtounicodedir(const char *path) +{ + globalParams->toUnicodeDirs->append(new GString(path)); } void pdfswf_setparameter(char*name, char*value) diff -u -r swftools-0.6.2/pdf2swf/SWFOutputDev.h swftools-0.6.2.mod/pdf2swf/SWFOutputDev.h --- swftools-0.6.2/pdf2swf/SWFOutputDev.h Sat Sep 11 02:10:33 2004 +++ swftools-0.6.2.mod/pdf2swf/SWFOutputDev.h Sun Oct 10 19:35:35 2004 @@ -21,10 +21,15 @@ #ifndef __pdf_h__ #define __pdf_h__ -void pdfswf_init(char*filename, char*userPassword) ; +void pdfswf_init() ; +void pdfswf_start(char*filename, char*userPassword) ; void pdfswf_setparameter(char*name, char*value); void pdfswf_addfont(char*filename); +void pdfswf_addcmapdir(const char *coll, const char *path); +void pdfswf_addcid2unicode(const char *coll, const char *path); +void pdfswf_addunicodemap(const char *encname, const char *path); +void pdfswf_addtounicodedir(const char *path); void pdfswf_setoutputfilename(char*filename); diff -u -r swftools-0.6.2/pdf2swf/pdf2swf.cc swftools-0.6.2.mod/pdf2swf/pdf2swf.cc --- swftools-0.6.2/pdf2swf/pdf2swf.cc Sat Sep 11 02:10:33 2004 +++ swftools-0.6.2.mod/pdf2swf/pdf2swf.cc Tue Oct 12 00:33:51 2004 @@ -239,6 +239,53 @@ printf("pdf2swf - part of %s %s\n", PACKAGE, VERSION); exit(0); } + else if (!strcmp(name, "c")) + { + int retval = 0; + char *s = strdup(val); + char *c = strchr(s, '='); + if(c && c[0] != '\0' && c[1] != '\0') { + *c = '\0'; + c++; + pdfswf_addcid2unicode(s, c); + retval = 1; + } + free(s); + return retval; + } + else if (!strcmp(name, "u")) + { + int retval = 0; + char *s = strdup(val); + char *c = strchr(s, '='); + if(c && c[0] != '\0' && c[1] != '\0') { + *c = '\0'; + c++; + pdfswf_addunicodemap(s, c); + retval = 1; + } + free(s); + return retval; + } + else if (!strcmp(name, "C")) + { + int retval = 0; + char *s = strdup(val); + char *c = strchr(s, '='); + if(c && c[0] != '\0' && c[1] != '\0') { + *c = '\0'; + c++; + pdfswf_addcmapdir(s, c); + retval = 1; + } + free(s); + return retval; + } + else if (!strcmp(name, "U")) + { + pdfswf_addtounicodedir(val); + return 1; + } else { fprintf(stderr, "Unknown option: -%s\n", name); @@ -283,6 +330,10 @@ {"l","defaultpreloader"}, {"t","stop"}, {"T","flashversion"}, + {"c","cidtounicode"}, + {"u","unicodemap"}, + {"C","cmapdir"}, + {"U","tounicodedir"}, {0,0} }; @@ -333,6 +384,10 @@ " graphic errors)\n"); printf("-s filloverlap Make intersecting shapes overlap, instead of canceling each\n" " other out. (Needed for some Powerpoint PDFs)\n"); + printf("-u encoding=filename Add location of misc. to Unicode mapping file.\n"); + printf("-c collection=filename Add location of CID to Unicode Mapping file.\n"); + printf("-U dirname Add location of ToUnicode file reporitory.\n"); + printf("-C collection=drname Add location of CMap file repository.\n"); printf("Postprocessing options:\n"); #ifndef SYSTEM_BACKTICKS printf("(They might not work because your system call doesn't support command substitution)\n"); @@ -437,6 +492,7 @@ srand(time(0)); #endif #endif + pdfswf_init(); processargs(argn, argv); initLog(0,-1,0,0,-1,loglevel); @@ -483,7 +539,7 @@ msg(" Couldn't find any fonts!"); #endif - pdfswf_init(filename, password); + pdfswf_start(filename, password); pdfswf_setoutputfilename(outputname); int pages = pdfswf_numpages(); diff -u -r swftools-0.6.2/pdf2swf/xpdf/GlobalParams.h swftools-0.6.2.mod/pdf2swf/xpdf/GlobalParams.h --- swftools-0.6.2/pdf2swf/xpdf/GlobalParams.h Sat Sep 18 05:05:29 2004 +++ swftools-0.6.2.mod/pdf2swf/xpdf/GlobalParams.h Sun Oct 10 18:50:24 2004 @@ -107,6 +107,10 @@ //------------------------------------------------------------------------ class GlobalParams { +friend void pdfswf_addcmapdir(const char *coll, const char *path); +friend void pdfswf_addcid2unicode(const char *coll, const char *path); +friend void pdfswf_addunicodemap(const char *encname, const char *path); +friend void pdfswf_addtounicodedir(const char *path); public: // Initialize the global parameters by attempting to read a config