[
https://issues.apache.org/jira/browse/FOP-2494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14649996#comment-14649996
]
Robert Meyer commented on FOP-2494:
-----------------------------------
I've spent a bit of time looking at this and have found that the method by
which we set the size of the glyph strings array is flawed. In the case of the
UbuntuMono-R.ttf font there are 1296 glyphs. The post table which is used to
store the names of the characters with their associated glyph index. What we
were doing was looping through the index array (which precedes the name array)
and counting the number of glyphs with ID's greater than 258 (the number of
glyphs in the default encoding). This would work fine if the glyph index array
was always complete but in this case it's not e.g.
1,2,3,5,6,9,10,11,12 etc...
The maximum glyph ID in this font is 1315 which, minus 258, equals 1057 which
is the actual number of names in the array. Because we were only counting them
we only got 1046, hence the error. As such to fix this it's simply a case of
setting the character name array to the maximum glyph ID found minus 258. I'll
post a patch tomorrow after I have done some further testing.
> Unable to use Ubuntu Mono Font
> ------------------------------
>
> Key: FOP-2494
> URL: https://issues.apache.org/jira/browse/FOP-2494
> Project: FOP
> Issue Type: Bug
> Components: font/opentype
> Affects Versions: 2.0
> Environment: Ubuntu 14.04, Java 8u45
> Reporter: Harshad
> Assignee: Robert Meyer
>
> I want to use the Ubuntu Mono font, which is installed on my system. But FOP
> throws an exception when it is auto-detecting the fonts:
> {code}
> Unable to load font file:
> file:/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-R.ttf
> java.lang.ArrayIndexOutOfBoundsException: 1047
>
> at org.apache.fop.fonts.truetype.OpenFont.readPostScript(OpenFont.java:1320)
> at org.apache.fop.fonts.truetype.OpenFont.readFont(OpenFont.java:736)
> at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:109)
> at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:93)
> at org.apache.fop.fonts.FontLoader.getFont(FontLoader.java:124)
> at org.apache.fop.fonts.FontLoader.loadFont(FontLoader.java:108)
> at
> org.apache.fop.fonts.autodetect.FontInfoFinder.find(FontInfoFinder.java:254)
> at org.apache.fop.fonts.FontAdder.add(FontAdder.java:63)
> at
> org.apache.fop.fonts.FontDetectorFactory$DefaultFontDetector.detect(FontDetectorFactory.java:97)
> at org.apache.fop.fonts.FontManager.autoDetectFonts(FontManager.java:229)
> at
> org.apache.fop.fonts.DefaultFontConfigurator.configure(DefaultFontConfigurator.java:82)
> at
> org.apache.fop.render.PrintRendererConfigurator.getCustomFontCollection(PrintRendererConfigurator.java:147)
> at
> org.apache.fop.render.PrintRendererConfigurator.setupFontInfo(PrintRendererConfigurator.java:127)
> at org.apache.fop.render.intermediate.IFUtil.setupFonts(IFUtil.java:170)
> at
> org.apache.fop.render.intermediate.IFRenderer.setupFontInfo(IFRenderer.java:187)
> at org.apache.fop.area.RenderPagesModel.<init>(RenderPagesModel.java:75)
> at org.apache.fop.area.AreaTreeHandler.setupModel(AreaTreeHandler.java:135)
> at org.apache.fop.area.AreaTreeHandler.<init>(AreaTreeHandler.java:105)
> at
> org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:350)
> at org.apache.fop.fo.FOTreeBuilder.<init>(FOTreeBuilder.java:107)
> at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:104)
> at org.apache.fop.apps.Fop.<init>(Fop.java:78)
> at org.apache.fop.apps.FOUserAgent.newFop(FOUserAgent.java:179)
> at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:240)
> {code}
> The same exception is thrown for other variants of the font (bold, italic,
> etc).
> Note that this font can be downloaded freely from http://font.ubuntu.com/
> The latest version of the font is 0.80, and that is what I have installed on
> my system.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)