Advertisement

Using Windows fonts for games...

Started by May 11, 2000 06:11 PM
6 comments, last by Houdini 24 years, 7 months ago
I recently decided to follow the advice of a most the people on this board and, instead of using the GUI TextOut to print out text, I decided to use bitmaps of the font and print them out. My problem became apparent early. If I make the font bmps too small, then it will be too small in 1024x768, and too big in 640x480. Now, I can obviously scale the bmps to a specific size, but if I enlarge the bmp then it will show "stair stepping" in the font, and if I scale it down then the font will become deformed. So, I decided to follow a few peoples advice and as my game loads, load an internal windows font, print it out to a bmp in memory, then blt that bmp to my screen. This way I can tell windows to load any font/size, and use GetTextExtentPoint32 to calculate how the size of each character. This works great, except for one thing. When I print out the font, I notice that its blocky (stair stepping). Looking back at Photoshop, I notice the same font was anti-aliased to look smooth. How can I do this in Windows? Heres the line I use to load the font: hfont = CreateFont(48, 0, 0, 0, FW_NORMAL, FALSE, False, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH, "Viner Hand ITC"); Passing ANTIALIASED_QUALITY SHOULD make it anti-aliased, yet it still comes out looking the same. Anyone have ANY suggestions?
- Houdini
Have you followed this advice from the SDK:

"the display must greater than 8-bit color, it must be a single plane device, it cannot be a palette display, and it cannot be in a multiple display monitor setup. In addition, you must select a TrueType font into a screen DC prior to using it in a DIBSection, otherwise antialiasing does not happen."
Advertisement
Have you followed this advice from the SDK:

"the display must greater than 8-bit color, it must be a single plane device, it cannot be a palette display, and it cannot be in a multiple display monitor setup. In addition, you must select a TrueType font into a screen DC prior to using it in a DIBSection, otherwise antialiasing does not happen."
---RobSee other worlds at http://www.silverfrost.com
Wow, i never heard of this stuff. Where can I get info on how it works, like where in the SDK is it, and are there any tutorials on this stuff?

thanks
Possibility
There is a simple way to make a font anti-aliased. Simply blt out each
character large and then blt in back small. The stretching will create
an anti-aliased effect.
If you were using OpenGL in Win32, you''d use the ''wglUseFontBitmaps'' function to build up a full range of display lists. (check MSVC''s help about this Win32 default extension).
You can blend the lists with different colors, you can scale ''em, ... and render some text in just one OpenGL call!
Advertisement
You could also run your own ''blur filter'' on it... Make a destination bitmap the same dimensions as the source, and for every pixel you copy across, get the average of 9 pixels (the 8 surrounding the source pixel, and the source pixel itself) and copy that across. You can weight this in different ways for slight variations.
I was going to suggest that, but got beaten to it (by something like 30min?). My advice is weigh the center pixel as 50% and the average of the others as 50%. Make sure that you don''t average the already antialiased pixels or your image will smudge and slide across the screen

--------------------


You are not a real programmer until you end all your sentences with semicolons;

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

This topic is closed to new replies.

Advertisement