There is a method in the BitmapText class setStyle(int), but there is absolutely no documentation on the method. I have been unable to find anything. Thanks for pointing me in the right direction.
This is definitely helpful when creating fonts, however, I don’t know how to use this in code. There is the function to set style for substrings in the bitmaptext class. This could be very useful, and is something I would love to implement. The settings on that page seem to just bold the font.
https://jmonkeyengine.github.io/wiki/jme3/advanced/hud.html#displaying-text-in-the-hud
You asked about setStyle(int). As I understand it,
BitmapFont guiFont = assetManager.loadFont("Interface/Fonts/Console.fnt");
guiFont.setStyle(Font.ITALIC);
As far as setStyle(regexp, int style). As I understand it,
//create regular expression
String regexp = "j[M][eE][1-3]";
hudText.setStyle(regexp, Font.BOLD);
I haven’t gotten to this yet but if I am wrong or misunderstand what you are asking please feel free to correct me.
Uhh, what class are you specifiying for Font? I don’t have anything listed that I can use with intellisense.
java.awt.Font
Yea, that’s not working for me. Perhaps I am being naive, but I sorta doubt that an AWT class would work here. Maybe I am missing something? Did that actually work for you?
Not what you’re looking for, but there’s a less known feature that parses html color codes if added like so:
String text = "whitetext\\#0000FF#bluetext\\#00FF00#greentext"
For example. Where whitetext is the color you set to the bitmaptext and the tags override it for the following section of text until the next tag.
Just a fun fact I guess.
For future development reference:
First, load your fonts using the assetmanager class.
Then, for each font, set a style. 0, 1, 2, 3. if you want to combine styles, you need a font for that.
I.E. bold and italic? You need a .fnt and .png.
Then merge your fonts together. so…
font.merge(boldFont); font.merge(italicFont); font.merge(boldItalicFont); etc.
You can set color immediately, but you need to set color and font together in order to get the font to update correctly.
I call style and color updates along with alignment and boundary (box) calls to ensure that functions correctly.
Hope this helps anyone with a similar issue. I sincerely hope there will be some documentation on this very attractive feature.
Font.PLAIN = 0
Font.BOLD = 1
Font.ITALIC = 2
The wiki can always use a helping hand.
What are you referring to with those 3 lines?
Thank you for this interesting piece of information. that is neat!