Color Markup Language - s76/libgdx GitHub Wiki
The BitmapFontCache class supports in-string colored text through a simple markup language.
Markup is disabled by default. Use the method BitmapFont.setMarkupEnabled() to turn it on/off.
The markup syntax is really simple but still versatile:
- [name] Sets the color by name. There are a few predefined colors, see the Colors.reset() method for an exhaustive list. Users can define their own colors through the methods of the Colors class.
- [#xxxxxxxx] Sets the color specified by the hex value
xxxxxxxxin the formRRGGBBAAwhere AA is optional and defaults to 0xFF. - [] Sets the color to the previous color (kind of optional end tag)
- [[ Escapes the left bracket.
Notice that color names are case-sensitive, cannot be empty, cannot start with neither # nor [, and cannot contain ]. Also, any occurrence of [ in the color name must not be escaped.
For a sample code see the test class BitmapFontTest.