Advertisement

Font engines

Started by March 13, 2000 03:26 AM
14 comments, last by Spiff 24 years, 7 months ago
Ok, thanks for your help, people.

One more question though. I would like to specify the color of the text too without creating alot of surfaces for every color. How can I easily change the color of what I''m blitting? (preferably without anything but DirectDraw)

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
If you're using DX, there was as similar question a while ago:


I wonder how they did it

I think they eventually decided to do the color conversions at run-time. Oh no! Mithrandir's pics are gone. Maybe you could ask him to send them to you -- they're really good illustrations of the task.

Good Luck!


- null_pointer


Edited by - null_pointer on 3/14/00 8:09:51 AM
Advertisement
i won't get into the nuts and bolts of it, but this is the font i use :


you might recognize it, it's the default font from mirc32 (fixedsys), but it does the job for me. having 256 elements allows you to customize the fonts for non-standard characters you want to include in your game, lets say a heart or an odd looking arrow. these can be part of the font itself. you would put these in the 128 to 255 portion of the image, so they dont disturb the ASCII portion.

the way i have it, you can make it a monochrome display (with transparent background like in the image) or have it drawn as a normal sprite so that the characters can be comprised of more than one color.

this works really well for me, i just need to call one function to load the font, and another to display text:

font_id = FONT_LoadFont("fixedsys.pcx", etc etc);
font_id2 = FONT_LoadFont("anotherfont.pcx", etc etc);
FONT_GotoXY(font_id, 100, 100);
FONT_Print(font_id, "HP: %d MP: %d", hitpoints, magicpoints);

Edited by - foofightr on 3/14/00 2:10:22 PM
and this is the 8x8 BIOS font:


and a 6x4 font i drew myself!


These look really tiny in desktop of 1024x768, but they look fine in fullscreen 640x480. (ok well the 6x4 looks tiny in any resolution except 320x200)

Sorry if it sounds like I''m tooting my own horn, but I really like my font system :D
I think there is a better way to do colored text than the alpha blending scheme in the above thread. Since text only requires 2 colors (the text and transparency) you could accomplish the same thing with 2 sets of transparent blits.

1) Create a temp surface to hold your entire message and fill it with the color you want the text to be.

2) Blit the characters from your font file to the temp surface with *black* as the transparent color. This will give you a message that is the right color, surrounded by magenta.

3) Blit the message to the back buffer, but this time use the magenta as the transparent color.

This should still work for black text since the first blit will do practically nothing (you could optimize this part, but it shouldn''t matter too much) so you don''t even have to have 2 special colors to do the 2 transparent blits!

Hope this helps.
When you scale a font up, it looks very pixelated. That''s OK for some bitmaps, but text just looks bad that way.

When you scale a font down, important parts end up not being drawn. A scaled-down E may look like F or L, depending on the scale. This is assuming you don''t anti-alias it, but of course AA is very slow.

~CGameProgrammer( );

~CGameProgrammer( ); Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.

This topic is closed to new replies.

Advertisement