1 #include <windows.h>
WndProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)2 LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam,
3 			  LPARAM lParam)
4 {
5   char *cr = "I don't know any magic.";
6 
7   HDC hdc;
8   PAINTSTRUCT ps;
9   RECT rect;
10 
11   LOGFONT lf = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "" };
12   HFONT hfont_small = NULL;
13   lf.lfWidth = 0;
14   lf.lfHeight = 18;
15   lf.lfWeight = 600;
16   strcpy (lf.lfFaceName, "Arial");
17   hfont_small = CreateFontIndirect (&lf);
18 
19   switch (iMsg)
20     {
21     case WM_PAINT:
22       hdc = BeginPaint (hwnd, &ps);
23       GetClientRect (hwnd, &rect);
24 
25       SetBkMode (hdc, TRANSPARENT);
26       SetTextColor (hdc, RGB (255, 0, 0));
27       /* Default font - vgasys.fon */
28       DrawText (hdc, "Map # 3, (C)opy or (S)tamp tile", 31, &rect, DT_CENTER | DT_WORDBREAK);
29 
30       OffsetRect (&rect, 0, 30);
31 
32       /* Switch to arial */
33       SelectObject (hdc, hfont_small);
34 
35       /* Draw text "borders" */
36       SetTextColor (hdc, RGB (8, 14, 21));
37       DrawText (hdc, cr, strlen (cr), &rect, DT_CENTER | DT_WORDBREAK);
38       OffsetRect (&rect, -2, 0);
39       DrawText (hdc, cr, strlen (cr), &rect, DT_CENTER | DT_WORDBREAK);
40       OffsetRect (&rect, 1, 1);
41       DrawText (hdc, cr, strlen (cr), &rect, DT_CENTER | DT_WORDBREAK);
42       OffsetRect (&rect, 0, -2);
43       DrawText (hdc, cr, strlen (cr), &rect, DT_CENTER | DT_WORDBREAK);
44       OffsetRect (&rect, 0, 1);
45 
46       /* Draw text */
47       SetTextColor (hdc, RGB (255, 255, 2));
48       DrawText (hdc, cr, strlen (cr), &rect, DT_CENTER | DT_WORDBREAK);
49       /* Emulate bold (bad kerning/spacing though): */
50       /* OffsetRect (&rect, 1, 0); */
51       /* DrawText (hdc, cr, strlen (cr), &rect, DT_CENTER | DT_WORDBREAK); */
52       /* OffsetRect (&rect, -1, 0); */
53 
54       OffsetRect (&rect, 0, 30);
55       SetTextColor (hdc, RGB (255, 255, 255));
56       DrawText (hdc, cr, strlen (cr), &rect, DT_CENTER | DT_WORDBREAK);
57 
58       EndPaint (hwnd, &ps);
59       return 0;
60 
61     case WM_DESTROY:
62       PostQuitMessage (0);
63       return 0;
64     }
65   return DefWindowProc (hwnd, iMsg, wParam, lParam);
66 }
67 
68 int WINAPI
WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)69 WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,
70 	 int iCmdShow)
71 {
72   HWND hwnd;
73   MSG msg;
74   WNDCLASSEX wndclass;
75   memset(&wndclass, 0, sizeof (wndclass));
76   wndclass.cbSize = sizeof (wndclass);
77   wndclass.lpfnWndProc = WndProc;
78   wndclass.lpszClassName = "font";
79   wndclass.hbrBackground = (HBRUSH) GetStockObject (GRAY_BRUSH);
80 
81   RegisterClassEx (&wndclass);
82   hwnd =
83     CreateWindow ("font", "FreeDink font simulation", WS_OVERLAPPEDWINDOW,
84 		  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
85 		  CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
86   ShowWindow (hwnd, iCmdShow);
87   UpdateWindow (hwnd);
88 
89   while (GetMessage (&msg, NULL, 0, 0))
90     {
91       TranslateMessage (&msg);
92       DispatchMessage (&msg);
93     }
94 
95   return msg.wParam;
96 }
97 
98 /**
99  * Local Variables:
100  * compile-command: "i586-mingw32msvc-gcc woefont.c -lgdi32"
101  * End:
102  */
103