3 #define MAX_FONT_SETTINGS 16
4 #define DEFINE_FS_MEMBER(name, param) \
5 int Get##name() const { return GetParam(param); } \
6 void Set##name(int n) { SetParam(param, n); }
11 int m_settings
[MAX_FONT_SETTINGS
];
12 static const char m_bound
[MAX_FONT_SETTINGS
][2];
14 enum _FontSettingsParams
{
17 FSP_NORMAL_WEIGHT
= 2,
29 DEFINE_FS_MEMBER(HintingMode
, FSP_HINTING
);
30 DEFINE_FS_MEMBER(AntiAliasMode
, FSP_AAMODE
);
31 DEFINE_FS_MEMBER(NormalWeight
, FSP_NORMAL_WEIGHT
);
32 DEFINE_FS_MEMBER(BoldWeight
, FSP_BOLD_WEIGHT
);
33 DEFINE_FS_MEMBER(ItalicSlant
, FSP_ITALIC_SLANT
);
34 DEFINE_FS_MEMBER(Kerning
, FSP_KERNING
);
36 int GetParam(int x
) const
38 Assert(0 <= x
&& x
< MAX_FONT_SETTINGS
);
41 void SetParam(int x
, int n
)
43 Assert(0 <= x
&& x
< MAX_FONT_SETTINGS
);
44 m_settings
[x
] = Bound
<int>(n
, m_bound
[x
][0], m_bound
[x
][1]);
48 ZeroMemory(m_settings
, sizeof(m_settings
));
51 void SetSettings(const int* p
, int count
)
53 count
= Min(count
, MAX_FONT_SETTINGS
);
54 memcpy(m_settings
, p
, count
* sizeof(int));
58 #undef DEFINE_FS_MEMBER
64 StringHashFont m_hash
;
70 CFontIndividual(LPCTSTR name
)
75 CFontSettings
& GetIndividual() { return m_set
; }
76 LPCTSTR
GetName() const { return m_hash
.c_str(); }
77 const StringHashFont
& GetHash() const { return m_hash
; }
78 bool operator ==(const CFontIndividual
& x
) const { return (m_hash
== x
.m_hash
); }
89 LPWSTR info
[INFOMAX
+ 1][2 * FONTMAX
+ 1];
91 CAtlMap
<CString
, int> index
;
98 const LPCWSTR
* lookup(LPCWSTR fontname
) const;
99 const LPCWSTR
sysfn() const { return default_font
; }
101 #if 0 /* disable sysfn for now*/
103 const LPCWSTR
sysfn() const { return syslf
.lfFaceName
; }
107 class CFontSubstitutesInfo
;
109 class CFontSubstituteData
111 friend CFontSubstitutesInfo
;
117 bool operator == (const CFontSubstituteData
& o
) const;
119 CFontSubstituteData();
120 bool init(LPCTSTR config
);
121 static int CALLBACK
EnumFontFamProc(const LOGFONT
*lplf
, const TEXTMETRIC
*lptm
, DWORD FontType
, LPARAM lParam
);
125 typedef StringHashT
<LF_FACESIZE
+ 10,true> CFontSubstitutesHash
;
126 typedef CArray
<CFontSubstitutesHash
> CFontSubstitutesIniArray
;
128 class CFontSubstitutesInfo
: public CSimpleMap
<CFontSubstituteData
, CFontSubstituteData
>
131 void initini(const CFontSubstitutesIniArray
& iniarray
);
134 void init(int nFontSubstitutes
, const CFontSubstitutesIniArray
& iniarray
);
135 const LOGFONT
* lookup(const LOGFONT
&lf
) const;
138 #define SETTING_FONTSUBSTITUTE_DISABLE (0)
139 #define SETTING_FONTSUBSTITUTE_INIONLY (1)
140 #define SETTING_FONTSUBSTITUTE_ALL (2)
142 #define SETTING_WIDTHMODE_GDI32 (0)
143 #define SETTING_WIDTHMODE_FREETYPE (1)
145 #define SETTING_FONTLOADER_FREETYPE (0)
146 #define SETTING_FONTLOADER_WIN32 (1)
148 class CGdippSettings
;
152 friend CFontSubstituteData
;
153 friend BOOL WINAPI
DllMain(HINSTANCE
, DWORD
, LPVOID
);
155 static CGdippSettings
* s_pInstance
;
157 CFontSettings m_FontSettings
;
158 bool m_bHookChildProcesses
: 1;
159 bool m_bUseMapping
: 1;
160 bool m_bLoadOnDemand
: 1;
161 bool m_bEnableShadow
: 1;
162 bool m_bFontLink
: 1;
164 bool m_bRunFromGdiExe
: 1;
165 bool m_bIsInclude
: 1;
166 bool m_bDelayedInit
: 1;
167 // bool m_bIsHDBench : 1;
168 // bool m_bHaveNewerFreeType : 1;
174 float m_fRenderWeight
;
179 int m_nFontSubstitutes
;
183 //FTC_Manager_New‚É“n‚·ƒpƒ‰ƒ��[ƒ^
184 int m_nCacheMaxFaces
;
185 int m_nCacheMaxSizes
;
186 int m_nCacheMaxBytes
;
188 // ƒAƒ“ƒ`ƒGƒCƒŠƒAƒX’²�®—pƒe�[ƒuƒ‹
189 int m_nTuneTable
[256];
191 int m_nTuneTableR
[256];
192 int m_nTuneTableG
[256];
193 int m_nTuneTableB
[256];
195 typedef CArray
<StringHashFont
> FontHashArray
;
196 typedef CArray
<StringHashModule
> ModuleHashArray
;
197 typedef CArray
<CFontIndividual
> IndividualArray
;
198 FontHashArray m_arrExcludeFont
;
199 ModuleHashArray m_arrExcludeModule
;
200 ModuleHashArray m_arrIncludeModule
;
201 IndividualArray m_arrIndividual
;
204 LOGFONT m_lfForceFont
;
205 TCHAR m_szForceChangeFont
[LF_FACESIZE
];
208 TCHAR m_szFileName
[MAX_PATH
];
210 //INI‚©‚ç‚Ì“Ç‚Ý�ž‚Ý�ˆ—�
211 bool LoadAppSettings(LPCTSTR lpszFile
);
212 static LPTSTR
_GetPrivateProfileSection (LPCTSTR lpszSection
, LPCTSTR lpszFile
);
213 static int _GetFreeTypeProfileInt (LPCTSTR lpszKey
, int nDefault
, LPCTSTR lpszFile
);
214 static int _GetFreeTypeProfileBoundInt (LPCTSTR lpszKey
, int nDefault
, int nMin
, int nMax
, LPCTSTR lpszFile
);
215 static float _GetFreeTypeProfileFloat (LPCTSTR lpszKey
, float fDefault
, LPCTSTR lpszFile
);
216 static float _GetFreeTypeProfileBoundFloat(LPCTSTR lpszKey
, float fDefault
, float fMin
, float fMax
, LPCTSTR lpszFile
);
217 static DWORD
_GetFreeTypeProfileString (LPCTSTR lpszKey
, LPCTSTR lpszDefault
, LPTSTR lpszRet
, DWORD cch
, LPCTSTR lpszFile
);
218 static int CALLBACK
EnumFontFamProc(const LOGFONT
* lplf
, const TEXTMETRIC
* lptm
, DWORD FontType
, LPARAM lParam
);
221 static bool AddListFromSection(LPCTSTR lpszSection
, LPCTSTR lpszFile
, CArray
<T
>& arr
);
222 bool AddIndividualFromSection(LPCTSTR lpszSection
, LPCTSTR lpszFile
, IndividualArray
& arr
);
223 static int _StrToInt(LPCTSTR pStr
, int nDefault
);
224 static float _StrToFloat(LPCTSTR pStr
, float fDefault
);
226 void InitInitTuneTable();
227 static void InitTuneTable(int v
, int* table
);
230 CFontLinkInfo m_fontlinkinfo
;
231 CFontSubstitutesInfo m_FontSubstitutesInfo
;
234 : m_bHookChildProcesses(false)
235 , m_bUseMapping(false)
236 , m_bLoadOnDemand(false)
237 , m_bEnableShadow(false)
239 // , m_bEnableKerning(false)
240 , m_bRunFromGdiExe(false)
241 , m_bIsInclude(false)
242 , m_bDelayedInit(false)
243 // , m_bIsHDBench(false)
244 // , m_bHaveNewerFreeType(false)
247 , m_fGammaValue(1.0f
)
248 , m_fRenderWeight(1.0f
)
252 , m_nCacheMaxFaces(0)
253 , m_nCacheMaxSizes(0)
254 , m_nCacheMaxBytes(0)
256 ZeroMemory(m_nTuneTable
, sizeof(m_nTuneTable
));
257 ZeroMemory(m_nTuneTableR
, sizeof(m_nTuneTableR
));
258 ZeroMemory(m_nTuneTableG
, sizeof(m_nTuneTableG
));
259 ZeroMemory(m_nTuneTableB
, sizeof(m_nTuneTableB
));
260 ZeroMemory(&m_lfForceFont
, sizeof(LOGFONT
));
261 ZeroMemory(m_nShadow
, sizeof(m_nShadow
));
262 ZeroMemory(m_szFileName
, sizeof(m_szFileName
));
263 ZeroMemory(m_szForceChangeFont
, sizeof(m_szForceChangeFont
));
270 static CGdippSettings
* CreateInstance();
271 static void DestroyInstance();
274 static const CGdippSettings
* GetInstance();
275 static const CGdippSettings
* GetInstanceNoInit(); //FreeTypeFontEngine
278 const CFontSettings
& GetFontSettings() const { return m_FontSettings
; }
279 bool HookChildProcesses() const { return m_bHookChildProcesses
; }
280 bool UseMapping() const { return m_bUseMapping
; }
281 bool LoadOnDemand() const { return m_bLoadOnDemand
; }
282 bool FontLink() const { return m_bFontLink
; }
283 // bool EnableKerning() const { return m_bEnableKerning; }
285 int BolderMode() const { return m_nBolderMode
; }
286 int GammaMode() const { return m_nGammaMode
; }
287 float GammaValue() const { return m_fGammaValue
; }
288 float RenderWeight() const { return m_fRenderWeight
; }
289 float Contrast() const { return m_fContrast
; }
290 int MaxHeight() const { return m_nMaxHeight
; }
291 int LcdFilter() const { return m_nLcdFilter
; }
292 int WidthMode() const { return m_nWidthMode
; }
293 int FontLoader() const { return m_nFontLoader
; }
294 int CacheMaxFaces() const { return m_nCacheMaxFaces
; }
295 int CacheMaxSizes() const { return m_nCacheMaxSizes
; }
296 int CacheMaxBytes() const { return m_nCacheMaxBytes
; }
298 bool EnableShadow() const { return m_bEnableShadow
; }
299 const int* GetShadowParams() const { return m_nShadow
; }
301 // ƒtƒHƒ“ƒg–¼‚æ‚Ý‚Æ‚è
302 LPCTSTR
GetForceFontName() const
304 _ASSERTE(m_bDelayedInit
);
305 LPCTSTR lpszFace
= m_lfForceFont
.lfFaceName
;
306 return lpszFace
[0] ? lpszFace
: NULL
;
309 bool CopyForceFont(LOGFONT
& lf
, const LOGFONT
& lfOrg
) const;
311 bool IsInclude() const { return m_bIsInclude
; }
312 // bool IsHDBench() const { return m_bIsHDBench; }
313 bool RunFromGdiExe() const { return m_bRunFromGdiExe
; }
314 // bool HaveNewerFreeType() const { return m_bHaveNewerFreeType; }
315 const int* GetTuneTable() const { return m_nTuneTable
; }
316 const int* GetTuneTableR() const { return m_nTuneTableR
; }
317 const int* GetTuneTableG() const { return m_nTuneTableG
; }
318 const int* GetTuneTableB() const { return m_nTuneTableB
; }
321 bool LoadSettings(HINSTANCE hModule
);
323 bool IsFontExcluded(LPCSTR lpFaceName
) const;
324 bool IsFontExcluded(LPCWSTR lpFaceName
) const;
326 bool IsProcessExcluded() const;
327 bool IsProcessIncluded() const;
328 const CFontSettings
& FindIndividual(LPCTSTR lpFaceName
) const;
330 const CFontLinkInfo
& GetFontLinkInfo() const
331 { _ASSERTE(m_bDelayedInit
); return m_fontlinkinfo
; }
332 const CFontSubstitutesInfo
& GetFontSubstitutesInfo() const
333 { _ASSERTE(m_bDelayedInit
); return m_FontSubstitutesInfo
; }
336 class CFontFaceNamesEnumerator
339 LPCWSTR m_facenames
[2];
340 const LPCWSTR
*p_facename
;
342 CFontFaceNamesEnumerator();
344 CFontFaceNamesEnumerator(LPCWSTR facename
);
345 operator LPCWSTR () {
352 return NULL
== *p_facename
;