Files
Work/common/FONT.CPP
2024-08-07 09:09:36 -04:00

38 lines
932 B
C++

#include <common/font.hpp>
#include <common/purehdc.hpp>
Font &Font::operator=(const Font &someFont)
{
if(someFont.isOkay())
{
mPitchAndFamily=someFont.mPitchAndFamily;
mWeight=someFont.mWeight;
mFontStyle=someFont.mFontStyle;
mFontSize=someFont.mFontSize;
mCharSet=someFont.mCharSet;
createFont();
}
return *this;
}
void Font::createFont(void)
{
PureDevice screenDevice;
TEXTMETRIC tm;
int fontHeight;
destroyFont();
screenDevice.screenDevice();
fontHeight=::MulDiv(((short)mFontSize),::GetDeviceCaps(screenDevice,LOGPIXELSY),72);
mhFont=::CreateFont(fontHeight,0,0,0,mWeight,0,0,0,
mCharSet,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,mPitchAndFamily,mFontStyle.str());
screenDevice.select(mhFont);
::GetTextMetrics(screenDevice,&tm);
charHeight(tm.tmHeight+tm.tmExternalLeading);
pureHeight(tm.tmHeight);
avgCharWidth(tm.tmAveCharWidth);
maxCharWidth(tm.tmMaxCharWidth);
}