ReactOS 0.4.15-dev-7924-g5949c20
bootvid_font_generator.c File Reference
#include <stdio.h>
#include <conio.h>
#include <windows.h>
Include dependency graph for bootvid_font_generator.c:

Go to the source code of this file.

Macros

#define FONT_NAME_DEF   "Lucida Console"
 
#define FONT_SIZE_DEF   10
 
#define X_OFFSET_DEF   0
 
#define Y_OFFSET_DEF   0
 
#define HEIGHT   13
 
#define WIDTH   8
 

Functions

static void DumpCharacterFontData (DWORD BmpBits[])
 
static BOOL PlotCharacter (HDC hDC, HFONT hFont, INT XOffset, INT YOffset, CHAR Character, DWORD BmpBits[])
 
static void DumpFont (LPSTR FontName, INT FontSize, INT XOffset, INT YOffset)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ FONT_NAME_DEF

#define FONT_NAME_DEF   "Lucida Console"

Definition at line 18 of file bootvid_font_generator.c.

◆ FONT_SIZE_DEF

#define FONT_SIZE_DEF   10

Definition at line 19 of file bootvid_font_generator.c.

◆ HEIGHT

#define HEIGHT   13

Definition at line 23 of file bootvid_font_generator.c.

◆ WIDTH

#define WIDTH   8

Definition at line 24 of file bootvid_font_generator.c.

◆ X_OFFSET_DEF

#define X_OFFSET_DEF   0

Definition at line 20 of file bootvid_font_generator.c.

◆ Y_OFFSET_DEF

#define Y_OFFSET_DEF   0

Definition at line 21 of file bootvid_font_generator.c.

Function Documentation

◆ DumpCharacterFontData()

static void DumpCharacterFontData ( DWORD  BmpBits[])
static

Dump the FontData for the bootvid/i386/bootdata.c array.

Definition at line 54 of file bootvid_font_generator.c.

55{
56 static int iBegin = 0;
57 int i;
58
59 fprintf(stdout, " ");
60
61 for (i = 0; i < HEIGHT; i++)
62 fprintf(stdout, "0x%02lX, ", BmpBits[i]);
63
64 fprintf(stdout, " // %d\n", iBegin);
65 iBegin += HEIGHT;
66}
#define HEIGHT
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define stdout
Definition: stdio.h:99
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)

Referenced by DumpFont().

◆ DumpFont()

static void DumpFont ( LPSTR  FontName,
INT  FontSize,
INT  XOffset,
INT  YOffset 
)
static

Definition at line 124 of file bootvid_font_generator.c.

125{
126 int iHeight;
127 HDC hDC = NULL;
128 HFONT hFont = NULL;
129
130 DWORD BmpBits[HEIGHT];
131 USHORT c;
132
134 if (!hDC)
135 {
136 fprintf(stderr, "CreateCompatibleDC failed with error %lu!\n", GetLastError());
137 goto Cleanup;
138 }
139
140 iHeight = -MulDiv(FontSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
141 hFont = CreateFontA(iHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
144 if (!hFont)
145 {
146 fprintf(stderr, "CreateFont failed with error %lu!\n", GetLastError());
147 goto Cleanup;
148 }
149
150 for (c = 0; c < 256; c++)
151 {
152 PlotCharacter(hDC, hFont, XOffset, YOffset, (CHAR)c, BmpBits);
153
154#ifdef DUMP_CHAR_ON_SCREEN
155 DumpCharacterOnScreen(BmpBits);
156 fprintf(stdout, "\nPress any key to continue...\n");
157 _getch();
158 system("cls");
159#else
160 DumpCharacterFontData(BmpBits);
161#endif
162 }
163
164Cleanup:
165 if (hFont)
167
168 if (hDC)
169 DeleteDC(hDC);
170}
static HDC hDC
Definition: 3dtext.c:33
HFONT hFont
Definition: main.c:53
static void DumpCharacterFontData(DWORD BmpBits[])
static BOOL PlotCharacter(HDC hDC, HFONT hFont, INT XOffset, INT YOffset, CHAR Character, DWORD BmpBits[])
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
const GLubyte * c
Definition: glext.h:8905
#define stderr
Definition: stdio.h:100
#define c
Definition: ke_i.h:80
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
unsigned short USHORT
Definition: pedump.c:61
int __cdecl system(_In_opt_z_ const char *_Command)
int _getch()
Definition: getch.c:16
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FIXED_PITCH
Definition: wingdi.h:444
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define ANSI_CHARSET
Definition: wingdi.h:383
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define FW_NORMAL
Definition: wingdi.h:373
HFONT WINAPI CreateFontA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR)
BOOL WINAPI DeleteDC(_In_ HDC)
#define NONANTIALIASED_QUALITY
Definition: wingdi.h:439
char CHAR
Definition: xmlstorage.h:175

Referenced by main().

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 172 of file bootvid_font_generator.c.

173{
174 /* Validate the arguments */
175 if (argc > 5 || (argc >= 2 && strncmp(argv[1], "/?", 2) == 0))
176 {
178 "Usage: %s \"font name\" [font size] [X-offset] [Y-offset]\n"
179 "Default font name is: \"%s\"\n"
180 "Default font size is: %i\n"
181 "Default X-offset is: %i\n"
182 "Default Y-offset is: %i\n",
183 argv[0],
185
186 return -1;
187 }
188
189 DumpFont((argc <= 1) ? FONT_NAME_DEF : argv[1],
190 (argc <= 2) ? FONT_SIZE_DEF : atoi(argv[2]),
191 (argc <= 3) ? X_OFFSET_DEF : atoi(argv[3]),
192 (argc <= 4) ? Y_OFFSET_DEF : atoi(argv[4]));
193 return 0;
194}
static int argc
Definition: ServiceArgs.c:12
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static void DumpFont(LPSTR FontName, INT FontSize, INT XOffset, INT YOffset)
#define X_OFFSET_DEF
#define FONT_NAME_DEF
#define FONT_SIZE_DEF
#define Y_OFFSET_DEF
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define argv
Definition: mplay32.c:18

◆ PlotCharacter()

static BOOL PlotCharacter ( HDC  hDC,
HFONT  hFont,
INT  XOffset,
INT  YOffset,
CHAR  Character,
DWORD  BmpBits[] 
)
static

Use GDI APIs to load a monospace font and plot a single character into a bitmap.

Definition at line 72 of file bootvid_font_generator.c.

73{
74 BOOL bReturnValue = FALSE;
75 HBITMAP hOldBmp;
76 HFONT hOldFont;
77 HBITMAP hBmp = NULL;
78 BYTE BmpInfo[sizeof(BITMAPINFO) + sizeof(RGBQUAD)];
79 PBITMAPINFO pBmpInfo = (PBITMAPINFO)&BmpInfo;
80
82 if (!hBmp)
83 {
84 fprintf(stderr, "CreateCompatibleBitmap failed with error %lu!\n", GetLastError());
85 goto Cleanup;
86 }
87
88 hOldBmp = SelectObject(hDC, hBmp);
89 hOldFont = SelectObject(hDC, hFont);
90 SetBkColor(hDC, RGB(0, 0, 0));
91 SetTextColor(hDC, RGB(255, 255, 255));
92 TextOutA(hDC, XOffset, YOffset, &Character, 1);
93
94 /*
95 * Use enough memory for BITMAPINFO and one additional color in the color table.
96 * BITMAPINFO already contains a color table entry for a single color and
97 * GetDIBits needs space for two colors (black and white).
98 */
99 ZeroMemory(&BmpInfo, sizeof(BmpInfo));
100 pBmpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
101 pBmpInfo->bmiHeader.biHeight = -HEIGHT;
102 pBmpInfo->bmiHeader.biWidth = WIDTH;
103 pBmpInfo->bmiHeader.biBitCount = 1;
104 pBmpInfo->bmiHeader.biPlanes = 1;
105
106 bReturnValue = TRUE;
107
108 if (!GetDIBits(hDC, hBmp, 0, HEIGHT, BmpBits, pBmpInfo, 0))
109 {
110 fprintf(stderr, "GetDIBits failed with error %lu!\n", GetLastError());
111 bReturnValue = FALSE;
112 }
113
114 SelectObject(hDC, hOldBmp);
115 SelectObject(hDC, hOldFont);
116
117Cleanup:
118 if (hBmp)
119 DeleteObject(hBmp);
120
121 return bReturnValue;
122}
#define WIDTH
#define TRUE
Definition: types.h:120
#define RGB(r, g, b)
Definition: precomp.h:71
ULONG RGBQUAD
Definition: precomp.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
static HBITMAP
Definition: button.c:44
USHORT biBitCount
Definition: precomp.h:46
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
#define ZeroMemory
Definition: winbase.h:1712
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
BOOL WINAPI TextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCSTR lpString, _In_ int c)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
struct tagBITMAPINFO BITMAPINFO
struct tagBITMAPINFO * PBITMAPINFO
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DumpFont().