JDK-8092327 : [Text] Add API to count chars in a cluster
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2012-12-12
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Blocks :  
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
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;

Comments
I filed a new issue to review TextPosInfo: JDK-8136971
22-09-2015

See comments about the new class TextInputControlSkin.TextPosInfo in JDK-8077916. Also related to JDK-8089924.
11-09-2015

Downgrading because there are no remaining depending bugs.
18-10-2013

Hi Leif, give this patch a try, let me know if it helps you in RT-32717.
09-10-2013

Leif, should this be target to Lombard ? Please set the Fix Version if so. Thanks.
09-10-2013

Raising priority again, due to dependency from RT-32717.
04-10-2013

Lowering to medium because RT-26250 has implemented a workaround utility method for HitInfo.getInsertionIndex().
22-08-2013

Sounds good. When the second part is fixed, I can go ahead and apply both to fix RT-26250.
17-07-2013

Hi Leif, For the first part of this bug you can fix that using BreakIterator#getCharacterIterator(), The second part, I have to fix on my end.
17-07-2013

Bumping to P3. Thanks for understanding. :)
07-05-2013

Leif, I don't think I'll have the time to fix this problem for Lombard, are you okay with that ?
07-05-2013