XSL-FO to PDF fails due to font error

llpick
Posts: 8
Joined: Sat Jun 23, 2018 12:52 am

XSL-FO to PDF fails due to font error

Post by llpick » Tue Jan 21, 2020 11:56 am

Hello there,

I get a systematic error during PDF transformation after installing missing font combinations for Roboto.
(DITA MAP PDF based on XSL-FO)

Code: Select all

ID Système: C:\test\temp\pdf\topic.fo
Scénario: DITA Map PDF - test 2020-01-21
fichier Input: C:\Program Files\Oxygen XML Editor 21\samples\dita\flowers\flowers.ditamap
Nom du moteur: FOP
Gravité: error
Description: Anttask - Error rendering fo file: C:\test\temp\pdf\topic.fo <org.apache.fop.apps.FOPException: Failed to read font file file:/C:/Windows/FONTS/Roboto-Light_0.ttf
I haven't changed anything about my DITA plugin. I've checked my C:\Windows\Fonts\ folder using the command line and the Roboto-Light_0.ttf file is there.
I'm having a tough time understanding what's happening or how to investigate further. Any ideas?
Thanks!

Radu
Posts: 6987
Joined: Fri Jul 09, 2004 5:18 pm

Re: XSL-FO to PDF fails due to font error

Post by Radu » Tue Jan 21, 2020 12:56 pm

Hi,

After the transformation fails there is a DITA OT console view at the bottom of Oxygen, you can try to look inside it to see if there are more details about the failure. The problem is not necessarily generated by the fact that the Apache FOP processor bundled with Oxygen cannot locate the file, but somehow it might not be able to interpret the information inside the font because of some limitation.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

llpick
Posts: 8
Joined: Sat Jun 23, 2018 12:52 am

Re: XSL-FO to PDF fails due to font error

Post by llpick » Tue Jan 21, 2020 1:09 pm

Hi Radu, here is what the oXygen console view tells me about the issue :

Code: Select all

