Font Blitters- the only way????????

Started by
12 comments, last by simulator 22 years, 8 months ago
Hi All :-) I have a silly but serious newbie question concerning font blitters (chopping up bitmaps to write text): Are font blitters really the only way to write text to a directdraw surface??? Any other, more direct or "built in" approaches??- ie: set the font/color/size and that''s it??? Ive scanned the win32 and directx sdk''s and can''t find anything. Yikes!!! If font blitters are really what''s used, is there anywhere I can download pre-packages ones: ie: with different font style bitmaps and lots more features than I would ever program myself?? (I''m sure no one but font specialists focus on font blitters in great depth?????) Thanx, I am really curious about this.... I''d be happy for any info.
Advertisement
There is of course a ton of Windows API functions for drawing text and creating fonts, but for a game font blitters are best because the GDI is painfully slow. If you must use GDI functions, look up CreateFont, DeleteObject, TextOut, and DrawText. Be careful about memory leaks when using different fonts.

I would still recommend writing your own font blitter. It really isn't all that difficult. To use your own font blitter in DirectDraw, just make a bitmap of all the characters of the font you want to use (not very hard, just takes a while), then load them onto a surface somewhere. Then have your own text function which your program can pass a string of text to. Then, in your text function, just loop through each character of string, a blit the appropriate character based on the ASCII value of that character. To change the color of your font, you'd use a destination color key. Trust me, it takes a while, but it is very rewarding when you finish your own font engine. Plus you won't get slowed down by GDI.

Edited by - Midnight Coder on July 28, 2001 1:48:06 PM
DirectX 8 has the ID3DXFont interface. Look it up in the help under the Direct3DX reference. I posted a reply about how to use this interface a couple days ago.

It is slower than a font blitter, but if you don''t use much text onscreen, it is definitely easier than writing a whole font system of your own.
I aggree with Midnight Coder.

I have just realised (a few days ago) that I can´t rely on windows doing my text. I is VERY slow...

I knew it would not be lightning fast but just how slow it is has surprised me. I now have to make my own font blitting using DirectDraw blt instead.

I am doing a 2D map editor in DirectDraw at the moment. It´s runing in 1024x768.
When printing text using GDI the framerate is 37. Without text it is 75 (max refreshrate of my monitor).

My machine is a Thunderbird 1000mhz and GeForce 3





-------------Ban KalvinB !
Hey thanx for the replys- amazing speed difference! Right now, gdi is out coz I don't even know how to incorperate it into a directx application (im following the online tutorial here). Also, im on windows NT so directx8 is also out.

But still!!!!!!!!!! Im a programmer not an artist. Sure if I want a simple constant-spaced courier style font its an okay task- but I like nice fonts & lots of them- making these in photoshop and then chopping them up etc (as in the online tutorial) well- their character spacing varies in a way I dont know (am i supposed to measure it??) and also, there's italics and bold etc- and even copyright issues perhaps....

Perhaps im lazy- but geesh- there must be really nice "font engines" out there??? Does anyone know of one???? Hey and if they don't exist- hahaha maybe I'll build one and make loads of $$$- Would you buy one??


ps: it would be interesting to see a similar speed comparison between font blitting and the directx 8.0 ID3DXFont interface functions

Edited by - simulator on July 28, 2001 3:25:14 PM
Hey

I searched the archives here & found GameFontDX at
http://maginusorb.dhs.org/gamefont/about.htm
& its free!! Havent used it yet?? Any opinions on it?
I just wrote a font generator program which takes a windows font and converts it into a bmp file, and records the offsets of each character in a separate file. You can have the source, or just the program if you want. Email me at lee@mazurek.net if anyone wants.
Hey Dog_Food..!!!

I could use that too....Please send it to me...

dsl26132@vip.cybercity.dk

I would like to look at the source too....


-------------Ban KalvinB !
quote:
Right now, gdi is out coz I don''t even know how to incorperate it into a directx application.


I can give you some code if you really want it...?
-------------Ban KalvinB !
Hey Dog-food thanx! I''ll email you now. This GameFontDX is, ummm, not really obvious for me..... so thanx

This topic is closed to new replies.

Advertisement