Text formatting in label

I was digging through some gui code and noticed Jmonkey has a “ColorTags” class. I cannot find documentation for it anywhere. Does Lemur have something similar to html color tags or markup? I’d like to be able to highlight keywords in a label by having the words color be different. I’d also like to re-visit a typing effect I made but by making the letters go from transparent to their destination color instead of adding characters to the string to prevent words from “popping” when they overflow.
Sorry if I missed something obvious, but I didn’t see any info on html or similar markup in the lemur docs and basically nothing is listed for jme gui

1 Like

Lemur is using JME’s BitmapText so the color tags will work. I think we picked this convention up from nifty but I’m not sure. I don’t know that it’s well documented but you can kind of see how it works looking in the bitmap text related classes.

Thanks, I’ll have a look and see if I can’t figure it out!

I didn’t know that until now :smiley:
See jmonkeyengine/ColorTags.java at master · jMonkeyEngine/jmonkeyengine · GitHub for reference

 * Contains the color information tagged in a text string
 * Format: \#rgb#
 *         \#rgba#
 *         \#rrggbb#
 *         \#rrggbbaa#

Yeah, there’s some other stuff that BitmapText is capable of (e.g. mix multiple fonts into one font and thus combine fat, plain, italic - doesn’t work good at the moment). But in the end it’s kind of crappy today and a better BitmapText2 would be needed. I was making that but got lost in all the possibilities that one might want. In theory it’s simple: Just a custom mesh for the glyphs and multiple textures for the bitmap information, combined with some meta data from the .fnt files. Then write a new class for “enriched text formatting” (colors, fonts, animation, shaking glyphs, writing in circles, writing in speech bubbles, etc.). Not so easy once you want to have all those fancy things… :wink:

Improved text rendering is also something I’d like to see in the engine. At Christmas time I spent a couple days implementing Valve’s SDF (Signed Distance Field) technique (http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf) for text rendering, but I wasn’t able to get past an antialiasing issue on the glyphs. (Antialiasing itself isn’t hard to do, but when the individual letters were antialiased enough to give a good result a white font looked grey against a black background, but turning down the antialiasing parameters resulted in crappy looking glyphs.) I’d like to implement “real” vector font rendering as that should produce the best result with the least work by a designer (no need to pack a font atlas), but it’ll probably be 6 months to 1 year before I can get to that.

I’m not sure but @Tryder did something related to font rendering, so check out what he did so you guys don’t both do the same work :slight_smile:

Yeah, I’ve seen his library and it looks outstanding. I haven’t used it myself because of dependency issues and also because I’m not sure what his plans for long term support of it are (and plans change, even if he plans on supporting it for the forseeable future).

As I recall, one of its display modes renders TrueType glyph outlines to an atlas and displays that with the standard BitmapText system. There’s absolutely nothing wrong with this approach, or any reason not too, really. The only downside is that you need to go through his library rather than a core class to display text, which isn’t a big deal, but if you ever want to switch text renderers you’ll have some refactoring to do.

My plan is to render vector glyphs directly in the fragment shader, using a scheme similar to this one but simplified (rotating quadratic Bezier curves isn’t all that expensive, but I believe I’ve hit on an approach that eliminates the need for it): GPU text rendering with vector textures · Will Dobbie. It’s a bit early to comment, but I think it’s possible to integrate with the existing BitmapText classes (or something very similar), and I’d be happy to contribute it to jME assuming I ever complete it (and get good enough + efficient enough visual results). The result would be vector font rendering at runtime without any external dependencies and a lot more flexibility (no need to generate bitmap atlases, even at runtime).