#include "stdafx.h"
#include "FontSize.h"

/***************************************************************************************/
// GetFontPointSize
int GetFontPointSize(int iHeight)
{
    HDC hDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
    ASSERT(hDC);

    int icyPixelsPerInch = GetDeviceCaps(hDC, LOGPIXELSY);
    DeleteDC(hDC);

    int iPointSize = MulDiv(iHeight, 72, icyPixelsPerInch);
    if(iPointSize < 0)
    {
        iPointSize = -iPointSize;
    }

    return iPointSize;
}

/***************************************************************************************/
// GetFontHeight
int GetFontHeight(int iPointSize)
{
    HDC hDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
    ASSERT(hDC);

    int icyPixelsPerInch = GetDeviceCaps(hDC, LOGPIXELSY);
    DeleteDC(hDC);

    int iHeight = -MulDiv(iPointSize, icyPixelsPerInch, 72);

    return iHeight;
}