SFML community forums
Help => Graphics => Topic started by: xqbt on July 10, 2016, 09:44:11 am
-
So I have this string which I have to display and some characters in it may be of different styles than other characters. Something like this:
SFML String
This is one sf::String and I need to draw it. But as far as I can see, sf::Text does not allow for character-based style change.
So, what would be a good (and efficient) way pull it off? For once, I could imagine iterating all the characters and drawing them one-by-one using a separate sf::Text object along with getCharacterPos().
I mean that's not too bad, but maybe I am missing something.
-
As you said, you could draw each character separately with their own style (or split it into substrings with different styles)
However, if the text doesn't constantly change, then i'd suggest drawing the text to a RenderTexture, and then drawing the RenderTexture to the window.
-
Thanks for reply :) I thought about that too, turns out it is even slower (http://en.sfml-dev.org/forums/index.php?topic=20485.0). But piece-by-piece stylization will work anyway.
-
You can take a look at RichText (https://github.com/skyrpex/RichText) which provides different options to change the text style on the fly.
-
eXpl0it3r, thanks for the link, I will check it out!