diff options
author | Simon Steiner <ssteiner@apache.org> | 2017-11-27 10:43:26 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2017-11-27 10:43:26 +0000 |
commit | d086a61db20f1ff4db85ae97724ac96dfc27a9dd (patch) | |
tree | efbe35ef73a0bf1c36d961ead8054b41d4db85e9 | |
parent | 2deb342979641c8cf3fb917fad00e0b596a09e56 (diff) | |
download | xmlgraphics-fop-d086a61db20f1ff4db85ae97724ac96dfc27a9dd.tar.gz xmlgraphics-fop-d086a61db20f1ff4db85ae97724ac96dfc27a9dd.zip |
FOP-2759: NPE converting OTF to Type1
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1816422 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java | 2 | ||||
-rw-r--r-- | fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java | 15 |
2 files changed, 14 insertions, 3 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java index a0060ccb6..0634957de 100644 --- a/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java +++ b/fop-core/src/main/java/org/apache/fop/fonts/truetype/OFFontLoader.java @@ -182,7 +182,7 @@ public class OFFontLoader extends FontLoader { returnFont.setWeight(otf.getWeightClass()); if (isCid) { if (otf instanceof OTFFile) { - if (((OTFFile) otf).isType1() && embeddingMode == EmbeddingMode.SUBSET) { + if (((OTFFile) otf).isType1() && embeddingMode == EmbeddingMode.SUBSET && !embedAsType1) { multiFont.setFontType(FontType.TYPE1C); copyGlyphMetricsSingleByte(otf); } diff --git a/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java b/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java index c0a5ed721..adea1d128 100644 --- a/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java +++ b/fop-core/src/test/java/org/apache/fop/fonts/truetype/OTFToType1TestCase.java @@ -34,6 +34,7 @@ import org.apache.fop.fonts.CustomFont; import org.apache.fop.fonts.EmbeddingMode; import org.apache.fop.fonts.EncodingMode; import org.apache.fop.fonts.FontLoader; +import org.apache.fop.fonts.FontType; import org.apache.fop.fonts.FontUris; public class OTFToType1TestCase { @@ -47,13 +48,23 @@ public class OTFToType1TestCase { Assert.assertEquals(t1.getFontName(), "AlexBrush-Regular.0"); } + @Test + public void testFontType() throws IOException { + CustomFont t1 = getRealFont("test/resources/fonts/otf/SourceSansProBold.otf"); + Assert.assertEquals(t1.getFontType(), FontType.TYPE1); + } + private Type1Font getFont(String s) throws IOException { + InputStream is = ((CFFToType1Font)getRealFont(s)).getInputStreams().get(0); + return Type1Font.createWithPFB(is); + } + + private CustomFont getRealFont(String s) throws IOException { InternalResourceResolver rr = ResourceResolverFactory.createDefaultInternalResourceResolver( new File(".").toURI()); CustomFont realFont = FontLoader.loadFont(new FontUris(new File(s).toURI(), null), null, true, EmbeddingMode.SUBSET, EncodingMode.AUTO, true, true, rr, false, true); realFont.mapChar('d'); - InputStream is = ((CFFToType1Font)realFont).getInputStreams().get(0); - return Type1Font.createWithPFB(is); + return realFont; } } |