I noticed tab stops in BitmapText don’t work as I would expect.
One issue is clearly a bug: The first explicitely set tab stop (BitmapText.setTabPosition()) is always skipped.
The other thing is that “normal” tabs just add a fixed spacing without aligning anything to columns.
I already fixed it… but is a fix even desired?
It could break things that rely on the current implementation.
Is the fixed spacing really undesired behaviour? What would you expect from tabs?
PS: Did you know that BitmapText can parse color codes like \#c0ffee# ? Pretty cool
It would probably be nice to have tab stops working… but note: if you fix it in one place then there are more places to fix. For example, line width is calculated using its own loop that is separate from the loop that lays out the mesh.
Yes, it’s dumb. The whole set of classes is pretty bad at this point.
I see… BitmapFont.getLineWidth() doesn’t care about tabs.
But I think the interface is clear on this. There’s no way to pass custom tab positions so a caller won’t expect that it returns accurate values when using tabs.
It could however use the default value for tabWidth. Right now a tab character adds 0 width.
I amended the last commit and added handling for tabs in BitmapFont.getLineWidth().
I moved the calculation of tab width to StringBlock and removed the getters for tab position/width which also removes the necessity to clone the tabPos array (it is cloned and overwritten in the setter and therefore can be shared across cloned instances - kinda copy-on-write semantics).
For reference regarding cloning: More weirdness when cloning BitmapText - #12 by pspeed
Well I tock a glance, and did notice that a tab is assumed to be 50, always. Question here is, if this should not instead be based on the tab with the used font has.
It’s been a while, so I’m not sure IIRC. You’re talking about BitmapFont.getLineWidth()?
I think the “problem” is that a BitmapFont has no associated tab width. You can only set the tab width in BitmapText.
This kinda makes sense. When you change the font properties (style, size etc.) of a text in a text processor, the tabs stay at the defined position too.
The tabs are more like a property of the paragraph.