15#include "IGraphicsPrivate.h"
18BEGIN_IGRAPHICS_NAMESPACE
26 : mFontHandle(
nullptr)
31 mFontHandle = AddFontMemResourceEx(data, resSize, NULL, &numFonts);
38 RemoveFontMemResourceEx(mFontHandle);
44 bool IsValid()
const {
return mFontHandle; }
54 LOGFONTW lFont = { 0 };
55 GetObjectW(hfont,
sizeof(LOGFONTW), &lFont);
56 mHFont = CreateFontIndirectW(&lFont);
62class WinFont :
public PlatformFont
65 WinFont(HFONT font,
const char* styleName,
bool system)
66 : PlatformFont(system), mFont(font), mStyleName(styleName) {}
72 FontDescriptor GetDescriptor()
override {
return mFont; }
74 IFontDataPtr GetFontData()
override
76 HDC hdc = CreateCompatibleDC(NULL);
77 IFontDataPtr fontData(
new IFontData());
81 SelectObject(hdc, mFont);
82 const size_t size = ::GetFontData(hdc, 0, 0, NULL, 0);
84 if (size != GDI_ERROR)
86 fontData = std::make_unique<IFontData>(size);
88 if (fontData->GetSize() == size)
90 size_t result = ::GetFontData(hdc, 0x66637474, 0, fontData->Get(), size);
91 if (result == GDI_ERROR)
92 result = ::GetFontData(hdc, 0, 0, fontData->Get(), size);
94 fontData->SetFaceIdx(GetFaceIdx(fontData->Get(), fontData->GetSize(), mStyleName.Get()));
106 WDL_String mStyleName;
109END_IGRAPHICS_NAMESPACE