I have a LOGFONT structure. Now all i’d like to do is get the associated font size in points from the LOGFONT height.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When the mapping mode is
mm_Text(which it usually is), and when thelfHeightfield is positive, it already gives the height in points. When it’s negative, the units are pixels. MSDN for LogFont gives you the formula to convert between them:There are 72 points per inch.
GetDeviceCapstells you the number of pixels per inch on a given device. Invert the formula to get pixels from points:The important thing to realize here is that you need a device context. Font sizes don’t exist independently of the media they appear on. The pixel height of a font on the screen will be different from the pixel height of a font on a printer. Use the
Handleproperty of whatever canvas you’re planning on drawing to.