Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
65 lines (52 loc) · 1.72 KB

File metadata and controls

65 lines (52 loc) · 1.72 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
//-----------------------------------------------------------------------------
// Entry point into the program.
//-----------------------------------------------------------------------------
int main(int argc, char** argv)
{
if(argc != 2) {
fprintf(stderr, "usage: ttf2c [output]");
return 1;
}
InitCommonControls();
// A monospaced font
HFONT font = CreateFont(16, 9, 0, 0, FW_REGULAR, false,
false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console");
HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
HBITMAP bitmap = CreateCompatibleBitmap(hdc, 30, 30);
SelectObject(hdc, bitmap);
SelectObject(hdc, font);
FILE* out = fopen(argv[1], "w");
if(!out) {
fprintf(stderr, "cannot open output file %s", argv[1]);
return 1;
}
fprintf(out, "static const uint8_t FontTexture[256*16*16] = {\n");
int c;
for(c = 0; c < 128; c++) {
RECT r;
r.left = 0; r.top = 0;
r.right = 30; r.bottom = 30;
FillRect(hdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH));
SetBkColor(hdc, RGB(0, 0, 0));
SetTextColor(hdc, RGB(255, 255, 255));
char str[2] = { c, 0 };
TextOut(hdc, 0, 0, str, 1);
int i, j;
for(i = 0; i < 16; i++) {
for(j = 0; j < 16; j++) {
COLORREF c = GetPixel(hdc, i, j);
fprintf(out, "%3d, ", c ? 255 : 0);
}
fprintf(out, "\n");
}
fprintf(out, "\n");
}
fprintf(out, "#include \"bitmapextra.table.h\"\n");
fprintf(out, "};\n");
fclose(out);
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.