MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / ProcessFont

Function ProcessFont

GTE/Tools/BitmapFontCreator/BitmapFontCreator.cpp:214–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214static void ProcessFont(HWND hWnd, std::wstring const& fontName, int weight,
215 int size, DWORD italic)
216{
217 HDC hDC = GetDC(hWnd);
218 SetTextColor(hDC, RGB(0, 0, 0));
219 SetBkColor(hDC, RGB(255, 255, 255));
220
221 // Create the font.
222 HFONT hFont = CreateFont(size, 0, 0, 0, weight, italic, FALSE, FALSE,
223 DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
224 ANTIALIASED_QUALITY, VARIABLE_PITCH, fontName.c_str());
225
226 HGDIOBJ oldFont = SelectObject(hDC, hFont);
227
228 RECT r{};
229 r.left = r.top = 0;
230 r.right = gWindowWidth - 1;
231 r.bottom = gWindowHeight - 1;
232 FillRect(hDC, &r, static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)));
233 wchar_t msg[256];
234 wsprintf(msg, L"Rendering %s, weight = %d, size = %d, italics = %d",
235 fontName.c_str(), weight, size, italic);
236 TextOut(hDC, 8, 3 * size, msg, static_cast<int>(wcslen(msg)));
237
238 int width{}, height{};
239 std::vector<unsigned char> texels{};
240 float characterData[257];
241 CreateFontData(hDC, width, height, texels, characterData);
242 CreateHeaderFile(fontName, weight, size, italic);
243 CreateSourceFile(fontName, weight, size, italic, width, height, texels, characterData);
244 SelectObject(hDC, oldFont);
245 DeleteObject(hFont);
246 ReleaseDC(hWnd, hDC);
247}
248
249int wmain()
250{

Callers 1

wmainFunction · 0.85

Calls 3

CreateFontDataFunction · 0.85
CreateHeaderFileFunction · 0.85
CreateSourceFileFunction · 0.85

Tested by

no test coverage detected