Skip to content

Commit c2b1374

Browse files
committed
PDFBOX-6172: avoid ClassCastException with SourceSansProBold.otf from FOP 2432
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1932122 13f79535-47bb-0310-9956-ffa450edef68
1 parent 23f8244 commit c2b1374

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/PDCIDFontType2Embedder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.TreeMap;
2828
import org.apache.fontbox.cff.CFFCIDFont;
2929
import org.apache.fontbox.cff.CFFCharset;
30+
import org.apache.fontbox.cff.CFFFont;
3031
import org.apache.fontbox.ttf.CFFTable;
3132

3233
import org.apache.logging.log4j.Logger;
@@ -239,8 +240,8 @@ private void checkForCidGidIdentity() throws IOException
239240
{
240241
return;
241242
}
242-
CFFCIDFont cff = (CFFCIDFont) cffTable.getFont();
243-
if (cff == null)
243+
CFFFont cff = cffTable.getFont();
244+
if (!(cff instanceof CFFCIDFont))
244245
{
245246
return;
246247
}
@@ -308,7 +309,7 @@ private void buildCIDSet(TreeMap<Integer, Integer> cidToGid) throws IOException
308309
}
309310

310311
InputStream input = new ByteArrayInputStream(bytes);
311-
PDStream stream = new PDStream(document, input, COSName.FLATE_DECODE);
312+
PDStream stream = new PDStream(document, input, bytes.length < 20 ? null : COSName.FLATE_DECODE);
312313

313314
fontDescriptor.setCIDSet(stream);
314315
}

0 commit comments

Comments
 (0)