Jump to content
  • Advertisement

Archived

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

Biggles

Starting a Font Engine

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

Could someone give me a few pointers on how to create a font engine using bitmaps DX8? I''ve looked around this site and at the d3dfont class, but neither really helped. About all I know is that I have to do something with creating textures with the letters I need and then blit them to screen. I just need a few pointers in the right direction. Thanks in advance. -------------------- Never eat anything bigger than your own head.

Share this post


Link to post
Share on other sites
Advertisement
Thanks. Unfortunately I can''t afford to buy any books right now.

--------------------
Never eat anything bigger than your own head.

Share this post


Link to post
Share on other sites
You might want to have your own font format but I don''t do that so that it''s easier to edit using Photoshop.

What you need is to have each character the same size. I mean, keep them in grids of equal sizes. Even if the character is smaller.

Have another file to ''describe'' the font (bitmap). This includes the height and width. Maybe even a name.

I guess this is only the beginning but I don''t have time to finish this. This is just the loading stage. I''ll leave it up to someone to finish it. Or when I get home.

Share this post


Link to post
Share on other sites
I think I see what you mean. Have a config file for each font that I create and then write a generic font class that can load one of these config files and a bitmap for the font texture. The config file would give the width and height of a letter in pixels. So how do I select a letter? I could create a vertex buffer which has vertices for each letter and uses the correct texture offsets, but then when I draw some text I would lose the vertex buffer that was set as the stream source before drawing the text.

--------------------
Never eat anything bigger than your own head.

Share this post


Link to post
Share on other sites
As a suggestion based upon the system use in "The Zen of Direct3D game programming" (which I think all Direct X programmers should have) you basically have this...

* A bitmap which holds all ascii characters in equal sized grids.
* A loading function which places the bitmap onto it''s own surface.
* An unloading function which removes the surface.
* A function to copy a chosen character from the surface and blit it to the screen. (use ascii values to navigate the surface).
* A function to recursively call the function to copy a character to the screen, most likely using a string.

This should be all you need to create a good font engine, I have one running and plan to extend it using a colour replacement function and a function for loading several fonts.

If you need any more help just reply and I''ll see what I can do.

Stewart

Share this post


Link to post
Share on other sites
quote:
Original post by sjleonard
[snip]* A function to copy a chosen character from the surface and blit it to the screen. (use ascii values to navigate the surface).


What do you mean by "copy from the surface"? Do you mean to have texture coordinates that will take only that part of the surface, or copy that part of the surface into another texture?

--------------------
Never eat anything bigger than your own head.

Share this post


Link to post
Share on other sites
quote:
Original post by Biggles
What do you mean by "copy from the surface"? Do you mean to have texture coordinates that will take only that part of the surface, or copy that part of the surface into another texture?


On my site there is a bit of code that does a font engine. It uses a pre-made bitmap rather than generating one on the fly. Full source, so you can use it as is or just use it to get an idea of one way to do it. It''s not big and I think it''s written in a clear manner.
http://www.drunkenhyena.com/docs/dhFastFont.phtml

The Zen method blows (IMO).


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
I have a really easy to use and understand class written for font handling in DX8. It uses a program called Bitfont Font Builder to create a texture map of all characters, and quickly draws your text for you.

I didn''t write the BFB program, just the DX8 class. I''m giving you a link to the program below. He includes a link to my class from his page.

Best of luck!

Bitmap Font Builder:
http://www.lmnopc.com/bitmapfontbuilder/

My Class:
http://www.wadesoft.com/gamedev/

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!