Color markup language does not work for Scene2D Labels
See original GitHub issueApparently it’s because Label
wipes out the color specified in the markup language with its own Color
property. The text does get parsed (i.e. [RED]velvet
turns into velvet
), but not recolored.
Issue Analytics
- State:
- Created 9 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Change the color of one word in a phrase using label, libgdx?
You can use color markup language, that Label supports as well. Enable markupEnabled on the BitmapFont font.getData().markupEnabled = true;. I' ...
Read more >Color Markup Language - libGDX
The BitmapFontCache class supports in-string colored text through a simple markup language. Markup is disabled by default. Use the public member font.
Read more >theme-color - HTML: HyperText Markup Language | MDN
The theme-color value for the name attribute of the element indicates a suggested color that user agents should use to customize the display ......
Read more >CHANGES - platform/external/libgdx - Git at Google
- Added color markup support for scene2d label and window title. - API Change: removed default constructor of DecalBatch, removed DefaultGroupStrategy. - ...
Read more >CHANGES · Alien_Dog/libgdx - Gitee.com
- BitmapFont can now render missing (tofu) glyph for glyphs not in the font. - FreeTypeFontGenerator depreacted methods removed. - Fixed BitmapFont color...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kalexmills Probably makes sense to comment on PR #2387 instead of commenting here and linking the PR. 😃
If BitmapFontData
markupEnabled
is true, GlyphLayout parses colors. Label just uses a font, so just give it a font with color markup enabled.I can’t seem to tell how this change is meant to be used in a label to draw multiple colors in a label. From what I understand of the commit, the only merged change from that class was to use .font instead of .color
It seems that the intent was to give Label a way to append text, rather than resetting the entire text. Should we add an appendText method, to allow users to add some text to a Label, change the color, then add more text (which will use the new Color))?
Or maybe I am missing something crucial. Still new to this library (which, so far, is awesome.)
Referencing the commit below: https://github.com/libgdx/libgdx/pull/2387/files