[CONSOLE][CONCFG][CONSRV] Provide support for specified additional TrueType fonts...
[reactos.git] / win32ss / user / winsrv / concfg / font.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/winsrv/concfg/font.h
5 * PURPOSE: Console Fonts Management
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
8 */
9
10 #pragma once
11
12 /* DEFINES ********************************************************************/
13
14 #define INVALID_CP ((UINT)-1)
15
16 #define CP_SHIFTJIS 932 // Japanese Shift-JIS
17 #define CP_HANGUL 949 // Korean Hangul/Wansung
18 #define CP_JOHAB 1361 // Korean Johab
19 #define CP_GB2312 936 // Chinese Simplified (GB2312)
20 #define CP_BIG5 950 // Chinese Traditional (Big5)
21
22 /* IsFarEastCP(CodePage) */
23 #define IsCJKCodePage(CodePage) \
24 ((CodePage) == CP_SHIFTJIS || (CodePage) == CP_HANGUL || \
25 /* (CodePage) == CP_JOHAB || */ \
26 (CodePage) == CP_BIG5 || (CodePage) == CP_GB2312)
27
28 #if !defined(_WINGDI_) || defined(NOGDI)
29 #define SHIFTJIS_CHARSET 128
30 #define HANGEUL_CHARSET 129
31 #define HANGUL_CHARSET 129 // HANGEUL_CHARSET
32 #if(WINVER >= 0x0400)
33 #define JOHAB_CHARSET 130
34 #endif /* WINVER */
35 #define GB2312_CHARSET 134
36 #define CHINESEBIG5_CHARSET 136
37 #endif /* !defined(_WINGDI_) || defined(NOGDI) */
38
39 /* IsAnyDBCSCharSet(CharSet) */
40 #define IsCJKCharSet(CharSet) \
41 ((CharSet) == SHIFTJIS_CHARSET || (CharSet) == HANGUL_CHARSET || \
42 /* (CharSet) == JOHAB_CHARSET || */ \
43 (CharSet) == GB2312_CHARSET || (CharSet) == CHINESEBIG5_CHARSET)
44
45 #define IsBoldFont(Weight) \
46 ((Weight) >= FW_SEMIBOLD) /* Sometimes, just > FW_MEDIUM */
47
48 typedef struct _TT_FONT_ENTRY
49 {
50 LIST_ENTRY Entry;
51 UINT CodePage;
52 BOOL DisableBold;
53 WCHAR FaceName[LF_FACESIZE];
54 WCHAR FaceNameAlt[LF_FACESIZE];
55 } TT_FONT_ENTRY, *PTT_FONT_ENTRY;
56
57
58 /* FUNCTIONS ******************************************************************/
59
60 BYTE
61 CodePageToCharSet(
62 IN UINT CodePage);
63
64 HFONT
65 CreateConsoleFontEx(
66 IN LONG Height,
67 IN LONG Width OPTIONAL,
68 IN OUT LPWSTR FaceName, // Points to a WCHAR array of LF_FACESIZE elements
69 IN ULONG FontFamily,
70 IN ULONG FontWeight,
71 IN UINT CodePage);
72
73 HFONT
74 CreateConsoleFont2(
75 IN LONG Height,
76 IN LONG Width OPTIONAL,
77 IN OUT PCONSOLE_STATE_INFO ConsoleInfo);
78
79 HFONT
80 CreateConsoleFont(
81 IN OUT PCONSOLE_STATE_INFO ConsoleInfo);
82
83 BOOL
84 GetFontCellSize(
85 IN HDC hDC OPTIONAL,
86 IN HFONT hFont,
87 OUT PUINT Height,
88 OUT PUINT Width);
89
90 BOOL
91 IsValidConsoleFont2(
92 IN PLOGFONTW lplf,
93 IN PNEWTEXTMETRICW lpntm,
94 IN DWORD FontType,
95 IN UINT CodePage);
96
97 BOOL
98 IsValidConsoleFont(
99 IN LPCWSTR FaceName,
100 IN UINT CodePage);
101
102 /*
103 * To install additional TrueType fonts to be available for the console,
104 * add entries of type REG_SZ named "0", "00" etc... in:
105 * HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
106 * The names of the fonts listed there should match those in:
107 * HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Fonts
108 *
109 * This function initializes the cache of the fonts listed there.
110 */
111 VOID
112 InitTTFontCache(VOID);
113
114 VOID
115 ClearTTFontCache(VOID);
116
117 VOID
118 RefreshTTFontCache(VOID);
119
120 PTT_FONT_ENTRY
121 FindCachedTTFont(
122 IN LPCWSTR FaceName,
123 IN UINT CodePage);
124
125 #define IsAdditionalTTFont(FaceName) \
126 (FindCachedTTFont((FaceName), INVALID_CP) != NULL)
127
128 #define IsAdditionalTTFontCP(FaceName, CodePage) \
129 (FindCachedTTFont((FaceName), (CodePage)) != NULL)
130
131 /* EOF */