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

    Details

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

      Description

      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:
      http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/a0c8eb083f39

      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).

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated: