FontSize.cpp 879 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include "stdafx.h"
  2. #include "FontSize.h"
  3. /***************************************************************************************/
  4. // GetFontPointSize
  5. int GetFontPointSize(int iHeight)
  6. {
  7. HDC hDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
  8. ASSERT(hDC);
  9. int icyPixelsPerInch = GetDeviceCaps(hDC, LOGPIXELSY);
  10. DeleteDC(hDC);
  11. int iPointSize = MulDiv(iHeight, 72, icyPixelsPerInch);
  12. if(iPointSize < 0)
  13. {
  14. iPointSize = -iPointSize;
  15. }
  16. return iPointSize;
  17. }
  18. /***************************************************************************************/
  19. // GetFontHeight
  20. int GetFontHeight(int iPointSize)
  21. {
  22. HDC hDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
  23. ASSERT(hDC);
  24. int icyPixelsPerInch = GetDeviceCaps(hDC, LOGPIXELSY);
  25. DeleteDC(hDC);
  26. int iHeight = -MulDiv(iPointSize, icyPixelsPerInch, 72);
  27. return iHeight;
  28. }