From 2031f5f46dd9264c2b65bcbe1e1d9eb2acedba97 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Mon, 2 Dec 2013 08:18:16 +1030 Subject: [PATCH] Ensure Type 0 fonts contain all glyphs but to save space the last base font is re-used for all glyphs past maxGlyphsUsed. Bug 70466 --- fofi/FoFiTrueType.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fofi/FoFiTrueType.cc b/fofi/FoFiTrueType.cc index cd11d6f..4fdee77 100644 --- a/fofi/FoFiTrueType.cc +++ b/fofi/FoFiTrueType.cc @@ -750,13 +750,17 @@ 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.) + + // Bug 70466: Ensure the Type 0 font has nGlyphs but to avoid huge fonts, + // the Type 0 font uses the same base font for glyphs between + // maxUsedGlyph to nGlyphs. if (cidMap) { n = nCIDs; } else if (nGlyphs > maxUsedGlyph + 256) { if (maxUsedGlyph <= 255) { n = 256; } else { - n = maxUsedGlyph + 1; + n = maxUsedGlyph + 256; } } else { n = nGlyphs; @@ -807,17 +811,17 @@ void FoFiTrueType::convertToType0(char *psName, int *cidMap, int nCIDs, (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); (*outputFunc)(outputStream, "/FMapType 2 def\n", 16); (*outputFunc)(outputStream, "/Encoding [\n", 12); - for (i = 0; i < n; i += 256) { + for (i = 0; i < nGlyphs; i += 256) { buf = GooString::format("{0:d}\n", i >> 8); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } (*outputFunc)(outputStream, "] def\n", 6); (*outputFunc)(outputStream, "/FDepVector [\n", 14); - for (i = 0; i < n; i += 256) { + for (i = 0; i < nGlyphs; i += 256) { (*outputFunc)(outputStream, "/", 1); (*outputFunc)(outputStream, psName, strlen(psName)); - buf = GooString::format("_{0:02x} findfont\n", i >> 8); + buf = GooString::format("_{0:02x} findfont\n", i > n ? (n-1) >> 8 : i >> 8); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; } -- 1.7.10.4