192 bool fSuccess =
false;
193 HDC hDC = ::CreateCompatibleDC(
nullptr);
196 HFONT hFont = ::CreateFontA(0, 0, 0, 0, FW_DONTCARE,
false,
197 false,
false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
198 CLIP_DEFAULT_PRECIS, 5,
199 VARIABLE_PITCH, FontFaceName);
202 SelectObject( hDC, hFont );
203 uint32_t dwTTFSize = ::GetFontData(hDC, 0, 0,
nullptr, 0);
204 if (dwTTFSize && dwTTFSize != GDI_ERROR)
207 uint32_t dwRealTTFSize = ::GetFontData(hDC, 0, 0, Data.
getMData(), dwTTFSize);
208 if (dwRealTTFSize == dwTTFSize)
220 throw std::runtime_error(
"Some Win32 error");
222 if (FT_Init_FreeType(&library))
223 throw std::runtime_error(
"Cannot init Freetype");
226 if ((e=FT_New_Memory_Face(library,
static_cast<const FT_Byte *
>(Data.
getData()), Data.
getSize(), 0, &face)))
227 throw std::runtime_error(std::string(
"Cannot load font: ") +
FormatString(
"%d",e).getData());
231 if (FT_Init_FreeType(&library))
232 throw std::runtime_error(
"Cannot init Freetype");
235 if ((e=FT_New_Face(library, FontFaceName, 0, &face)))
236 throw std::runtime_error(std::string(
"Cannot load ") + FontFaceName +
": " +
FormatString(
"%d",e).getData());
StdStrBuf FormatString(const char *szFmt,...)
void SetSize(size_t inSize)
const void * getData() const