Jump to content
  • Advertisement

Archived

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

Craazer

How GetCharWidth works?

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

Hi I understand if dont like questons like this but I have read the docs and it says width returned is in logical coordinates. So I asume they must be converted to "pixels" but how? Could this be done whit GetDeviceCaps() ?

Share this post


Link to post
Share on other sites
Advertisement
That returns the average width but i need width of each character. Example a has difrend width than i. Thanks though!

also note that even I would use GetTextExtentPoint32 for single chars I would still have to convert logical units. Right?

Share this post


Link to post
Share on other sites
In my experience it doesn''t. (work, that is)
Check out my previous experience:
[url]http://www.gamedev.net/community/forums/topic.asp?topic_id=165540[/url]

Share this post


Link to post
Share on other sites
quote:
Original post by Sailorstick
In my experience it doesn't. (work, that is)
Check out my previous experience:
[url]http://www.gamedev.net/community/forums/topic.asp?topic_id=165540[/url]



What windows you got?
I have 98 SE and GetCharWidth32() doesnt work in that so Im using GetCharWidth() wich works and returns somehow sensible values... So now they should be converted...

The main queston isnt yet answerd, what is logical width? And how to convert?


[edited by - Craazer on May 9, 2004 12:33:51 PM]

Share this post


Link to post
Share on other sites
So far no good. However this is how I understand the conversion should work from the docs:


SIZE wext,vext;
GetWindowExtEx(mhdc,&wext);
GetViewportExtEx(mhdc,&vext);
for(int x = 0; x < NUM_CHARS;x++)
{
// cwidths are gained by GetCharWidth()

pcharwidths[x] = (MulDiv(cwidths[x],vext.cx,wext.cx));
}


So "quess" what, that doesnt work.
The window and viewport x's are both 1, wich I know nothing about, but character widths are still too short or unaccurate.

[edited by - Craazer on May 9, 2004 2:25:46 PM]

Share this post


Link to post
Share on other sites
Got it working!!!

I had forgot to select the font object before using GetCharWidth!

Man im so happy for being so stupid sometimes...

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!