Jump to content
  • Advertisement

Archived

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

Splizxer

Bitmap font help

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

Ok, so im using the bitmap font tutorial (number 13). Its all fine and dandy, but I want to do some other things with it, like make centered aligned text, underlined (without making a new font list), and drawing a box around the text. I tried to do this: SIZE s; GetTextExtentPoint(hDC, strText, strlen(strText), &s); then the length of the entire string would be s.cx when I type, the length does get longer, different lengths for each character, but its not 100% accurate, the more I type the more its off, say about 3 characters and I can notice the width is terribly incorrect. Anyway, does anyone here know of a way to get the render length of the string? Thanks for your time reading, Splizxer

Share this post


Link to post
Share on other sites
Advertisement
Maybe the space between the characters isn't included in the width, anyway this is just a wild guess.

EDIT: how does the function you call know which font you use? The problem might be the function taking the default font for calculating the length, try fixedsys in your ogl app and try out if the 'i' is shorter than the 'w' while this is definetely not the case with fixedsys.

[edited by - Tree Penguin on April 10, 2004 7:48:36 PM]

Share this post


Link to post
Share on other sites
if I type in individual characters, it ends up just fine.
But its when I do a string, then it starts to become uneven.

I guess I need to find a way to get the distance between characters.

Any Ideas?

Share this post


Link to post
Share on other sites
I thought the bitmap fonts used either rasterpos (if that translates, not sets the position, i don''t know) or glTranslateX to position the characters, how about using the matrix to find out how much a certain character translates after it has been drawn?

WWW.TREEPENGUIN.TK

Share this post


Link to post
Share on other sites
I did this in my initilize function:

for(int i=0; i < 255; i++)
{
SIZE s;
char line[2] = { (char)i, 0 };
GetTextExtentPoint(hDC, line, 1, &s);
cwidth = s.cx;
}

where cwidth is an array of short


Thanks for your help

Share this post


Link to post
Share on other sites
I think you are mixing OpenGL and Windows GDI. The function GetTextExtentPoint is for Windows GDI. There is another function for OpenGL, but I am an home so I don''t have any reference to what I used in my bitmap classes.



- onebeer

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!