Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 5.0.1, 5.0.2
-
Fix Version/s: 5.0.3
-
Component/s: Font Engine
-
Labels:None
-
Environment:All
-
Salesforce Case Reference:
Description
When running the PDF file provided by the customer the following exception is thrown and the text is rendered as all special characters:
FINE: Could not create instance of font file 5
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.icepdf.core.pobjects.fonts.FontFactory.createFontFile(FontFactory.java:151)
at org.icepdf.core.pobjects.fonts.FontDescriptor.init(FontDescriptor.java:311)
at org.icepdf.core.pobjects.fonts.nfont.Font.init(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.Font.init(Unknown Source)
at org.icepdf.core.pobjects.Resources.getFont(Resources.java:147)
at org.icepdf.core.util.content.AbstractContentParser.consume_Tf(AbstractContentParser.java:722)
at org.icepdf.core.util.content.NContentParser.parseText(Unknown Source)
at org.icepdf.core.util.content.NContentParser.parse(Unknown Source)
at org.icepdf.core.pobjects.Page.init(Page.java:367)
at org.icepdf.ri.common.views.PageViewComponentImpl$PageInitializer.run(PageViewComponentImpl.java:1017)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 6
at org.icepdf.core.pobjects.fonts.nfont.i.readUint16(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontTrueType.readMaxpTable(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontTrueType.parse(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontOpenType.parse(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.i.<init>(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontTrueType.<init>(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontOpenType.<init>(Unknown Source)
... 17 more
FINE: Could not create instance of font file 5
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.icepdf.core.pobjects.fonts.FontFactory.createFontFile(FontFactory.java:151)
at org.icepdf.core.pobjects.fonts.FontDescriptor.init(FontDescriptor.java:311)
at org.icepdf.core.pobjects.fonts.nfont.Font.init(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.Font.init(Unknown Source)
at org.icepdf.core.pobjects.Resources.getFont(Resources.java:147)
at org.icepdf.core.util.content.AbstractContentParser.consume_Tf(AbstractContentParser.java:722)
at org.icepdf.core.util.content.NContentParser.parseText(Unknown Source)
at org.icepdf.core.util.content.NContentParser.parse(Unknown Source)
at org.icepdf.core.pobjects.Page.init(Page.java:367)
at org.icepdf.ri.common.views.PageViewComponentImpl$PageInitializer.run(PageViewComponentImpl.java:1017)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 6
at org.icepdf.core.pobjects.fonts.nfont.i.readUint16(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontTrueType.readMaxpTable(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontTrueType.parse(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontOpenType.parse(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.i.<init>(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontTrueType.<init>(Unknown Source)
at org.icepdf.core.pobjects.fonts.nfont.NFontOpenType.<init>(Unknown Source)
... 17 more
The was a tricky one as the actual cause of the failure was do to what would appear to be a bug that has been around for quite some time. Basically an OpenType font can have a TrueType or Type1 sub font program. The Type1 font program was not getting is data stream set from the parent OpenType font and thus the font null'd out. This was further complicated by the fact that the font was a CID font so not in the normal ASCII range. I think this might have gone unnoticed as font substitution would normally kicked in. But in this case the CID codes don't match to any readable glyphs.
I'll have to run this through QA but it appear than OpenType/Type1/CID combination is very rare code execution.