Jump to content
  • Advertisement

Archived

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

Houdini

Using Windows fonts for games...

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

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?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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."

Share this post


Link to post
Share on other sites
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."

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!