Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  

SFML 2.0 Bitmap font with different colors?

This topic is 2152 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



So, I've worked on creating a little application with bitmap fonts. I can add color on top of the text without any issue.

However, I would like to know how I would go about being able to change the color for different parts of the text.


For example:

"Testing ^4this ^2thing", where ^4 would tell the application that the font after it should be red, and the ^2 being say yellow.


I thought about it and it feels like I would need to split the string up at those points and then create a new sprite for the following text. Does this sound like a good idea? Because I felt like this would be very bad if the original string was very large.


Any advice would be great.





So I tried going about it in another way and I'm getting a strange behavior. I'm checking if the current letter is a '^' and if so, is the next letter a '1'. 

If it is, set the color to blue. It does this but somehow the letter before '^' also gets the blue color, I'm at a loss here. Can't figure out why.

else if(Text[show] == '^')
	if(Text[show+1] == '1')
	   sf::Color BlueColor(0,0,255);
	   show = (show + 1);					
Edited by Nausea

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!