tags:

views:

988

answers:

1

I have a LOGFONT.lfHeight value of -11. However, I know that the font size is actually 8 so do I need to convert this number to a different unit of measurement? I found this formula in the MSDN docs:

int height = abs((pixels * DOTSY) / 72);

This takes pixels and makes it into a height value that LOGFONT can use. If I work this the other way:

int pixels = abs((height / DOTSY) * 72);

This gives me a value of 8.24. Am I correct in assuming this is all I need to do to convert the font height into a usable value?

+4  A: 

Yes. DOTSY will be 96, which is the default monitor resolution in DPI in Windows. You will need to ensure that this value is correct for the device you're writing to - printers will usually have a much higher resolution, and the monitor resolution can be changed. lfHeight is negative to indicate that the font mapper should use character height instead of cell height to match, so only the absolute value is important here.

Stu Mackellar
Excellent - thanks. I will be testing on various DPI settings to make sure this works correctly. :)
Jon Tackabury