Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Font Engine


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
2 replies to this topic

#1 Wymsical Wyvern   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 September 1999 - 06:09 AM

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


Sponsor:

#2 foofightr   Members   -  Reputation: 130

Like
Likes
Like

Posted 12 September 1999 - 05:47 AM

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.


#3 Wymsical Wyvern   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 September 1999 - 06:09 AM

I'll try that Thx




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.



PARTNERS