JDK-8307363 : TextFlow.underlineShape()
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-05-03
  • Updated: 2023-05-23
  • Resolved: 2023-05-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
jfx21 b17Fixed
Related Reports
CSR :  
Relates :  
Description
Create a new method to provide underline shape (a line under text in the range), similar to Text.underlineShape():

    /**
     * Returns the shape for the underline in local coordinates.
     *
     * @param start the beginning character index for the range
     * @param end the end character index (non-inclusive) for the range
     * @return an array of {@code PathElement} which can be used to create a {@code Shape}
     * @since 21
     */
    public final PathElement[] underlineShape(int start, int end) {
        return getRange(start, end, TextLayout.TYPE_UNDERLINE);
    }

FYI.
The shapes being returned is not a line but a rectangle (moveto + lineto segments).  There seems to be somewhat complicated logic that constructs a simple line in TextInputControl.createInputMethodAttributes() 
Comments
Changeset: 604fc262 Author: Andy Goryachev <angorya@openjdk.org> Date: 2023-05-11 21:22:55 +0000 URL: https://git.openjdk.org/jfx/commit/604fc26219a10114c22aea5062bad228a34dc7c0
11-05-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/1127 Date: 2023-05-04 18:50:35 +0000
04-05-2023

A related question: should we make public other shapes? TextLayout: public static final int TYPE_TEXT = 1 << 0; public static final int TYPE_UNDERLINE = 1 << 1; public static final int TYPE_STRIKETHROUGH = 1 << 2; public static final int TYPE_BASELINE = 1 << 3; public static final int TYPE_TOP = 1 << 4; public static final int TYPE_BEARINGS = 1 << 5; Answer: NO
04-05-2023