SFML community forums
Help => Graphics => Topic started by: mkalex777 on September 30, 2015, 04:47:33 am
-
I'm implemented a game console, such as used in Doom, Quake, Stalker, Crysis and other 3D shooters.
It's very useful for debugging and works fast enough, but there is a little question about rendering colored texts.
I'm using colored text output to make it more readable.
For simplification purposes, I'm using special text codes to switch current text color. For exampe:
"$1Hello $2world!"
It will be rendered as white "Hello" and blue "world".
To render such texts I'm split it into several parts for each color and then render it with calling Text.GetLocalBounds to measure it's size.
So, the question - is there any better way to render text which consists of sub-strings with different colors?
-
Have you looked into existing solutions? E.g. https://github.com/skyrpex/RichText
-
There have also been source codes on this forum and maybe the Wiki, you could search a bit.