You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/02/15 17:46:05 UTC
svn commit: r1824337 - in /pdfbox/trunk:
fontbox/src/main/java/org/apache/fontbox/ttf/
fontbox/src/test/java/org/apache/fontbox/cmap/
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/
Author: tilman
Date: Thu Feb 15 17:46:05 2018
New Revision: 1824337
URL: http://svn.apache.org/viewvc?rev=1824337&view=rev
Log:
PDFBOX-4106: add cmap lookup interface, by Aaron Madlon-Kay
Added:
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapLookup.java (with props)
Modified:
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/TrueTypeEmbedder.java
Added: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapLookup.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapLookup.java?rev=1824337&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapLookup.java (added)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapLookup.java Thu Feb 15 17:46:05 2018
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.fontbox.ttf;
+
+import java.util.List;
+
+/**
+ * An interface that abstracts the cid <-> codepoint lookup functionality of cmap.
+ *
+ * @author Aaron Madlon-Kay
+ */
+public interface CmapLookup
+{
+
+ /**
+ * Returns all possible character codes for the given gid, or null if there is none.
+ *
+ * @param gid glyph id
+ * @return a list with all character codes the given gid maps to
+ */
+ List<Integer> getCharCodes(int gid);
+
+ /**
+ * Returns the GlyphId linked with the given character code.
+ *
+ * @param codePointAt the given character code to be mapped
+ * @return glyphId the corresponding glyph id for the given character code
+ */
+ int getGlyphId(int codePointAt);
+
+}
\ No newline at end of file
Propchange: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapLookup.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java?rev=1824337&r1=1824336&r2=1824337&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/CmapSubtable.java Thu Feb 15 17:46:05 2018
@@ -33,7 +33,7 @@ import org.apache.commons.logging.LogFac
*
* @author Ben Litchfield
*/
-public class CmapSubtable
+public class CmapSubtable implements CmapLookup
{
private static final Log LOG = LogFactory.getLog(CmapSubtable.class);
Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java?rev=1824337&r1=1824336&r2=1824337&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java Thu Feb 15 17:46:05 2018
@@ -55,7 +55,7 @@ public final class TTFSubsetter
private static final byte[] PAD_BUF = new byte[] { 0, 0, 0 };
private final TrueTypeFont ttf;
- private final CmapSubtable unicodeCmap;
+ private final CmapLookup unicodeCmap;
private final SortedMap<Integer, Integer> uniToGID;
private final List<String> keepTables;
@@ -88,7 +88,7 @@ public final class TTFSubsetter
glyphIds = new TreeSet<>();
// find the best Unicode cmap
- this.unicodeCmap = ttf.getUnicodeCmap();
+ this.unicodeCmap = ttf.getUnicodeCmapLookup();
// always copy GID 0
glyphIds.add(0);
Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java?rev=1824337&r1=1824336&r2=1824337&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java Thu Feb 15 17:46:05 2018
@@ -504,7 +504,9 @@ public class TrueTypeFont implements Fon
* by which this is accomplished are implementation-dependent."
*
* @throws IOException if the font could not be read
+ * @deprecated Use {@link #getUnicodeCmapLookup()} instead
*/
+ @Deprecated
public CmapSubtable getUnicodeCmap() throws IOException
{
return getUnicodeCmap(true);
@@ -516,9 +518,44 @@ public class TrueTypeFont implements Fon
*
* @param isStrict False if we allow falling back to any cmap, even if it's not Unicode.
* @throws IOException if the font could not be read, or there is no Unicode cmap
+ * @deprecated Use {@link #getUnicodeCmapLookup(boolean)} instead
*/
+ @Deprecated
public CmapSubtable getUnicodeCmap(boolean isStrict) throws IOException
{
+ return getUnicodeCmapImpl(isStrict);
+ }
+
+ /**
+ * Returns the best Unicode from the font (the most general). The PDF spec says that "The means
+ * by which this is accomplished are implementation-dependent."
+ *
+ * The returned cmap will perform glyph substitution.
+ *
+ * @throws IOException if the font could not be read
+ */
+ public CmapLookup getUnicodeCmapLookup() throws IOException
+ {
+ return getUnicodeCmapLookup(true);
+ }
+
+ /**
+ * Returns the best Unicode from the font (the most general). The PDF spec says that "The means
+ * by which this is accomplished are implementation-dependent."
+ *
+ * The returned cmap will perform glyph substitution.
+ *
+ * @param isStrict False if we allow falling back to any cmap, even if it's not Unicode.
+ * @throws IOException if the font could not be read, or there is no Unicode cmap
+ */
+ public CmapLookup getUnicodeCmapLookup(boolean isStrict) throws IOException
+ {
+ CmapSubtable cmap = getUnicodeCmapImpl(isStrict);
+ return cmap;
+ }
+
+ private CmapSubtable getUnicodeCmapImpl(boolean isStrict) throws IOException
+ {
CmapTable cmapTable = getCmap();
if (cmapTable == null)
{
@@ -592,7 +629,7 @@ public class TrueTypeFont implements Fon
int uni = parseUniName(name);
if (uni > -1)
{
- CmapSubtable cmap = getUnicodeCmap(false);
+ CmapLookup cmap = getUnicodeCmapLookup(false);
return cmap.getGlyphId(uni);
}
Modified: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java?rev=1824337&r1=1824336&r2=1824337&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java (original)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cmap/TestCMap.java Thu Feb 15 17:46:05 2018
@@ -20,13 +20,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import junit.framework.TestCase;
-
-import static junit.framework.TestCase.assertEquals;
-import org.apache.fontbox.ttf.CmapSubtable;
+import org.apache.fontbox.ttf.CmapLookup;
import org.apache.fontbox.ttf.TTFParser;
import org.apache.fontbox.ttf.TrueTypeFont;
+import junit.framework.TestCase;
+
/**
* This will test the CMap implementation.
*
@@ -70,7 +69,7 @@ public class TestCMap extends TestCase
}
try (TrueTypeFont ttf = new TTFParser().parse(is))
{
- CmapSubtable cmap = ttf.getUnicodeCmap(false);
+ CmapLookup cmap = ttf.getUnicodeCmapLookup(false);
assertEquals(886, cmap.getGlyphId(0x1F681));
}
}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java?rev=1824337&r1=1824336&r2=1824337&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2.java Thu Feb 15 17:46:05 2018
@@ -23,7 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fontbox.cff.Type2CharString;
import org.apache.fontbox.cmap.CMap;
-import org.apache.fontbox.ttf.CmapSubtable;
+import org.apache.fontbox.ttf.CmapLookup;
import org.apache.fontbox.ttf.GlyphData;
import org.apache.fontbox.ttf.OTFParser;
import org.apache.fontbox.ttf.OpenTypeFont;
@@ -47,7 +47,7 @@ public class PDCIDFontType2 extends PDCI
private final int[] cid2gid;
private final boolean isEmbedded;
private final boolean isDamaged;
- private final CmapSubtable cmap; // may be null
+ private final CmapLookup cmap; // may be null
private Matrix fontMatrix;
private BoundingBox fontBBox;
@@ -139,7 +139,7 @@ public class PDCIDFontType2 extends PDCI
}
ttf = ttfFont;
}
- cmap = ttf.getUnicodeCmap(false);
+ cmap = ttf.getUnicodeCmapLookup(false);
cid2gid = readCIDToGIDMap();
}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java?rev=1824337&r1=1824336&r2=1824337&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java Thu Feb 15 17:46:05 2018
@@ -135,7 +135,7 @@ final class PDCIDFontType2Embedder exten
}
// skip composite glyph components that have no code point
- List<Integer> codes = cmap.getCharCodes(cid); // old GID -> Unicode
+ List<Integer> codes = cmapLookup.getCharCodes(cid); // old GID -> Unicode
if (codes != null)
{
// use the first entry even for ambiguous mappings
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java?rev=1824337&r1=1824336&r2=1824337&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDTrueTypeFontEmbedder.java Thu Feb 15 17:46:05 2018
@@ -1,129 +1,129 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.pdfbox.pdmodel.font;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.fontbox.ttf.HorizontalMetricsTable;
-import org.apache.fontbox.ttf.TrueTypeFont;
-import org.apache.pdfbox.cos.COSDictionary;
-import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.common.COSArrayList;
-import org.apache.pdfbox.pdmodel.font.encoding.Encoding;
-import org.apache.pdfbox.pdmodel.font.encoding.GlyphList;
-
-/**
- * Embedded PDTrueTypeFont builder. Helper class to populate a PDTrueTypeFont from a TTF.
- *
- * @author John Hewson
- * @author Ben Litchfield
- */
-final class PDTrueTypeFontEmbedder extends TrueTypeEmbedder
-{
- private final Encoding fontEncoding;
-
- /**
- * Creates a new TrueType font embedder for the given TTF as a PDTrueTypeFont.
- *
- * @param document The parent document
- * @param dict Font dictionary
- * @param ttfStream TTF stream
- * @param encoding The PostScript encoding vector to be used for embedding.
- * @throws IOException if the TTF could not be read
- */
- PDTrueTypeFontEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf,
- Encoding encoding) throws IOException
- {
- super(document, dict, ttf, false);
- dict.setItem(COSName.SUBTYPE, COSName.TRUE_TYPE);
-
- GlyphList glyphList = GlyphList.getAdobeGlyphList();
- this.fontEncoding = encoding;
- dict.setItem(COSName.ENCODING, encoding.getCOSObject());
- fontDescriptor.setSymbolic(false);
- fontDescriptor.setNonSymbolic(true);
-
- // add the font descriptor
- dict.setItem(COSName.FONT_DESC, fontDescriptor);
-
- // set the glyph widths
- setWidths(dict, glyphList);
- }
-
- /**
- * Sets the glyph widths in the font dictionary.
- */
- private void setWidths(COSDictionary font, GlyphList glyphList) throws IOException
- {
- float scaling = 1000f / ttf.getHeader().getUnitsPerEm();
- HorizontalMetricsTable hmtx = ttf.getHorizontalMetrics();
-
- Map<Integer, String> codeToName = getFontEncoding().getCodeToNameMap();
-
- int firstChar = Collections.min(codeToName.keySet());
- int lastChar = Collections.max(codeToName.keySet());
-
- List<Integer> widths = new ArrayList<>(lastChar - firstChar + 1);
- for (int i = 0; i < lastChar - firstChar + 1; i++)
- {
- widths.add(0);
- }
-
- // a character code is mapped to a glyph name via the provided font encoding
- // afterwards, the glyph name is translated to a glyph ID.
- for (Map.Entry<Integer, String> entry : codeToName.entrySet())
- {
- int code = entry.getKey();
- String name = entry.getValue();
-
- if (code >= firstChar && code <= lastChar)
- {
- String uni = glyphList.toUnicode(name);
- int charCode = uni.codePointAt(0);
- int gid = cmap.getGlyphId(charCode);
- widths.set(entry.getKey() - firstChar,
- Math.round(hmtx.getAdvanceWidth(gid) * scaling));
- }
- }
-
- font.setInt(COSName.FIRST_CHAR, firstChar);
- font.setInt(COSName.LAST_CHAR, lastChar);
- font.setItem(COSName.WIDTHS, COSArrayList.converterToCOSArray(widths));
- }
-
- /**
- * Returns the font's encoding.
- */
- public Encoding getFontEncoding()
- {
- return fontEncoding;
- }
-
- @Override
- protected void buildSubset(InputStream ttfSubset, String tag,
- Map<Integer, Integer> gidToCid) throws IOException
- {
- // use PDType0Font instead
- throw new UnsupportedOperationException();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.pdfbox.pdmodel.font;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.fontbox.ttf.HorizontalMetricsTable;
+import org.apache.fontbox.ttf.TrueTypeFont;
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.pdmodel.common.COSArrayList;
+import org.apache.pdfbox.pdmodel.font.encoding.Encoding;
+import org.apache.pdfbox.pdmodel.font.encoding.GlyphList;
+
+/**
+ * Embedded PDTrueTypeFont builder. Helper class to populate a PDTrueTypeFont from a TTF.
+ *
+ * @author John Hewson
+ * @author Ben Litchfield
+ */
+final class PDTrueTypeFontEmbedder extends TrueTypeEmbedder
+{
+ private final Encoding fontEncoding;
+
+ /**
+ * Creates a new TrueType font embedder for the given TTF as a PDTrueTypeFont.
+ *
+ * @param document The parent document
+ * @param dict Font dictionary
+ * @param ttfStream TTF stream
+ * @param encoding The PostScript encoding vector to be used for embedding.
+ * @throws IOException if the TTF could not be read
+ */
+ PDTrueTypeFontEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf,
+ Encoding encoding) throws IOException
+ {
+ super(document, dict, ttf, false);
+ dict.setItem(COSName.SUBTYPE, COSName.TRUE_TYPE);
+
+ GlyphList glyphList = GlyphList.getAdobeGlyphList();
+ this.fontEncoding = encoding;
+ dict.setItem(COSName.ENCODING, encoding.getCOSObject());
+ fontDescriptor.setSymbolic(false);
+ fontDescriptor.setNonSymbolic(true);
+
+ // add the font descriptor
+ dict.setItem(COSName.FONT_DESC, fontDescriptor);
+
+ // set the glyph widths
+ setWidths(dict, glyphList);
+ }
+
+ /**
+ * Sets the glyph widths in the font dictionary.
+ */
+ private void setWidths(COSDictionary font, GlyphList glyphList) throws IOException
+ {
+ float scaling = 1000f / ttf.getHeader().getUnitsPerEm();
+ HorizontalMetricsTable hmtx = ttf.getHorizontalMetrics();
+
+ Map<Integer, String> codeToName = getFontEncoding().getCodeToNameMap();
+
+ int firstChar = Collections.min(codeToName.keySet());
+ int lastChar = Collections.max(codeToName.keySet());
+
+ List<Integer> widths = new ArrayList<>(lastChar - firstChar + 1);
+ for (int i = 0; i < lastChar - firstChar + 1; i++)
+ {
+ widths.add(0);
+ }
+
+ // a character code is mapped to a glyph name via the provided font encoding
+ // afterwards, the glyph name is translated to a glyph ID.
+ for (Map.Entry<Integer, String> entry : codeToName.entrySet())
+ {
+ int code = entry.getKey();
+ String name = entry.getValue();
+
+ if (code >= firstChar && code <= lastChar)
+ {
+ String uni = glyphList.toUnicode(name);
+ int charCode = uni.codePointAt(0);
+ int gid = cmapLookup.getGlyphId(charCode);
+ widths.set(entry.getKey() - firstChar,
+ Math.round(hmtx.getAdvanceWidth(gid) * scaling));
+ }
+ }
+
+ font.setInt(COSName.FIRST_CHAR, firstChar);
+ font.setInt(COSName.LAST_CHAR, lastChar);
+ font.setItem(COSName.WIDTHS, COSArrayList.converterToCOSArray(widths));
+ }
+
+ /**
+ * Returns the font's encoding.
+ */
+ public Encoding getFontEncoding()
+ {
+ return fontEncoding;
+ }
+
+ @Override
+ protected void buildSubset(InputStream ttfSubset, String tag,
+ Map<Integer, Integer> gidToCid) throws IOException
+ {
+ // use PDType0Font instead
+ throw new UnsupportedOperationException();
+ }
+}
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/TrueTypeEmbedder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/TrueTypeEmbedder.java?rev=1824337&r1=1824336&r2=1824337&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/TrueTypeEmbedder.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/TrueTypeEmbedder.java Thu Feb 15 17:46:05 2018
@@ -27,6 +27,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.fontbox.ttf.CmapLookup;
import org.apache.fontbox.ttf.CmapSubtable;
import org.apache.fontbox.ttf.HeaderTable;
import org.apache.fontbox.ttf.HorizontalHeaderTable;
@@ -56,7 +57,9 @@ abstract class TrueTypeEmbedder implemen
private final PDDocument document;
protected TrueTypeFont ttf;
protected PDFontDescriptor fontDescriptor;
- protected final CmapSubtable cmap;
+ @Deprecated
+ protected final CmapSubtable cmap; // for API backwards compatibility
+ protected final CmapLookup cmapLookup;
private final Set<Integer> subsetCodePoints = new HashSet<>();
private final boolean embedSubset;
@@ -88,6 +91,7 @@ abstract class TrueTypeEmbedder implemen
// choose a Unicode "cmap"
cmap = ttf.getUnicodeCmap();
+ cmapLookup = ttf.getUnicodeCmapLookup();
}
public final void buildFontFile2(InputStream ttfStream) throws IOException