On Fri, 14 Apr 2023 07:35:33 GMT, Karthik P K <k...@openjdk.org> wrote:

> Since surrogate pairs are internally considered as 2 characters and text 
> field is null in `HitInfo` when `getInsertionIndex` is invoked from 
> `TextFlow`, wrong insertion index was returned.
> 
> Updated code to calculate insertion index in `getHitInfo` method of 
> `PrismTextLayout` class when `hitTest` of trailing side of surrogate pair is 
> requested. Since text runs are processed in this method already, calculating 
> the insertion index in this method looks better than calculating in 
> `getInsertionIndex` of `HitInfo` method.
> The latter approach also requires the text to be sent to `HitInfo` as 
> parameter from the `hitTest` method of `TextFlow`. If the number of `Text` 
> nodes in `TextFlow` are very large, processing all the `Text` nodes on each 
> `hitTest` method invocation might cause performance issue. Hence implemented 
> first approach.
> 
> Added system test to validate the fix.

This pull request has now been integrated.

Changeset: c20f6d0f
Author:    Karthik P K <k...@openjdk.org>
URL:       
https://git.openjdk.org/jfx/commit/c20f6d0f0133a59a982959ee2e48809f30f3130b
Stats:     408 lines in 3 files changed: 407 ins; 0 del; 1 mod

8304831: TextFlow.hitTest.insertionIndex incorrect with surrogate pairs

Reviewed-by: angorya, prr

-------------

PR: https://git.openjdk.org/jfx/pull/1091

Reply via email to