JDK-8130738 TextFlow's tab width is static

Scott Palmer swpalmer at gmail.com
Thu Sep 19 01:14:00 UTC 2019

I would like to implement this feature, being able to adjust the tab size in a TextFlow or Text node (JDK-8130738 <https://bugs.openjdk.java.net/browse/JDK-8130738>).  It involves new public API, so I want to start a discussion about it here.  (My motivation is that RichTextFX suggests an entirely unacceptable workaround of substituting actual spaces when the tab character is typed and cites the lack of this API.)

I’ve already jumped the gun and taken a crack at an implementation.  It is currently incomplete as I was just poking around to see if it was going to be easy enough to not take up too much of my time.  It boils down to:
TextFlow and Text get a new property for tab width, an integer representing the number of spaces taken by a tab. (The value is only used to initialize the tab width for the TextLayout when needed.)
TextLayout interface gets a new method:  boolean setTabWidth(int spaces)
TextLayout gets a new constant: DEFAULT_TAB_WIDTH = 8;
PrismTextLayout implements the new setTabWidth API.

I’m not sure that the Text node needs this new property.  I figured it would be rarely used on that class, so I had implemented it via an added property in the private TextAttributes class.  Maybe it isn’t needed at all.

What’s the next step?



More information about the openjfx-dev mailing list