JDK-8341672 : [Text/TextFlow] getRangeInfo
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2024-10-07
  • Updated: 2024-10-11
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
Cloners :  
Description
The RichTextArea control (JDK-8301121), or any custom control that need to render custom text decorations (such as selection blocks, squiggly lines, strike-through lines, to name a few) can benefit from a better public API representing the range.

Currently, the range is represented by an array of PathElements in an undocumented fashion; the reverse engineering shows that it is typically a sequence of [MoveTo,LineTo] for single lines, or [MoveTo,LineTo,LineTo,LineTo, LineTo] for blocks.

One possibility is to add a new method to Text / TextFlow:
  public RangeInfo getRangeInfo(int start, int end, RangeType type)
or possibly
  public RangeInfo getRangeInfo(int start, int end, RangeType type, boolean includeLineSpacing)
to address
JDK-8317120 RFE: TextFlow.rangeShape() ignores lineSpacing
JDK-8317122 RFE: TextFlow.preferredHeight ignores lineSpacing

The RangeInfo class would provide the following data points:
- PathElement[] getRangeShape() // to be used by the legacy rangeShape() method
- PathElement[] getUnderlineShape() // to be used by the legacy underlineShape() method
- PathElement[] getStrikeThroughShape()
- getPartCount // the number of "parts", i.e. lines or rectangular blocks
- getBounds(int part) // the bounds of each part

The RichTextArea requires such a public API in TextFlow only, but we'll basically get the same functionality for Text node for free.

NOTE: this API is somewhat derivative of JDK-8341670 [Text,TextFlow] Public API for Text Layout, it might be possible to roll the requested functionality into LayoutInfo class.
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jfx/pull/1596 Date: 2024-10-08 16:07:54 +0000
11-10-2024