forked from nakkag/CLCL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFont.c
58 lines (50 loc) · 1.37 KB
/
Font.c
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
/*
* CLCL
*
* Font.c
*
* Copyright (C) 1996-2019 by Ohno Tomoaki. All rights reserved.
* https://www.nakka.com/
*/
/* Include Files */
#define _INC_OLE
#include <windows.h>
#undef _INC_OLE
/* Define */
/* Global Variables */
/* Local Function Prototypes */
/*
* font_create - ƒtƒHƒ“ƒg‚ð쬂·‚é
*/
HFONT font_create(const TCHAR *FontName, const int FontSize, const int Charset, const int weight, const BOOL italic, const BOOL fixed)
{
LOGFONT lf;
HDC hdc;
ZeroMemory(&lf, sizeof(LOGFONT));
hdc = GetDC(NULL);
lf.lfHeight = -(int)((FontSize * GetDeviceCaps(hdc, LOGPIXELSY)) / 72);
ReleaseDC(NULL, hdc);
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = weight;
lf.lfItalic = italic;
lf.lfUnderline = FALSE;
lf.lfStrikeOut = FALSE;
lf.lfCharSet = Charset;
lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = DEFAULT_QUALITY;
lf.lfPitchAndFamily = (BYTE)(((fixed == TRUE) ? FIXED_PITCH : DEFAULT_PITCH) | FF_DONTCARE);
if (*FontName == TEXT('\0')) {
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0);
lstrcpy(lf.lfFaceName, ncm.lfCaptionFont.lfFaceName);
} else {
lstrcpy(lf.lfFaceName, FontName);
}
return CreateFontIndirect((CONST LOGFONT *)&lf);
}
/* End of source */