Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8211855

ArrayIndexOOB exception when justifying Thai text with text normalization and other broken behavior when you have ligature substitution



    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 9, 10, 11
    • Fix Version/s: tbd
    • Component/s: client-libs
    • Labels:
    • Subcomponent:


      My colleague Yacob Yonas reports:

      The stack trace and relevant code (ThaiJustificationCrash.java) sample are attached. I believe that the issue stems from this patch into jdk9:

      This patch updates the text justification code to no longer assume that "there can not be fewer glyphs than characters" since that is not necessarily always true. To do this, the code allocates a new fixed size array for creating GlyphJustificationInfos, and it is sized by the number of characters. However, as noted in another comment in the method, "there can be more glyphs than characters (glyph insertion, perhaps based on normalization, has taken place)".

      As a result, there are ArrayIndexOutOfBoundsExceptions when trying to get justified layouts for Thai text that lays out with more glyphs than characters.

      Furthermore, in general, this code makes assumptions about a 1:1 mapping from glyph to character, but that doesn't handle ligature substitution or text normalization properly. If there are ligatures, then the indices into the GlyphJustificationInfos will be wrong and the code results in bad justification.
      Run the code sample in JustificationSample.java and toggle ligatures on and off to observe this behavior. Note: this doesn't cause a crash but the behavior is not justified correctly (e.g. there is uneven spacing between words).




            • Assignee:
              prr Philip Race
              martin Martin Buchholz
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: