summaryrefslogtreecommitdiff
path: root/fofi/FoFiTrueType.cc
diff options
context:
space:
mode:
authorWilliam Bader <william@newspapersystems.com>2016-12-08 21:45:18 +0100
committerAlbert Astals Cid <aacid@kde.org>2016-12-08 21:45:18 +0100
commit2cf901c817fc99e1fa57745c11aa79cdfb4e8c99 (patch)
tree4b21955f0963cd718b637919416f2066a1bbdfdc /fofi/FoFiTrueType.cc
parent97b801b55b9bd33f20723c7139cf845a1cba5bd3 (diff)
Fix PS conversion for some files
Bug #63963
Diffstat (limited to 'fofi/FoFiTrueType.cc')
-rw-r--r--fofi/FoFiTrueType.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc
index 49058264..f1a15e00 100644
--- a/fofi/FoFiTrueType.cc
+++ b/fofi/FoFiTrueType.cc
@@ -22,7 +22,7 @@
// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2014 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2015 Aleksei Volkov <Aleksei Volkov>
-// Copyright (C) 2015 William Bader <williambader@hotmail.com>
+// Copyright (C) 2015, 2016 William Bader <williambader@hotmail.com>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -727,12 +727,15 @@ void FoFiTrueType::convertToCIDType0(char *psName, int *cidMap, int nCIDs,
void FoFiTrueType::convertToType0(char *psName, int *cidMap, int nCIDs,
GBool needVerticalMetrics,
+ int *maxValidGlyph,
FoFiOutputFunc outputFunc,
void *outputStream) {
GooString *buf;
GooString *sfntsName;
int maxUsedGlyph, n, i, j;
+ *maxValidGlyph = -1;
+
if (openTypeCFF) {
return;
}
@@ -754,6 +757,13 @@ void FoFiTrueType::convertToType0(char *psName, int *cidMap, int nCIDs,
// that refers to one of the unused glyphs -- this results in PS
// errors if we simply use maxUsedGlyph+1 for the Type 0 font. So
// we compromise by always defining at least 256 glyphs.)
+ // Some fonts have a large nGlyphs but maxUsedGlyph of 0.
+ // These fonts might reference any glyph.
+ // Return the last written glyph number in maxValidGlyph.
+ // PSOutputDev::drawString() can use maxValidGlyph to avoid
+ // referencing zero-length glyphs that we trimmed.
+ // This allows pdftops to avoid writing huge files while still
+ // handling the rare PDF that uses a zero-length glyph.
if (cidMap) {
n = nCIDs;
} else if (nGlyphs > maxUsedGlyph + 256) {
@@ -765,6 +775,7 @@ void FoFiTrueType::convertToType0(char *psName, int *cidMap, int nCIDs,
} else {
n = nGlyphs;
}
+ *maxValidGlyph = n-1;
for (i = 0; i < n; i += 256) {
(*outputFunc)(outputStream, "10 dict begin\n", 14);
(*outputFunc)(outputStream, "/FontName /", 11);