Jump to content
  • Advertisement

Archived

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

Wymsical Wyvern

Font Engine

This topic is 6889 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'm not exactly sure what your implementation is like, but I would split up the bitmap into 256 sprites, corresponding to ASCII characters. You usually only need the first 128 to actually write text, so you can use the other half for special symbols specific to your game.

DrawChar (byte symbol)
{
draw the sprite using font_data[symbol]
}

This is roughly how I do it (not exactly) but the idea is the same.

As for different colors, I would suggest you have two drawing modes. One for monochrome fonts, and another for "sprite" fonts. You could allow to change between drawing modes at run-time if you want.

monochrome fonts just draw any non-transparent pixels using the FOREGROUND color and if the background color isn't transparent, draw it using the BACKGROUND color... seems simple but sometimes simple stuff is hard

The "sprite" drawing mode is just what it implies. You just draw the characters as if they were sprites (with transparency if you wish) so you can draw the characters as nicely as you want in a paint program (for those nice colorful fonts) and they will just display as sprites on screen.

Hope this helps.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I'm currently trying to write the font engine for my game.

Right now i've got a CFont class, which loads a bitmap into a CSprite class. My sprite class splits up the bitmap into frames and i can call up anyframe when i need it, so that part of my font engine is settled. The problem that i have is with the part just before drawing. the CFont class has a function called DrawString( char* string, x, y, destination_surface ). I've got it to call strlen() to get the size, then there is a for loop that will send character by character to the function DrawChar( char, x, y, dest ).
And here is where my problem is right now I'm using a case statement to parse the character then switch to the corresponding frame in the bitmap. Am I right to do this? Am I right to pass strings like that? And how am I sure that I've got all the characters in the character set in my case statment? Which set of character codes should I use ASCII or ANSI? I'm using ANSI right now, but the chart in MSDN does not give me the same characters as I do when I type alt-### And how would I implement colour changing?

I know some of these questions may seem a bit basic and some may have been answered before but right now I'm totally lost here.

Thanks in advanced

Wymsical Wyvern

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!