// FontSize.cpp Version 1.0 // // Author: Hans Dietrich // hdietrich2@hotmail.com // // This software is released into the public domain. // You are free to use it in any way you like. // // This software is provided "as is" with no expressed // or implied warranty. I accept no liability for any // damage or loss of business that this software may cause. // /////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "FontSize.h" /////////////////////////////////////////////////////////////////////////////// // GetFontPointSize() int GetFontPointSize(int nHeight) { HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL); ASSERT(hdc); int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY); ::DeleteDC(hdc); int nPointSize = MulDiv(nHeight, 72, cyPixelsPerInch); if (nPointSize < 0) nPointSize = -nPointSize; return nPointSize; } /////////////////////////////////////////////////////////////////////////////// // GetFontHeight() int GetFontHeight(int nPointSize) { HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL); ASSERT(hdc); int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY); ::DeleteDC(hdc); int nHeight = -MulDiv(nPointSize, cyPixelsPerInch, 72); return nHeight; }