EDIT: Just reporting a potential issue with LetterQuad.java

Issue is…

BitmapText allows you to set a clipping rectangle. The rectangle’s x and y coordinated do not alter the clipping placement… they re-position the the text. I’m assuming that this is not working as intended… or it would use 2 floats instead of a Rectangle.

So… it looks like a rectangle is used for only clipping the right side of the text O.o

EDIT: See post below

Well… Going through LetterQuad.java … the clip rect is not really being utilized EXCEPT for clipping the right x coord.

Honestly, seems like a waste, as this could be used to clip all 4 sides for various reasons. A standard for instance:

Line wrap is set to Char or Word… the clipping rectangle could be used to clip outside the y coords if the are defined.
TextFields with a set width set to clip (but follow text as it is appended to, could easily be moved + clipped from the left x coord.

Anyways, I’m gonna take a crack at rewriting the LetterQuad class and updating the Clip enum with a few extra settings as this seems sort of incomplete as is.

BitmapText is an extremely fragile class. It’s almost impossible to modify it without breaking 6 other edge cases.

Also beware, BitmapFont and BitmapText both use different loops to calculate line width… if you change one and not the other you break all kinds of things.

You should decide carefully if you really need this functionality. Personally, I’m not sure why. Where the text is placed seems like the job of the layout and not a clipping rectangle… and if you are suggesting clipping the left side of text in addition to leaving it at it’s normal position then you will run afoul of the fact that characters are not the same width.

Or are you talking about actually clipping the letter quad itself? Like only a portion of a letter would show instead of all or none?

I was talking about clipping partial quads… But, I have another solution that I’d like to try before screwing around with this, however… I’m having trouble locating what material BitmapTextPage is actually using and where it is set. Is this hard-coded some place? I see that the texture being set is ColorMap… which narrows down the which, however… it doesn’t help if it can’t be changed.

I’d like to handle all clipping on the shader level to avoid the need to change anything. But this requires being able to change the material used for rendering text as well.

@pspeed Any idea how you set the setRenderedSize for BitmapFont to accurately represent the font size you set in BitmapText for the purpose of using BitmapFont.getLineWidth(String text)?

@pspeed said: Personally, I'm not sure why. Where the text is placed seems like the job of the layout and not a clipping rectangle...

That was kinda the point I was getting at… Using a rectangle to clip the right side of text only seems a little strangle. Why not just use a single float for the width? The other 3 floats of the Rectangle are completely ignored throughout.

The shader is set in the font loader. I think you will get hard resistance if you try to change this to a third material as there was a pretty big push sometime back to reduce everything to just lighting and unshaded.

You can’t set the rendered size of a font. It’s always the natural size loaded from the file. If you want to use font to get a line width then you have to scale the results by the desired size / the font’s preferred size.

TextBox.x is used for stuff… maybe positioning. I don’t remember exactly what and my brain could not stand a deep trip through BitmapText code right now.

The whole thing deserves a rewrite someday. I will probably do it when I really need lit text with my own shaders. I’ve been able to work around it so far. I’m sensitive to changes in this code because each of the last three or four fixes by some other developer meant I had to go fix bugs and I hate working in this code.