RFR: 8341670: [Text, TextFlow] Public API for Text Layout Info [v29]
Andy Goryachev
angorya at openjdk.org
Thu May 22 18:11:16 UTC 2025
> Please refer to
>
> https://github.com/andy-goryachev-oracle/Test/blob/main/doc/Text/LayoutInfo.md
>
> The RichTextArea control ([JDK-8301121](https://bugs.openjdk.org/browse/JDK-8301121)), or any custom control that needs non-trivial navigation within complex or wrapped text needs a public API to get information about text layout.
>
> This change fixes the missing functionality by adding a new public method to the `Text` and `TextFlow` classes.:
>
>
> /**
> * Obtains the snapshot of the current text layout information.
> * @return the layout information
> * @since 25
> */
> public final LayoutInfo getLayoutInfo()
>
>
> The `LayoutInfo` provides a view into the text layout within `Text`/`TextFlow` nodes such as:
>
> - caret information
> - text lines: offsets and bounds
> - overall layout bounds
> - text selection geometry
> - strike-through geometry
> - underline geometry
>
>
>
>
> ## WARNING
>
> Presently, information obtained via certain Text/TextField methods is incorrect with non-zero padding and borders, see [JDK-8341438](https://bugs.openjdk.org/browse/JDK-8341438).
>
> This PR provides correct answers in the new API, leaving the behavior of the existing methods unchanged (there is a compatibility risk associated with trying to fix [JDK-8341438](https://bugs.openjdk.org/browse/JDK-8341438) ).
>
>
>
> ## Testing
>
> The new APIs can be visually tested using the Monkey Tester on this branch:
> https://github.com/andy-goryachev-oracle/MonkeyTest/tree/text.layout.api
>
> in the Text and TextFlow pages:
> 
>
> Two very basic headful tests have been added.
>
>
> ## See Also
>
> https://github.com/FXMisc/RichTextFX/pull/1246
Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:
removed getStrikeThroughShape
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/1596/files
- new: https://git.openjdk.org/jfx/pull/1596/files/c885173b..0f02fe9d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=1596&range=28
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=1596&range=27-28
Stats: 8 lines in 2 files changed: 2 ins; 0 del; 6 mod
Patch: https://git.openjdk.org/jfx/pull/1596.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1596/head:pull/1596
PR: https://git.openjdk.org/jfx/pull/1596
More information about the openjfx-dev
mailing list