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

[Text] Add API to count chars in a cluster

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8
    • javafx

      When Text combines Unicode character clusters into ligatures, etc, the text editing controls will need a way to count the chars in a cluster in order to skip them as a whole, or to delete them.

      This request comes in two parts.

      1. Provide a method in the Text class similar to java.lang.Character.offsetByCodePoints().

      See http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#offsetByCodePoints%28java.lang.CharSequence,%20int,%20int%29

      This could be:
        public int offsetByCharCluster(int index, int clusterCount);
      where clusterCount is the number of clusters to include after (or before if negative) the index. The clusterCount value will probably not be greater than 1 in most cases, but this is a simple way to also provide the direction.

      Note that the method should include the functionality of offsetByCodePoints() and count surrogate character pairs as clusters as well.

      2. Include cluster offset as part of the HitInfo object returned from a hit test. The method
      HitInfo.getInsertionIndex() should then add that number instead of 1 when leading is false;

            prr Philip Race
            leifs Leif Samuelsson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Imported: