2010-04-26 07:52:49 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Entry point into the program.
|
|
|
|
//-----------------------------------------------------------------------------
|
2015-03-29 00:33:46 +00:00
|
|
|
int main(int argc, char** argv)
|
2010-04-26 07:52:49 +00:00
|
|
|
{
|
2015-03-29 00:33:46 +00:00
|
|
|
if(argc != 2) {
|
|
|
|
fprintf(stderr, "usage: ttf2c [output]");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
InitCommonControls();
|
|
|
|
|
|
|
|
// A monospaced font
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
HFONT font = CreateFont(16, 9, 0, 0, FW_REGULAR, false,
|
|
|
|
false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
2010-04-26 07:52:49 +00:00
|
|
|
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);
|
|
|
|
|
2015-03-29 00:33:46 +00:00
|
|
|
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");
|
2010-04-26 07:52:49 +00:00
|
|
|
|
|
|
|
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);
|
2015-03-29 00:33:46 +00:00
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
int i, j;
|
|
|
|
for(i = 0; i < 16; i++) {
|
|
|
|
for(j = 0; j < 16; j++) {
|
|
|
|
COLORREF c = GetPixel(hdc, i, j);
|
2015-03-29 00:33:46 +00:00
|
|
|
fprintf(out, "%3d, ", c ? 255 : 0);
|
2010-04-26 07:52:49 +00:00
|
|
|
}
|
2015-03-29 00:33:46 +00:00
|
|
|
fprintf(out, "\n");
|
2010-04-26 07:52:49 +00:00
|
|
|
}
|
2015-03-29 00:33:46 +00:00
|
|
|
fprintf(out, "\n");
|
2010-04-26 07:52:49 +00:00
|
|
|
}
|
2015-03-29 00:33:46 +00:00
|
|
|
fprintf(out, "#include \"bitmapextra.table.h\"\n");
|
|
|
|
fprintf(out, "};\n");
|
|
|
|
|
|
|
|
fclose(out);
|
2010-04-26 07:52:49 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|