Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-2977

[PATCH] Array index out of bounds with glyph position adjustments and surrogate pairs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.6
    • 2.8
    • renderer/pdf
    • None
    • Windows 10

    Description

      Out of bounds happens in org.apache.fop.fonts.GlyphMapping.processWordMapping when:

      1. There are glyph position adjustments for the font being used
      2. There are surrogate pairs in the text that has adjustments

      The font I've used to reproduce the issue so far is Segoe UI Emoji, which should be installed on Windows 10 by default.

      input.fo attached to cause the crash.
      I believe I've fixed the crash in the attached patch.

      There's a separate issue demonstrated in the input.fo that the glyphs don't render in some cases, even though the font is the same throughout everything. But I'd like to make sure my fix for the crash is correct before I dig into the rendering issue.

      org.apache.fop.apps.FOPException: java.lang.ArrayIndexOutOfBoundsException: 3
      javax.xml.transform.TransformerException: java.lang.ArrayIndexOutOfBoundsException: 3
      	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:296)
      	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:116)
      	at org.apache.fop.cli.Main.startFOP(Main.java:183)
      	at org.apache.fop.cli.Main.main(Main.java:214)
      Caused by: javax.xml.transform.TransformerException: java.lang.ArrayIndexOutOfBoundsException: 3
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:737)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:343)
      	at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:293)
      	... 3 more
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
      	at org.apache.fop.fonts.GlyphMapping.processWordMapping(GlyphMapping.java:177)
      	at org.apache.fop.fonts.GlyphMapping.doGlyphMapping(GlyphMapping.java:92)
      	at org.apache.fop.layoutmgr.inline.TextLayoutManager.processWord(TextLayoutManager.java:963)
      	at org.apache.fop.layoutmgr.inline.TextLayoutManager.getNextKnuthElements(TextLayoutManager.java:881)
      	at org.apache.fop.layoutmgr.inline.LineLayoutManager.collectInlineKnuthElements(LineLayoutManager.java:698)
      	at org.apache.fop.layoutmgr.inline.LineLayoutManager.getNextKnuthElements(LineLayoutManager.java:627)
      	at org.apache.fop.layoutmgr.BlockLayoutManager.getNextChildElements(BlockLayoutManager.java:141)
      	at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextKnuthElements(BlockStackingLayoutManager.java:292)
      	at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:113)
      	at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:105)
      	at org.apache.fop.layoutmgr.BlockLayoutManager.getNextChildElements(BlockLayoutManager.java:141)
      	at org.apache.fop.layoutmgr.BlockStackingLayoutManager.getNextKnuthElements(BlockStackingLayoutManager.java:292)
      	at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:113)
      	at org.apache.fop.layoutmgr.BlockLayoutManager.getNextKnuthElements(BlockLayoutManager.java:105)
      	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextChildElements(FlowLayoutManager.java:223)
      	at org.apache.fop.layoutmgr.FlowLayoutManager.addChildElements(FlowLayoutManager.java:148)
      	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:116)
      	at org.apache.fop.layoutmgr.FlowLayoutManager.getNextKnuthElements(FlowLayoutManager.java:69)
      	at org.apache.fop.layoutmgr.PageBreaker.getNextKnuthElements(PageBreaker.java:252)
      	at org.apache.fop.layoutmgr.AbstractBreaker.getNextBlockList(AbstractBreaker.java:675)
      	at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:179)
      	at org.apache.fop.layoutmgr.PageBreaker.getNextBlockList(PageBreaker.java:159)
      	at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:385)
      	at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:113)
      	at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:143)
      	at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
      	at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:139)
      	at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:362)
      	at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:190)
      	at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endElement(ToXMLSAXHandler.java:265)
      	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
      	at org.apache.xerces.xinclude.XIncludeHandler.endElement(Unknown Source)
      	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
      	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
      	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
      	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
      	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:659)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:728)
      	... 5 more
      
      

      Attachments

        1. fop.xconf
          1 kB
          Simon Steiner
        2. test.fo
          1 kB
          Simon Steiner
        3. drawTextWithDX.patch
          3 kB
          Kelly H Wilkerson
        4. arrayindex.patch
          1 kB
          Kelly H Wilkerson
        5. input.fo
          1 kB
          Kelly H Wilkerson

        Issue Links

          Activity

            People

              ssteiner Simon Steiner
              kwilkerson Kelly H Wilkerson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: