question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Color markup language does not work for Scene2D Labels

See original GitHub issue

Apparently 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:closed
  • Created 9 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
NathanSweetcommented, Dec 27, 2017

@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.

0reactions
kalexmillscommented, Dec 23, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found