Jump to content

View more

Image of the Day

The beast has a mighty searchlight of evil! #screenshotsaturday https://t.co/bzKepOojDL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

SFML 2.0 Bitmap font with different colors?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 Nausea   Members   

258
Like
0Likes
Like

Posted 28 November 2013 - 08:19 PM

Hey!

 

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.

Thanks

 

 

edit:

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);
	   FontSprite.setColor(BlueColor);
	   show = (show + 1);					
	}
}

Edited by Nausea, 29 November 2013 - 12:37 AM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.