Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


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

#1 simulator   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 05:38 AM

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.

Sponsor:

#2 Midnight Coder   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 06:47 AM

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

#3 jaxson   Members   -  Reputation: 127

Like
Likes
Like

Posted 28 July 2001 - 06:59 AM

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.

#4 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 07:29 AM

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







#5 simulator   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 08:19 AM

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

#6 simulator   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 08:47 AM

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?

#7 Dog_Food   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 08:56 AM

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.

#8 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 10:30 AM

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....




#9 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 10:32 AM

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...?

#10 simulator   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 12:28 PM

Hey Dog-food thanx! I''ll email you now. This GameFontDX is, ummm, not really obvious for me..... so thanx

#11 simulator   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 12:32 PM

Hi granat- that would be great - ive been curious about how to do that.Thanx.

You guys are so helpful!! This forum is great
I''ll try to write a generalized blitting function to read in dog-food''s output- if it works, I''ll post it here.

Thanx

#12 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 01:18 PM

I have sent you the code

#13 Dog_Food   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 02:49 PM

Although I am hesitant to post code online (code for other people must meet a higher standard of quality), here is a link to the bitmap font generator.
http://www.mazurek.net/lee/fontgen.zip

(Sorry, would have made html link but that didn't work and screwed up page formatting)

Edited by - Dog_Food on July 28, 2001 9:51:49 PM

#14 simulator   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 July 2001 - 03:14 PM

Hey Granat thank you- I got it working after a little tweaking!!!

And Dog-food thank you- I''ll download it now & no worries- I don''t mind imperfect code- that''s actually how I learn




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