Discussion:
How to get Font Size if I know the LOGFONT structure?
(too old to reply)
Alejandro Nadal
2022-10-21 10:23:44 UTC
Permalink
23 years later, thanks for this info :) . I hope you are still there.
I believe this is a simple question,
but I just can't find the answer.
Thank you in advance.
Yong Wang
What size do you want ?
Points ? Pixels ? Millimetres ?
Vertical Height ? Horizontal Width ?
structure member "lfHeight"
Specifies the height, in logical units, of the font's character cell
or character. The character height value (also known as the em height)
is the character cell height value minus the internal-leading value.
The font mapper interprets the value specified in lfHeight in the
following manner.
The font mapper transforms this value into device units and matches it
against the cell height of the available fonts.
The font mapper uses a default height value when it searches for a
match.
The font mapper transforms this value into device units and matches
its absolute value against the character height of the available
fonts.
For all height comparisons, the font mapper looks for the largest font
that does not exceed the requested size.
This mapping occurs when the font is used for the first time.
For the MM_TEXT mapping mode, you can use the following formula to
lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
Hope this helps,
Jim M
--
@ Derbyshire
JiiPee
2022-10-22 05:49:03 UTC
Permalink
23 years later, thanks for this info 😄 . I hope you are still there.
did it solve the problem? :)
vinod kc
2022-12-04 22:37:07 UTC
Permalink
Post by JiiPee
23 years later, thanks for this info 😄 . I hope you are still there.
did it solve the problem? :)
I think I am using this formula from 2019 in my own gui library, but today I noticed that there is a minus sign on the left of MulDiv function. So I was passing a positive number to my LOGFONT struct and now I realized. And voilà !! Suddenly my apps are showing a different text size after I added the minus sign.
JiiPee
2022-12-05 15:42:35 UTC
Permalink
Post by vinod kc
Post by JiiPee
23 years later, thanks for this info 😄 . I hope you are still there.
did it solve the problem? :)
I think I am using this formula from 2019 in my own gui library, but today I noticed that there is a minus sign on the left of MulDiv function. So I was passing a positive number to my LOGFONT struct and now I realized. And voilà !! Suddenly my apps are showing a different text size after I added the minus sign.
ye I also noted the minus. the documentation explains its purpose
Loading...