Advertisement Jump to content


This topic is now archived and is closed to further replies.


Changing the color of a bitmap font

This topic is 6393 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

I have a bitmap font I use to draw text with. It is a white font. Using DDraw or GDI, how would I dynamicly change the color of the text? Do I have to map another color over it? If so, is that very fast & efficient? How would I do that? Thanks

Share this post

Link to post
Share on other sites
Destination color keys are not always supported.

What I do in my lib is use source color keys. In my font structure I store the current foreground and the current background color. When I want to change the font (foreground) color, here''s what I do:

1) Set the font surface''s color key to the current font color (in your case, white).

2) Create a new surface of the same dimensions as the font surface

3) Fill the new surface with the color you want to change the font to

4) Blit the font onto the new surface

5) Now you can either switch the surface pointer in your font object to point to the new surface, or blit the new surface on top of the font surface.

6) Depending upon which method you used in step 5, release the surface you no longer need.

That''s it. Nothing to it, and it works quite fast.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!