Commit bf7e0e98 authored by Albert Astals Cid's avatar Albert Astals Cid

Merge xpdf302branch in HEAD as noone vetoed it.

Testing more than welcome
parent ba74bb3b
2007-04-25 Albert Astals Cid <aacid@kde.org>
* ChangeLog:
* configure.ac:
* fofi/FoFiTrueType.cc:
* fofi/FoFiTrueType.h:
* fofi/FoFiType1.cc:
* fofi/FoFiType1C.cc:
* fofi/FoFiType1C.h:
* glib/poppler-action.cc:
* glib/poppler-document.cc:
* glib/poppler-page.cc:
* goo/FixedPoint.cc:
* goo/FixedPoint.h:
* goo/GooString.cc:
* goo/GooString.h:
* goo/Makefile.am:
* goo/gfile.cc:
* goo/gmem.cc:
* goo/gmem.h:
* poppler/ABWOutputDev.cc:
* poppler/ABWOutputDev.h:
* poppler/Annot.cc:
* poppler/Annot.h:
* poppler/ArthurOutputDev.cc:
* poppler/Catalog.cc:
* poppler/Catalog.h:
* poppler/CharCodeToUnicode.cc:
* poppler/DCTStream.cc:
* poppler/DCTStream.h:
* poppler/Decrypt.cc:
* poppler/Decrypt.h:
* poppler/Dict.cc:
* poppler/Dict.h:
* poppler/FontInfo.cc:
* poppler/Form.cc:
* poppler/Form.h:
* poppler/Function.cc:
* poppler/Function.h:
* poppler/Gfx.cc:
* poppler/Gfx.h:
* poppler/GfxFont.cc:
* poppler/GfxFont.h:
* poppler/GfxState.cc:
* poppler/GfxState.h:
* poppler/GlobalParams.cc:
* poppler/GlobalParams.h:
* poppler/JBIG2Stream.cc:
* poppler/JBIG2Stream.h:
* poppler/JPXStream.cc:
* poppler/JPXStream.h:
* poppler/Lexer.cc:
* poppler/Link.cc:
* poppler/Link.h:
* poppler/Makefile.am:
* poppler/Object.cc:
* poppler/Object.h:
* poppler/Outline.cc:
* poppler/OutputDev.cc:
* poppler/OutputDev.h:
* poppler/PDFDoc.cc:
* poppler/PDFDoc.h:
* poppler/PSOutputDev.cc:
* poppler/PSOutputDev.h:
* poppler/PSTokenizer.cc:
* poppler/Page.cc:
* poppler/Page.h:
* poppler/PageLabelInfo.cc:
* poppler/Parser.cc:
* poppler/Parser.h:
* poppler/PreScanOutputDev.cc:
* poppler/PreScanOutputDev.h:
* poppler/SecurityHandler.cc:
* poppler/SecurityHandler.h:
* poppler/SplashOutputDev.cc:
* poppler/SplashOutputDev.h:
* poppler/Stream.cc:
* poppler/Stream.h:
* poppler/TextOutputDev.cc:
* poppler/TextOutputDev.h:
* poppler/XRef.cc:
* poppler/XRef.h:
* qt/poppler-document.cc:
* qt/poppler-page-transition.cc:
* qt/poppler-page.cc:
* qt/poppler-private.h:
* qt4/src/poppler-annotation-helper.h:
* qt4/src/poppler-document.cc:
* qt4/src/poppler-embeddedfile.cc:
* qt4/src/poppler-form.cc:
* qt4/src/poppler-page.cc:
* qt4/src/poppler-private.h:
* splash/Splash.cc:
* splash/Splash.h:
* splash/SplashBitmap.cc:
* splash/SplashBitmap.h:
* splash/SplashClip.cc:
* splash/SplashClip.h:
* splash/SplashFTFont.cc:
* splash/SplashFTFont.h:
* splash/SplashFTFontEngine.cc:
* splash/SplashFTFontEngine.h:
* splash/SplashFTFontFile.cc:
* splash/SplashFTFontFile.h:
* splash/SplashFont.cc:
* splash/SplashFont.h:
* splash/SplashFontEngine.cc:
* splash/SplashFontEngine.h:
* splash/SplashFontFile.cc:
* splash/SplashFontFile.h:
* splash/SplashMath.h:
* splash/SplashPath.cc:
* splash/SplashPath.h:
* splash/SplashPattern.cc:
* splash/SplashPattern.h:
* splash/SplashScreen.cc:
* splash/SplashScreen.h:
* splash/SplashState.cc:
* splash/SplashState.h:
* splash/SplashT1Font.cc:
* splash/SplashT1Font.h:
* splash/SplashT1FontEngine.cc:
* splash/SplashT1FontFile.cc:
* splash/SplashT1FontFile.h:
* splash/SplashTypes.h:
* splash/SplashXPath.cc:
* splash/SplashXPath.h:
* splash/SplashXPathScanner.cc:
* splash/SplashXPathScanner.h:
* utils/HtmlOutputDev.cc:
* utils/HtmlOutputDev.h:
* utils/pdffonts.cc:
* utils/pdfinfo.cc:
* utils/pdftoabw.cc:
* utils/pdftohtml.cc:
* utils/pdftoppm.cc:
* utils/pdftops.cc:
* utils/pdftotext.cc:
Merge xpdf 3.02 changes
2007-04-15 Pino Toscano <pino@kde.org> 2007-04-15 Pino Toscano <pino@kde.org>
reviewed by: Albert Astals Cid <aacid@kde.org> reviewed by: Albert Astals Cid <aacid@kde.org>
......
...@@ -40,6 +40,10 @@ dnl ##### Checks for header files. ...@@ -40,6 +40,10 @@ dnl ##### Checks for header files.
AC_PATH_XTRA AC_PATH_XTRA
AC_HEADER_DIRENT AC_HEADER_DIRENT
AC_ARG_ENABLE(exceptions,
[ --enable-exceptions use C++ exceptions],
AC_DEFINE([USE_EXCEPTIONS], [], [Throw exceptions to deal with not enough memory and similar problems]))
dnl ##### Switch over to C++. This will make the checks below a little dnl ##### Switch over to C++. This will make the checks below a little
dnl ##### bit stricter (requiring function prototypes in include files). dnl ##### bit stricter (requiring function prototypes in include files).
dnl ##### (99% of xpdf is written in C++.) dnl ##### (99% of xpdf is written in C++.)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "goo/gmem.h" #include "goo/gmem.h"
#include "goo/GooString.h" #include "goo/GooString.h"
#include "goo/GooHash.h" #include "goo/GooHash.h"
#include "FoFiType1C.h"
#include "FoFiTrueType.h" #include "FoFiTrueType.h"
// //
...@@ -108,8 +109,11 @@ struct TrueTypeLoca { ...@@ -108,8 +109,11 @@ struct TrueTypeLoca {
#define cmapTag 0x636d6170 #define cmapTag 0x636d6170
#define glyfTag 0x676c7966 #define glyfTag 0x676c7966
#define headTag 0x68656164 #define headTag 0x68656164
#define hheaTag 0x68686561
#define hmtxTag 0x686d7478
#define locaTag 0x6c6f6361 #define locaTag 0x6c6f6361
#define nameTag 0x6e616d65 #define nameTag 0x6e616d65
#define os2Tag 0x4f532f32
#define postTag 0x706f7374 #define postTag 0x706f7374
static int cmpTrueTypeLocaOffset(const void *p1, const void *p2) { static int cmpTrueTypeLocaOffset(const void *p1, const void *p2) {
...@@ -392,6 +396,28 @@ int FoFiTrueType::mapNameToGID(char *name) { ...@@ -392,6 +396,28 @@ int FoFiTrueType::mapNameToGID(char *name) {
return nameToGID->lookupInt(name); return nameToGID->lookupInt(name);
} }
Gushort *FoFiTrueType::getCIDToGIDMap(int *nCIDs) {
FoFiType1C *ff;
Gushort *map;
int i;
*nCIDs = 0;
if (!openTypeCFF) {
return NULL;
}
i = seekTable("CFF ");
if (!checkRegion(tables[i].offset, tables[i].len)) {
return NULL;
}
if (!(ff = FoFiType1C::make((char *)file + tables[i].offset,
tables[i].len))) {
return NULL;
}
map = ff->getCIDToGIDMap(nCIDs);
delete ff;
return map;
}
int FoFiTrueType::getEmbeddingRights() { int FoFiTrueType::getEmbeddingRights() {
int i, fsType; int i, fsType;
GBool ok; GBool ok;
...@@ -420,13 +446,19 @@ void FoFiTrueType::convertToType42(char *psName, char **encoding, ...@@ -420,13 +446,19 @@ void FoFiTrueType::convertToType42(char *psName, char **encoding,
Gushort *codeToGID, Gushort *codeToGID,
FoFiOutputFunc outputFunc, FoFiOutputFunc outputFunc,
void *outputStream) { void *outputStream) {
char buf[512]; GooString *buf;
GBool ok; GBool ok;
if (openTypeCFF) {
return;
}
// write the header // write the header
ok = gTrue; ok = gTrue;
sprintf(buf, "%%!PS-TrueTypeFont-%g\n", (double)getS32BE(0, &ok) / 65536.0); buf = GooString::format("%!PS-TrueTypeFont-{0:2g}\n",
(*outputFunc)(outputStream, buf, strlen(buf)); (double)getS32BE(0, &ok) / 65536.0);
(*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
// begin the font dictionary // begin the font dictionary
(*outputFunc)(outputStream, "10 dict begin\n", 14); (*outputFunc)(outputStream, "10 dict begin\n", 14);
...@@ -435,9 +467,10 @@ void FoFiTrueType::convertToType42(char *psName, char **encoding, ...@@ -435,9 +467,10 @@ void FoFiTrueType::convertToType42(char *psName, char **encoding,
(*outputFunc)(outputStream, " def\n", 5); (*outputFunc)(outputStream, " def\n", 5);
(*outputFunc)(outputStream, "/FontType 42 def\n", 17); (*outputFunc)(outputStream, "/FontType 42 def\n", 17);
(*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30);
sprintf(buf, "/FontBBox [%d %d %d %d] def\n", buf = GooString::format("/FontBBox [{0:d} {1:d} {2:d} {3:d}] def\n",
bbox[0], bbox[1], bbox[2], bbox[3]); bbox[0], bbox[1], bbox[2], bbox[3]);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
(*outputFunc)(outputStream, "/PaintType 0 def\n", 17); (*outputFunc)(outputStream, "/PaintType 0 def\n", 17);
// write the guts of the dictionary // write the guts of the dictionary
...@@ -449,20 +482,47 @@ void FoFiTrueType::convertToType42(char *psName, char **encoding, ...@@ -449,20 +482,47 @@ void FoFiTrueType::convertToType42(char *psName, char **encoding,
(*outputFunc)(outputStream, "FontName currentdict end definefont pop\n", 40); (*outputFunc)(outputStream, "FontName currentdict end definefont pop\n", 40);
} }
void FoFiTrueType::convertToType1(char *psName, char **newEncoding,
GBool ascii, FoFiOutputFunc outputFunc,
void *outputStream) {
FoFiType1C *ff;
int i;
if (!openTypeCFF) {
return;
}
i = seekTable("CFF ");
if (!checkRegion(tables[i].offset, tables[i].len)) {
return;
}
if (!(ff = FoFiType1C::make((char *)file + tables[i].offset,
tables[i].len))) {
return;
}
ff->convertToType1(psName, newEncoding, ascii, outputFunc, outputStream);
delete ff;
}
void FoFiTrueType::convertToCIDType2(char *psName, void FoFiTrueType::convertToCIDType2(char *psName,
Gushort *cidMap, int nCIDs, Gushort *cidMap, int nCIDs,
GBool needVerticalMetrics, GBool needVerticalMetrics,
FoFiOutputFunc outputFunc, FoFiOutputFunc outputFunc,
void *outputStream) { void *outputStream) {
char buf[512]; GooString *buf;
Gushort cid; Gushort cid;
GBool ok; GBool ok;
int i, j, k; int i, j, k;
if (openTypeCFF) {
return;
}
// write the header // write the header
ok = gTrue; ok = gTrue;
sprintf(buf, "%%!PS-TrueTypeFont-%g\n", (double)getS32BE(0, &ok) / 65536.0); buf = GooString::format("%!PS-TrueTypeFont-{0:2g}\n",
(*outputFunc)(outputStream, buf, strlen(buf)); (double)getS32BE(0, &ok) / 65536.0);
(*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
// begin the font dictionary // begin the font dictionary
(*outputFunc)(outputStream, "20 dict begin\n", 14); (*outputFunc)(outputStream, "20 dict begin\n", 14);
...@@ -478,8 +538,9 @@ void FoFiTrueType::convertToCIDType2(char *psName, ...@@ -478,8 +538,9 @@ void FoFiTrueType::convertToCIDType2(char *psName,
(*outputFunc)(outputStream, " end def\n", 10); (*outputFunc)(outputStream, " end def\n", 10);
(*outputFunc)(outputStream, "/GDBytes 2 def\n", 15); (*outputFunc)(outputStream, "/GDBytes 2 def\n", 15);
if (cidMap) { if (cidMap) {
sprintf(buf, "/CIDCount %d def\n", nCIDs); buf = GooString::format("/CIDCount {0:d} def\n", nCIDs);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
if (nCIDs > 32767) { if (nCIDs > 32767) {
(*outputFunc)(outputStream, "/CIDMap [", 9); (*outputFunc)(outputStream, "/CIDMap [", 9);
for (i = 0; i < nCIDs; i += 32768 - 16) { for (i = 0; i < nCIDs; i += 32768 - 16) {
...@@ -488,8 +549,10 @@ void FoFiTrueType::convertToCIDType2(char *psName, ...@@ -488,8 +549,10 @@ void FoFiTrueType::convertToCIDType2(char *psName,
(*outputFunc)(outputStream, " ", 2); (*outputFunc)(outputStream, " ", 2);
for (k = 0; k < 16 && i+j+k < nCIDs; ++k) { for (k = 0; k < 16 && i+j+k < nCIDs; ++k) {
cid = cidMap[i+j+k]; cid = cidMap[i+j+k];
sprintf(buf, "%02x%02x", (cid >> 8) & 0xff, cid & 0xff); buf = GooString::format("{0:02x}{1:02x}",
(*outputFunc)(outputStream, buf, strlen(buf)); (cid >> 8) & 0xff, cid & 0xff);
(*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
} }
(*outputFunc)(outputStream, "\n", 1); (*outputFunc)(outputStream, "\n", 1);
} }
...@@ -503,8 +566,10 @@ void FoFiTrueType::convertToCIDType2(char *psName, ...@@ -503,8 +566,10 @@ void FoFiTrueType::convertToCIDType2(char *psName,
(*outputFunc)(outputStream, " ", 2); (*outputFunc)(outputStream, " ", 2);
for (j = 0; j < 16 && i+j < nCIDs; ++j) { for (j = 0; j < 16 && i+j < nCIDs; ++j) {
cid = cidMap[i+j]; cid = cidMap[i+j];
sprintf(buf, "%02x%02x", (cid >> 8) & 0xff, cid & 0xff); buf = GooString::format("{0:02x}{1:02x}",
(*outputFunc)(outputStream, buf, strlen(buf)); (cid >> 8) & 0xff, cid & 0xff);
(*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
} }
(*outputFunc)(outputStream, "\n", 1); (*outputFunc)(outputStream, "\n", 1);
} }
...@@ -512,27 +577,34 @@ void FoFiTrueType::convertToCIDType2(char *psName, ...@@ -512,27 +577,34 @@ void FoFiTrueType::convertToCIDType2(char *psName,
} }
} else { } else {
// direct mapping - just fill the string(s) with s[i]=i // direct mapping - just fill the string(s) with s[i]=i
sprintf(buf, "/CIDCount %d def\n", nGlyphs); buf = GooString::format("/CIDCount {0:d} def\n", nGlyphs);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
if (nGlyphs > 32767) { if (nGlyphs > 32767) {
(*outputFunc)(outputStream, "/CIDMap [\n", 10); (*outputFunc)(outputStream, "/CIDMap [\n", 10);
for (i = 0; i < nGlyphs; i += 32767) { for (i = 0; i < nGlyphs; i += 32767) {
j = nGlyphs - i < 32767 ? nGlyphs - i : 32767; j = nGlyphs - i < 32767 ? nGlyphs - i : 32767;
sprintf(buf, " %d string 0 1 %d {\n", 2 * j, j - 1); buf = GooString::format(" {0:d} string 0 1 {1:d} {{\n", 2 * j, j - 1);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
sprintf(buf, " 2 copy dup 2 mul exch %d add -8 bitshift put\n", i); delete buf;
(*outputFunc)(outputStream, buf, strlen(buf)); buf = GooString::format(" 2 copy dup 2 mul exch {0:d} add -8 bitshift put\n",
sprintf(buf, " 1 index exch dup 2 mul 1 add exch %d add" i);
" 255 and put\n", i); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
(*outputFunc)(outputStream, buf, strlen(buf)); delete buf;
buf = GooString::format(" 1 index exch dup 2 mul 1 add exch {0:d} add"
" 255 and put\n", i);
(*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
(*outputFunc)(outputStream, " } for\n", 8); (*outputFunc)(outputStream, " } for\n", 8);
} }
(*outputFunc)(outputStream, "] def\n", 6); (*outputFunc)(outputStream, "] def\n", 6);
} else { } else {
sprintf(buf, "/CIDMap %d string\n", 2 * nGlyphs); buf = GooString::format("/CIDMap {0:d} string\n", 2 * nGlyphs);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
sprintf(buf, " 0 1 %d {\n", nGlyphs - 1); delete buf;
(*outputFunc)(outputStream, buf, strlen(buf)); buf = GooString::format(" 0 1 {0:d} {{\n", nGlyphs - 1);
(*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
(*outputFunc)(outputStream, (*outputFunc)(outputStream,
" 2 copy dup 2 mul exch -8 bitshift put\n", 42); " 2 copy dup 2 mul exch -8 bitshift put\n", 42);
(*outputFunc)(outputStream, (*outputFunc)(outputStream,
...@@ -542,9 +614,10 @@ void FoFiTrueType::convertToCIDType2(char *psName, ...@@ -542,9 +614,10 @@ void FoFiTrueType::convertToCIDType2(char *psName,
} }
} }
(*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30);
sprintf(buf, "/FontBBox [%d %d %d %d] def\n", buf = GooString::format("/FontBBox [{0:d} {1:d} {2:d} {3:d}] def\n",
bbox[0], bbox[1], bbox[2], bbox[3]); bbox[0], bbox[1], bbox[2], bbox[3]);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
(*outputFunc)(outputStream, "/PaintType 0 def\n", 17); (*outputFunc)(outputStream, "/PaintType 0 def\n", 17);
(*outputFunc)(outputStream, "/Encoding [] readonly def\n", 26); (*outputFunc)(outputStream, "/Encoding [] readonly def\n", 26);
(*outputFunc)(outputStream, "/CharStrings 1 dict dup begin\n", 30); (*outputFunc)(outputStream, "/CharStrings 1 dict dup begin\n", 30);
...@@ -560,14 +633,39 @@ void FoFiTrueType::convertToCIDType2(char *psName, ...@@ -560,14 +633,39 @@ void FoFiTrueType::convertToCIDType2(char *psName,
56); 56);
} }
void FoFiTrueType::convertToCIDType0(char *psName,
FoFiOutputFunc outputFunc,
void *outputStream) {
FoFiType1C *ff;
int i;
if (!openTypeCFF) {
return;
}
i = seekTable("CFF ");
if (!checkRegion(tables[i].offset, tables[i].len)) {
return;
}
if (!(ff = FoFiType1C::make((char *)file + tables[i].offset,
tables[i].len))) {
return;
}
ff->convertToCIDType0(psName, outputFunc, outputStream);
delete ff;
}
void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, int nCIDs, void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, int nCIDs,
GBool needVerticalMetrics, GBool needVerticalMetrics,
FoFiOutputFunc outputFunc, FoFiOutputFunc outputFunc,
void *outputStream) { void *outputStream) {
char buf[512]; GooString *buf;
GooString *sfntsName; GooString *sfntsName;
int n, i, j; int n, i, j;
if (openTypeCFF) {
return;
}
// write the Type 42 sfnts array // write the Type 42 sfnts array
sfntsName = (new GooString(psName))->append("_sfnts"); sfntsName = (new GooString(psName))->append("_sfnts");
cvtSfnts(outputFunc, outputStream, sfntsName, needVerticalMetrics); cvtSfnts(outputFunc, outputStream, sfntsName, needVerticalMetrics);
...@@ -579,28 +677,33 @@ void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, int nCIDs, ...@@ -579,28 +677,33 @@ void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, int nCIDs,
(*outputFunc)(outputStream, "10 dict begin\n", 14); (*outputFunc)(outputStream, "10 dict begin\n", 14);
(*outputFunc)(outputStream, "/FontName /", 11); (*outputFunc)(outputStream, "/FontName /", 11);
(*outputFunc)(outputStream, psName, strlen(psName)); (*outputFunc)(outputStream, psName, strlen(psName));
sprintf(buf, "_%02x def\n", i >> 8); buf = GooString::format("_{0:02x} def\n", i >> 8);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
(*outputFunc)(outputStream, "/FontType 42 def\n", 17); (*outputFunc)(outputStream, "/FontType 42 def\n", 17);
(*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30);
sprintf(buf, "/FontBBox [%d %d %d %d] def\n", buf = GooString::format("/FontBBox [{0:d} {1:d} {2:d} {3:d}] def\n",
bbox[0], bbox[1], bbox[2], bbox[3]); bbox[0], bbox[1], bbox[2], bbox[3]);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
(*outputFunc)(outputStream, "/PaintType 0 def\n", 17); (*outputFunc)(outputStream, "/PaintType 0 def\n", 17);
(*outputFunc)(outputStream, "/sfnts ", 7); (*outputFunc)(outputStream, "/sfnts ", 7);
(*outputFunc)(outputStream, psName, strlen(psName)); (*outputFunc)(outputStream, psName, strlen(psName));
(*outputFunc)(outputStream, "_sfnts def\n", 11); (*outputFunc)(outputStream, "_sfnts def\n", 11);
(*outputFunc)(outputStream, "/Encoding 256 array\n", 20); (*outputFunc)(outputStream, "/Encoding 256 array\n", 20);
for (j = 0; j < 256 && i+j < n; ++j) { for (j = 0; j < 256 && i+j < n; ++j) {
sprintf(buf, "dup %d /c%02x put\n", j, j); buf = GooString::format("dup {0:d} /c{1:02x} put\n", j, j);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
} }
(*outputFunc)(outputStream, "readonly def\n", 13); (*outputFunc)(outputStream, "readonly def\n", 13);
(*outputFunc)(outputStream, "/CharStrings 257 dict dup begin\n", 32); (*outputFunc)(outputStream, "/CharStrings 257 dict dup begin\n", 32);
(*outputFunc)(outputStream, "/.notdef 0 def\n", 15); (*outputFunc)(outputStream, "/.notdef 0 def\n", 15);
for (j = 0; j < 256 && i+j < n; ++j) { for (j = 0; j < 256 && i+j < n; ++j) {
sprintf(buf, "/c%02x %d def\n", j, cidMap ? cidMap[i+j] : i+j); buf = GooString::format("/c{0:02x} {1:d} def\n",
(*outputFunc)(outputStream, buf, strlen(buf)); j, cidMap ? cidMap[i+j] : i+j);
(*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
} }
(*outputFunc)(outputStream, "end readonly def\n", 17); (*outputFunc)(outputStream, "end readonly def\n", 17);
(*outputFunc)(outputStream, (*outputFunc)(outputStream,
...@@ -617,21 +720,44 @@ void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, int nCIDs, ...@@ -617,21 +720,44 @@ void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, int nCIDs,
(*outputFunc)(outputStream, "/FMapType 2 def\n", 16); (*outputFunc)(outputStream, "/FMapType 2 def\n", 16);
(*outputFunc)(outputStream, "/Encoding [\n", 12); (*outputFunc)(outputStream, "/Encoding [\n", 12);
for (i = 0; i < n; i += 256) { for (i = 0; i < n; i += 256) {
sprintf(buf, "%d\n", i >> 8); buf = GooString::format("{0:d}\n", i >> 8);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
} }
(*outputFunc)(outputStream, "] def\n", 6); (*outputFunc)(outputStream, "] def\n", 6);
(*outputFunc)(outputStream, "/FDepVector [\n", 14); (*outputFunc)(outputStream, "/FDepVector [\n", 14);
for (i = 0; i < n; i += 256) { for (i = 0; i < n; i += 256) {
(*outputFunc)(outputStream, "/", 1); (*outputFunc)(outputStream, "/", 1);
(*outputFunc)(outputStream, psName, strlen(psName)); (*outputFunc)(outputStream, psName, strlen(psName));
sprintf(buf, "_%02x findfont\n", i >> 8); buf = GooString::format("_{0:02x} findfont\n", i >> 8);
(*outputFunc)(outputStream, buf, strlen(buf)); (*outputFunc)(outputStream, buf->getCString(), buf->getLength());
delete buf;
} }
(*outputFunc)(outputStream, "] def\n", 6); (*outputFunc)(outputStream, "] def\n", 6);
(*outputFunc)(outputStream, "FontName currentdict end definefont pop\n", 40); (*outputFunc)(outputStream, "FontName currentdict end definefont pop\n", 40);
} }
void FoFiTrueType::convertToType0(char *psName,
FoFiOutputFunc outputFunc,
void *outputStream) {
FoFiType1C *ff;
int i;
if (!openTypeCFF) {
return;
}
i = seekTable("CFF ");
if (!checkRegion(tables[i].offset, tables[i].len)) {
return;
}
if (!(ff = FoFiType1C::make((char *)file + tables[i].offset,
tables[i].len))) {
return;
}
ff->convertToType0(psName, outputFunc, outputStream);
delete ff;
}
void FoFiTrueType::writeTTF(FoFiOutputFunc outputFunc, void FoFiTrueType::writeTTF(FoFiOutputFunc outputFunc,
void *outputStream, char *name, void *outputStream, char *name,
Gushort *codeToGID) { Gushort *codeToGID) {
...@@ -673,12 +799,50 @@ void FoFiTrueType::writeTTF(FoFiOutputFunc outputFunc, ...@@ -673,12 +799,50 @@ void FoFiTrueType::writeTTF(FoFiOutputFunc outputFunc,
0, 0, 0, 0, // min Type 1 memory 0, 0, 0, 0, // min Type 1 memory
0, 0, 0, 0 // max Type 1 memory 0, 0, 0, 0 // max Type 1 memory
}; };
GBool missingCmap, missingName, missingPost, unsortedLoca, badCmapLen; static char os2Tab[86] = {
0, 1, // version
0, 1, // xAvgCharWidth
0, 0, // usWeightClass
0, 0, // usWidthClass
0, 0, // fsType
0, 0, // ySubscriptXSize
0, 0, // ySubscriptYSize
0, 0, // ySubscriptXOffset
0, 0, // ySubscriptYOffset
0, 0, // ySuperscriptXSize
0, 0, // ySuperscriptYSize
0, 0, // ySuperscriptXOffset
0, 0, // ySuperscriptYOffset
0, 0, // yStrikeoutSize
0, 0, // yStrikeoutPosition
0, 0, // sFamilyClass
0, 0, 0, 0, 0, // panose
0, 0, 0, 0, 0,
0, 0, 0, 0, // ulUnicodeRange1
0, 0, 0, 0, // ulUnicodeRange2
0, 0, 0, 0, // ulUnicodeRange3
0, 0, 0, 0, // ulUnicodeRange4
0, 0, 0, 0, // achVendID
0, 0, // fsSelection
0, 0, // usFirstCharIndex
0, 0, // usLastCharIndex
0, 0, // sTypoAscender
0, 0, // sTypoDescender
0, 0, // sTypoLineGap
0, 0, // usWinAscent
0, 0, // usWinDescent
0, 0, 0, 0, // ulCodePageRange1
0, 0, 0, 0 // ulCodePageRange2
};
GBool missingCmap, missingName, missingPost, missingOS2;
GBool unsortedLoca, badCmapLen, abbrevHMTX;
int nZeroLengthTables;