transform.fo2pdf.fop:
[fop] [ERROR] Anttask - Error rendering fo file: C:\test\temp\pdf\topic.fo <org.apache.fop.apps.FOPException: Failed to read font file file:/C:/Windows/FONTS/Roboto-Light_0.ttf
      [fop] java.lang.RuntimeException: Failed to read font file file:/C:/Windows/FONTS/Roboto-Light_0.ttf>org.apache.fop.apps.FOPException: Failed to read font file file:/C:/Windows/FONTS/Roboto-Light_0.ttf
      [fop] java.lang.RuntimeException: Failed to read font file file:/C:/Windows/FONTS/Roboto-Light_0.ttf
      [fop] 	at org.apache.fop.tools.anttasks.FOPTaskStarter.renderInputHandler(Fop.java:652)
      [fop] 	at org.apache.fop.tools.anttasks.FOPTaskStarter.render(Fop.java:671)
      [fop] 	at org.apache.fop.tools.anttasks.FOPTaskStarter.run(Fop.java:532)
      [fop] 	at org.apache.fop.tools.anttasks.Fop.execute(Fop.java:369)
      [fop] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
      [fop] 	at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      [fop] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [fop] 	at java.lang.reflect.Method.invoke(Unknown Source)
      [fop] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      [fop] 	at org.apache.tools.ant.Task.perform(Task.java:350)
      [fop] 	at org.apache.tools.ant.Target.execute(Target.java:448)
      [fop] 	at org.apache.tools.ant.Target.performTasks(Target.java:469)
      [fop] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      [fop] 	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
      [fop] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
      [fop] 	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:446)
      [fop] 	at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
      [fop] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
      [fop] 	at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      [fop] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [fop] 	at java.lang.reflect.Method.invoke(Unknown Source)
      [fop] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      [fop] 	at org.apache.tools.ant.Task.perform(Task.java:350)
      [fop] 	at org.apache.tools.ant.Target.execute(Target.java:448)
      [fop] 	at org.apache.tools.ant.Target.performTasks(Target.java:469)
      [fop] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      [fop] 	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
      [fop] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
      [fop] 	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:446)
      [fop] 	at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
      [fop] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
      [fop] 	at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
      [fop] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      [fop] 	at java.lang.reflect.Method.invoke(Unknown Source)
      [fop] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      [fop] 	at org.apache.tools.ant.Task.perform(Task.java:350)
      [fop] 	at org.apache.tools.ant.Target.execute(Target.java:448)
      [fop] 	at org.apache.tools.ant.Target.performTasks(Target.java:469)
      [fop] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      [fop] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1370)
      [fop] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      [fop] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
      [fop] 	at org.apache.tools.ant.Main.runBuild(Main.java:849)
      [fop] 	at org.apache.tools.ant.Main.startAnt(Main.java:228)
      [fop] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
      [fop] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
      [fop] Caused by: org.apache.fop.apps.FOPException: Failed to read font file file:/C:/Windows/FONTS/Roboto-Light_0.ttf
      [fop] java.lang.RuntimeException: Failed to read font file file:/C:/Windows/FONTS/Roboto-Light_0.ttf
      [fop] 	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:296)
      [fop] 	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:116)
      [fop] 	at org.apache.fop.tools.anttasks.FOPTaskStarter.renderInputHandler(Fop.java:648)
      [fop] 	... 45 more
      [fop] Caused by: java.lang.RuntimeException: Failed to read font file file:/C:/Windows/FONTS/Roboto-Light_0.ttf
      [fop] 	at org.apache.fop.fonts.LazyFont.load(LazyFont.java:127)
      [fop] 	at org.apache.fop.fonts.LazyFont.getAscender(LazyFont.java:235)
      [fop] 	at org.apache.fop.fonts.Font.getAscender(Font.java:120)
      [fop] 	at org.apache.fop.layoutmgr.BlockLayoutManager.initialize(BlockLayoutManager.java:82)
      [fop] 	at org.apache.fop.layoutmgr.AbstractLayoutManager.getChildLM(AbstractLayoutManager.java:118)
      [fop] 	at org.apache.fop.layoutmgr.BlockContainerLayoutManager$BlockContainerBreaker.getNextKnuthElements(BlockContainerLayoutManager.java:666)
      [fop] 	at org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:770)
      [fop] 	at org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:743)
      [fop] 	at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:389)
      [fop] 	at org.apache.fop.layoutmgr.BlockContainerLayoutManager.getNextKnuthElementsAbsolute(BlockContainerLayoutManager.java:535)
      [fop] 	at org.apache.fop.layoutmgr.BlockContainerLayoutManager.getNextKnuthElements(BlockContainerLayoutManager.java:212)
      [fop] 	at org.apache.fop.layoutmgr.BlockContainerLayoutManager.getNextKnuthElements(BlockContainerLayoutManager.java:186)
      [fop] 	at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextChildElements(BlockStackingLayoutManager.java:498)
      [fop] 	at org.apache.fop.layoutmgr.BlockContainerLayoutManager.getNextKnuthElements(BlockContainerLayoutManager.java:256)
      [fop] 	at org.apache.fop.layoutmgr.BlockContainerLayoutManager.getNextKnuthElements(BlockContainerLayoutManager.java:186)
      [fop] 	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextChildElements(FlowLayoutManager.java:223)
      [fop] 	at org.apache.fop.layoutmgr.FlowLayoutManager.addChildElements(FlowLayoutManager.java:147)
      [fop] 	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:116)
      [fop] 	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:69)
      [fop] 	at org.apache.fop.layoutmgr.PageBreaker.getNextKnuthElements(PageBreaker.java:251)
      [fop] 	at org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:770)
      [fop] 	at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:178)
      [fop] 	at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:158)
      [fop] 	at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:389)
      [fop] 	at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:112)
      [fop] 	at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:143)
      [fop] 	at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
      [fop] 	at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:130)
      [fop] 	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:360)
      [fop] 	at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:190)
      [fop] 	at net.sf.saxon.event.ContentHandlerProxy.endElement(ContentHandlerProxy.java:414)
      [fop] 	at net.sf.saxon.event.NamespaceReducer.endElement(NamespaceReducer.java:228)
      [fop] 	at net.sf.saxon.event.ComplexContentOutputter.endElement(ComplexContentOutputter.java:578)
      [fop] 	at net.sf.saxon.event.ReceivingContentHandler.endElement(ReceivingContentHandler.java:459)
      [fop] 	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
      [fop] 	at org.ditang.relaxng.defaults.RelaxNGDefaultsComponent.endElement(Unknown Source)
      [fop] 	at org.apache.xerces.xinclude.XIncludeHandler.endElement(XIncludeHandler.java:1071)
      [fop] 	at org.apache.xerces.impl.XMLNSDocumentScannerImplXerces.scanEndElement(XMLNSDocumentScannerImplXerces.java:673)
      [fop] 	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:319)
      [fop] 	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1647)
      [fop] 	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:325)
      [fop] 	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      [fop] 	at org.ditang.relaxng.defaults.RelaxDefaultsParserConfiguration.parse(Unknown Source)
      [fop] 	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      [fop] 	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      [fop] 	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      [fop] 	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      [fop] 	at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:427)
      [fop] 	at net.sf.saxon.event.Sender.send(Sender.java:138)
      [fop] 	at net.sf.saxon.jaxp.IdentityTransformer.transform(IdentityTransformer.java:383)
      [fop] 	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:293)
      [fop] 	... 47 more
      [fop] Caused by: java.lang.UnsupportedOperationException: coverage set class table not yet supported
      [fop] 	at org.apache.fop.complexscripts.fonts.GlyphClassTable$CoverageSetClassTable.<init>(GlyphClassTable.java:259)
      [fop] 	at org.apache.fop.complexscripts.fonts.GlyphClassTable.createClassTable(GlyphClassTable.java:88)
      [fop] 	at org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readGDEFMarkGlyphsTableFormat1(OTFAdvancedTypographicTableReader.java:3339)
      [fop] 	at org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readGDEFMarkGlyphsTable(OTFAdvancedTypographicTableReader.java:3352)
      [fop] 	at org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readGDEF(OTFAdvancedTypographicTableReader.java:3422)
      [fop] 	at org.apache.fop.complexscripts.fonts.OTFAdvancedTypographicTableReader.readAll(OTFAdvancedTypographicTableReader.java:82)
      [fop] 	at org.apache.fop.fonts.truetype.OpenFont.handleCharacterSpacing(OpenFont.java:886)
      [fop] 	at org.apache.fop.fonts.truetype.OpenFont.readFont(OpenFont.java:858)
      [fop] 	at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:117)
      [fop] 	at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:101)
      [fop] 	at org.apache.fop.fonts.FontLoader.getFont(FontLoader.java:126)
      [fop] 	at org.apache.fop.fonts.FontLoader.loadFont(FontLoader.java:110)
      [fop] 	at org.apache.fop.fonts.LazyFont.load(LazyFont.java:119)
      [fop] 	... 97 more
      [fop] 
      [fop] C:\test\temp\pdf\topic.fo -> C:\test\out\pdf\flowers.pdf
I hope it makes it clearer... thanks for your help :)

Radu
Posts: 6987
Joined: Fri Jul 09, 2004 5:18 pm

Re: XSL-FO to PDF fails due to font error

Post by Radu » Tue Jan 21, 2020 1:33 pm

Hi,

Looks like this bug:

https://issues.apache.org/jira/browse/FOP-2704

There is a fop.xconf file in:

OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT3.x/plugins/org.dita.pdf2.fop/cfg/fop.xconf

Maybe you can try the advice on the issue above and add to it an element to disable complex scripts:

Code: Select all

<complex-scripts disabled="true" />
but as it's specified on the thread, this might not work for fonts which are automatically gathered.
The issue was added by my colleague Dan but even if we patch things on our side to make this work, we'll probably focus on fixing things in the CSS-based PDF processor and not in the Apache FOP used for the XSL-FO based publishing.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

llpick
Posts: 8
Joined: Sat Jun 23, 2018 12:52 am

Re: XSL-FO to PDF fails due to font error

Post by llpick » Tue Jan 21, 2020 4:00 pm

The PDF now generates properly. Thank you so much Radu for saving the day :D

Post Reply