diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2022-04-24 03:42:26 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2022-04-24 03:42:26 +0000 |
commit | d743821ec3b71e00af5dc5541d4e7bf5b003c55e (patch) | |
tree | 8145068541ec45af3c223f5a35891d02e4adf273 /Build/source/libs/xpdf/xpdf-src/xpdf/WebFont.cc | |
parent | d0ce904282bf50ad444cf1ff7df7edd12a3b5a70 (diff) |
xpdf 4.04
git-svn-id: svn://tug.org/texlive/trunk@63119 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/xpdf/WebFont.cc')
-rw-r--r-- | Build/source/libs/xpdf/xpdf-src/xpdf/WebFont.cc | 73 |
1 files changed, 47 insertions, 26 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/xpdf/WebFont.cc b/Build/source/libs/xpdf/xpdf-src/xpdf/WebFont.cc index 9ae636226ae..c04b52f937a 100644 --- a/Build/source/libs/xpdf/xpdf-src/xpdf/WebFont.cc +++ b/Build/source/libs/xpdf/xpdf-src/xpdf/WebFont.cc @@ -71,8 +71,11 @@ static void writeToFile(void *stream, const char *data, int len) { fwrite(data, 1, len, (FILE *)stream); } -GBool WebFont::writeTTF(const char *fontFilePath) { - FILE *out; +static void writeToString(void *stream, const char *data, int len) { + ((GString *)stream)->append(data, len); +} + +GBool WebFont::generateTTF(FoFiOutputFunc outFunc, void *stream) { int *codeToGID; Guchar *cmapTable; GBool freeCodeToGID; @@ -100,22 +103,35 @@ GBool WebFont::writeTTF(const char *fontFilePath) { if (!cmapTable) { return gFalse; } - if (!(out = fopen(fontFilePath, "wb"))) { - gfree(cmapTable); - return gFalse; - } - ffTrueType->writeTTF(writeToFile, out, NULL, NULL, + ffTrueType->writeTTF(outFunc, stream, NULL, NULL, cmapTable, cmapTableLength); - fclose(out); gfree(cmapTable); return gTrue; } -GBool WebFont::writeOTF(const char *fontFilePath) { +GBool WebFont::writeTTF(const char *fontFilePath) { + FILE *out = fopen(fontFilePath, "wb"); + if (!out) { + return gFalse; + } + GBool ret = generateTTF(writeToFile, out); + fclose(out); + return ret; +} + +GString *WebFont::getTTFData() { + GString *s = new GString(); + if (!generateTTF(writeToString, s)) { + delete s; + return NULL; + } + return s; +} + +GBool WebFont::generateOTF(FoFiOutputFunc outFunc, void *stream) { int *codeToGID; Gushort *widths; Guchar *cmapTable; - FILE *out; int nCodes, nWidths, cmapTableLength; if (ffType1C) { @@ -138,27 +154,13 @@ GBool WebFont::writeOTF(const char *fontFilePath) { widths = makeCIDType0CWidths(codeToGID, nCodes, &nWidths); gfree(codeToGID); } - if (!(out = fopen(fontFilePath, "wb"))) { - gfree(cmapTable); - gfree(widths); - return gFalse; - } - ffType1C->convertToOpenType(writeToFile, out, - nWidths, widths, + ffType1C->convertToOpenType(outFunc, stream, nWidths, widths, cmapTable, cmapTableLength); - fclose(out); gfree(cmapTable); gfree(widths); } else if (isOpenType) { - if (!(out = fopen(fontFilePath, "wb"))) { - return gFalse; - } - if (fwrite(fontBuf, 1, fontLength, out) != (Guint)fontLength) { - fclose(out); - return gFalse; - } - fclose(out); + outFunc(stream, fontBuf, fontLength); } else { return gFalse; @@ -167,6 +169,25 @@ GBool WebFont::writeOTF(const char *fontFilePath) { return gTrue; } +GBool WebFont::writeOTF(const char *fontFilePath) { + FILE *out = fopen(fontFilePath, "wb"); + if (!out) { + return gFalse; + } + GBool ret = generateOTF(writeToFile, out); + fclose(out); + return ret; +} + +GString *WebFont::getOTFData() { + GString *s = new GString(); + if (!generateOTF(writeToString, s)) { + delete s; + return NULL; + } + return s; +} + Gushort *WebFont::makeType1CWidths(int *codeToGID, int nCodes, int *nWidths) { Gushort *widths; |