-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcefonts.c
124 lines (103 loc) · 3.24 KB
/
cefonts.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// cefonts.c
//
// Time-stamp: <03/01/02 22:24:35 [email protected]>
#include "celib.h"
#if UNDER_CE <= 201
#include <malloc.h>
#endif
HFONT XCEAPI
XCECreateFontIndirectA(CONST LOGFONTA *lplf)
{
LOGFONTW lfw;
HFONT hFont;
lfw.lfHeight = lplf->lfHeight;
lfw.lfWidth = lplf->lfWidth;
lfw.lfEscapement = lplf->lfEscapement;
lfw.lfOrientation = lplf->lfOrientation;
lfw.lfWeight = lplf->lfWeight;
lfw.lfItalic = lplf->lfItalic;
lfw.lfUnderline = lplf->lfUnderline;
lfw.lfStrikeOut = lplf->lfStrikeOut;
lfw.lfCharSet = lplf->lfCharSet;
lfw.lfOutPrecision = lplf->lfOutPrecision;
lfw.lfClipPrecision = lplf->lfClipPrecision;
lfw.lfQuality = lplf->lfQuality;
lfw.lfPitchAndFamily = lplf->lfPitchAndFamily;
MultiByteToWideChar(CP_ACP, 0,
lplf->lfFaceName, -1,
lfw.lfFaceName, COUNTOF(lfw.lfFaceName));
hFont = CreateFontIndirectW(&lfw);
return hFont;
}
typedef struct _MyEnumFontFamArg
{
FONTENUMPROC fn;
LPARAM lParam;
} MYENUMFONTFAMARG;
int CALLBACK
MyEnumFontFamProc(ENUMLOGFONT *lpelf, NEWTEXTMETRIC *lpntm,
int fonttype, LPARAM lParam)
{
MYENUMFONTFAMARG *parg = (MYENUMFONTFAMARG *) lParam;
FONTENUMPROC fn = parg->fn;
ENUMLOGFONT elfa;
NEWTEXTMETRICA tma;
LOGFONTA *plfa;
LOGFONTW *plfw;
plfa = &elfa.elfLogFont;
plfw = &lpelf->elfLogFont;
memcpy(plfa, plfw, sizeof(LOGFONTA));
WideCharToMultiByte(CP_ACP, 0,
plfw->lfFaceName, -1,
plfa->lfFaceName,
LF_FACESIZE,
NULL, NULL);
WideCharToMultiByte(CP_ACP, 0,
lpelf->elfFullName, -1,
elfa.elfFullName,
LF_FULLFACESIZE,
NULL, NULL);
WideCharToMultiByte(CP_ACP, 0,
lpelf->elfStyle, -1,
elfa.elfStyle,
LF_FACESIZE,
NULL, NULL);
tma.tmHeight = lpntm->tmHeight;
tma.tmAscent = lpntm->tmAscent;
tma.tmDescent = lpntm->tmDescent;
tma.tmInternalLeading = lpntm->tmInternalLeading;
tma.tmExternalLeading = lpntm->tmExternalLeading;
tma.tmAveCharWidth = lpntm->tmAveCharWidth;
tma.tmMaxCharWidth = lpntm->tmMaxCharWidth;
tma.tmWeight = lpntm->tmWeight;
tma.tmOverhang = lpntm->tmOverhang;
tma.tmDigitizedAspectX = lpntm->tmDigitizedAspectX;
tma.tmDigitizedAspectY = lpntm->tmDigitizedAspectY;
tma.tmFirstChar = lpntm->tmFirstChar;
tma.tmLastChar = lpntm->tmLastChar;
tma.tmDefaultChar = lpntm->tmDefaultChar;
tma.tmBreakChar = lpntm->tmBreakChar;
tma.tmItalic = lpntm->tmItalic;
tma.tmUnderlined = lpntm->tmUnderlined;
tma.tmStruckOut = lpntm->tmStruckOut;
tma.tmPitchAndFamily = lpntm->tmPitchAndFamily;
tma.tmCharSet = lpntm->tmCharSet;
return (*fn)(&elfa, &tma, fonttype, parg->lParam);
}
int XCEAPI
XCEEnumFontFamilies(HDC hdc, LPCSTR lpszFamily,
FONTENUMPROC lpEnumFontFamProc, LPARAM lParam)
{
MYENUMFONTFAMARG arg;
wchar_t *lpszFamilyW = NULL;
if(lpszFamily != NULL)
{
int len = strlen(lpszFamily);
lpszFamilyW = alloca(len + 1);
MultiByteToWideChar(CP_ACP, 0, lpszFamily, len, lpszFamilyW, len);
}
arg.fn = lpEnumFontFamProc;
arg.lParam = lParam;
return EnumFontFamiliesW(hdc, lpszFamilyW, (FONTENUMPROC) MyEnumFontFamProc,
(LPARAM) &arg);
}