>>Hugo,
>>
>>Each fontface is going to behave differently. I don't understand the hangup about not wanting to loop through the possible font sizes calling fontmetric() till you find the best fit. It's not like fontmetric() takes a ton of time to execute.
>
>I know David it is not important, I will probably do an iteration, I just wanted to be sure there is no non-iterative way.
>I know David it is not important, I will probably do an iteration, I just wanted to be sure there is no non-iterative way.
Hugo,
I'm not quite sure there is a non-iterative way EXACTLY, because I didn't do any research on this.
But, if I looked from the formula at MSDN.
get the CellHeight:
CellHeight = (PointSize * VerticalResolution) / 72 + InternalLeading
and to get the PointSize:
PointSize = ((CellHeight - InternalLeading) * 72) / VerticalResolution
The things that missing is InternalLeading. You can't get the exact value until the font is exist and selected into DC. So you can only use a rough value or predefined value.
I believe you can learn it yourself :)
Here is the link:
Windows Font Mapping
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngdi/html/msdn_fontmap.aspRegards
Herman