JDK-8090955 : Impossible to set the tabulation indentation size in Text
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-11-12
  • Updated: 2023-08-16
  • Resolved: 2023-08-16
Related Reports
Duplicate :  
Relates :  
Description
The indentation size seems to be hard-coded in PrimsTextLayout: 


    private float getTabAdvance() {
        float spaceAdvance = 0;
        if (spans != null) {
            /* Rich text case - use the first font (for now) */
            for (int i = 0; i < spans.length; i++) {
                TextSpan span = spans[i];
                PGFont font = (PGFont)span.getFont();
                if (font != null) {
                    FontStrike strike = font.getStrike(IDENTITY);
                    spaceAdvance = strike.getCharAdvance(' ');
                    break;
                }
            }
        } else {
            spaceAdvance = strike.getCharAdvance(' ');
        }
        return 8 * spaceAdvance;
    }
Comments
Created a separate ticket for TabStopPolicy: JDK-8314482 Closing this as duplicate.
16-08-2023

The tabSize property has been added in JDK-8130738 However, it is still impossible to implement a more complicated tab stop policy.
21-02-2023

The API I used in the past was to provide a list of tab stops, the last value in the list repeats indefinitely. For example: list=[15] - tab stop every 15 pixels. list=[5, 8, 18] - first stop at 5, the second at 8, then 18, 28, 38, ...
12-11-2013