forked from snowie2000/mactype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.h
851 lines (788 loc) · 24.1 KB
/
settings.h
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
#pragma once
#include "common.h"
#include "gdiPlusFlat2.h"
#include "cache.h"
#include "hash_list.h"
#define MACTYPE_VERSION 20120404
#define MAX_FONT_SETTINGS 16
#define DEFINE_FS_MEMBER(name, param) \
int Get##name() const { return GetParam(param); } \
void Set##name(int n) { SetParam(param, n); }
#define HOOK_MANUALLY HOOK_DEFINE
#define HOOK_DEFINE(rettype, name, argtype) \
extern rettype (WINAPI * ORIG_##name) argtype; \
extern rettype WINAPI IMPL_##name argtype;
#include "hooklist.h"
#undef HOOK_DEFINE //ホェチヒネキア」エヒホトシメイトワヨアスモハケモテユネキオトコッハ」ャミ靨ェノ�」
#undef HOOK_MANUALLY
/*
struct CFontName
{
LPWSTR content;
public:
bool operator < (const CFontName fn) const {
return wcscmp(content, fn.content)>0;
}
CFontName(LPCWSTR fontname)
{
content = _wcsdup(fontname);
wcsupr(content);
}
~CFontName()
{
free(content);
}
};
struct CFontSubResult
{
public:
LPWSTR lpRealName;
LPWSTR lpGDIName;
CFontSubResult(LPCWSTR RealName, LPCWSTR GDIName)
{
lpRealName = _wcsdup(RealName);
lpGDIName = _wcsdup(GDIName);
}
~CFontSubResult()
{
free(lpRealName);
free(lpGDIName);
}
};
typedef map<CFontName,CFontSubResult> CFontNameCache;*/
class CFontSettings
{
private:
int m_settings[MAX_FONT_SETTINGS];
static const char m_bound[MAX_FONT_SETTINGS][2];
enum _FontSettingsParams {
FSP_HINTING = 0,
FSP_AAMODE = 1,
FSP_NORMAL_WEIGHT = 2,
FSP_BOLD_WEIGHT = 3,
FSP_ITALIC_SLANT = 4,
FSP_KERNING = 5,
};
public:
CFontSettings()
{
Clear();
}
DEFINE_FS_MEMBER(HintingMode, FSP_HINTING);
DEFINE_FS_MEMBER(AntiAliasMode, FSP_AAMODE);
DEFINE_FS_MEMBER(NormalWeight, FSP_NORMAL_WEIGHT);
DEFINE_FS_MEMBER(BoldWeight, FSP_BOLD_WEIGHT);
DEFINE_FS_MEMBER(ItalicSlant, FSP_ITALIC_SLANT);
DEFINE_FS_MEMBER(Kerning, FSP_KERNING);
int GetParam(int x) const
{
Assert(0 <= x && x < MAX_FONT_SETTINGS);
return m_settings[x];
}
void SetParam(int x, int n)
{
Assert(0 <= x && x < MAX_FONT_SETTINGS);
m_settings[x] = Bound<int>(n, m_bound[x][0], m_bound[x][1]);
}
void Clear()
{
ZeroMemory(m_settings, sizeof(m_settings));
}
void SetSettings(const int* p, int count)
{
count = Min(count, MAX_FONT_SETTINGS);
memcpy(m_settings, p, count * sizeof(int));
}
};
#undef DEFINE_FS_MEMBER
class CFontIndividual
{
CFontSettings m_set;
StringHashFont m_hash;
public:
CFontIndividual()
{
}
CFontIndividual(LPCTSTR name)
: m_hash(name)
{
}
CFontSettings& GetIndividual() { return m_set; }
LPCTSTR GetName() const { return m_hash.c_str(); }
const StringHashFont& GetHash() const { return m_hash; }
bool operator ==(const CFontIndividual& x) const { return (m_hash == x.m_hash); }
};
class CFontLinkInfo
{
public:
enum {
INFOMAX = 180, //ヤエホトシ=15
FONTMAX = 31,
};
private:
LPWSTR info[INFOMAX + 1][FONTMAX + 1];
bool AllowDefaultLink[256];
WCHAR DefaultFontLink[FF_DECORATIVE + 1][LF_FACESIZE + 1]; //エ豺ナカヤモヲラヨフ蠡獎ヘオトトャネマチエスモ
public:
CFontLinkInfo();
~CFontLinkInfo();
void init();
void clear();
const bool IsAllowFontLink(BYTE aCharset) const { return AllowDefaultLink[aCharset]; }
const LPCWSTR sysfn(int nFontFamily) const {
return DefaultFontLink[nFontFamily] ? DefaultFontLink[nFontFamily] : DefaultFontLink[1]; }
const LPCWSTR * lookup(LPCWSTR fontname) const;
LPCWSTR get(int row, int col) const;
};
class CFontSubstitutesInfo;
class CFontSubstituteData
{
friend CFontSubstitutesInfo;
private:
LOGFONT m_lf;
TEXTMETRIC m_tm;
bool m_bCharSet;
//TCHAR CustomName[LF_FACESIZE];
public:
bool operator == (const CFontSubstituteData& o) const;
private:
CFontSubstituteData();
bool init(LPCTSTR config);
static int CALLBACK EnumFontFamProc(const LOGFONT *lplf, const TEXTMETRIC *lptm, DWORD FontType, LPARAM lParam);
};
typedef StringHashT<LF_FACESIZE + 10,true> CFontSubstitutesHash;
typedef set<wstring> CFontSubstitutesIniArray;
class CFontSubstitutesInfo : public CSimpleMap<CFontSubstituteData, CFontSubstituteData>
{
private:
//typedef map<wstring, wstring> FontSubMap;
//FontSubMap m_mfontsub;
void initini(const CFontSubstitutesIniArray& iniarray);
void initreg();
public:
void init(int nFontSubstitutes, const CFontSubstitutesIniArray& iniarray);
const LOGFONT * lookup(LOGFONT &lf) const;
//void RemoveAll() {m_mfontsub.clear();};
//bool TrySub(LPCTSTR lpFacename) {return m_mfontsub.find(lpFacename)!=m_mfontsub.end(); };
};
#define SETTING_FONTSUBSTITUTE_DISABLE (0)
#define SETTING_FONTSUBSTITUTE_INIONLY (1)
#define SETTING_FONTSUBSTITUTE_ALL (2)
#define SETTING_WIDTHMODE_GDI32 (0)
#define SETTING_WIDTHMODE_FREETYPE (1)
#define SETTING_FONTLOADER_FREETYPE (0)
#define SETTING_FONTLOADER_WIN32 (1)
class CGdippSettings;
interface IControlCenter
{
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ __RPC__deref_out void __RPC_FAR *__RPC_FAR *ppvObject) = 0;
virtual ULONG STDMETHODCALLTYPE AddRef( void) = 0;
virtual ULONG STDMETHODCALLTYPE Release( void) = 0;
virtual ULONG WINAPI GetVersion(void) = 0;
virtual BOOL WINAPI SetIntAttribute(int eSet, int nValue) = 0;
virtual BOOL WINAPI SetFloatAttribute(int eSet, float nValue) = 0;
virtual int WINAPI GetIntAttribute(int eSet) = 0;
virtual float WINAPI GetFloatAttribute(int eSet) = 0;
virtual BOOL WINAPI RefreshSetting(void) = 0;
virtual BOOL WINAPI EnableRender(BOOL bEnable) = 0;
virtual BOOL WINAPI EnableCache(BOOL bEnable) = 0;
virtual BOOL WINAPI ClearIndividual() = 0;
virtual BOOL WINAPI AddIndividual(WCHAR* fontSetting) = 0;
virtual BOOL WINAPI DelIndividual(WCHAR* lpFaceName) = 0;
virtual void WINAPI LoadSetting(WCHAR* lpFileName) = 0;
};
class CControlCenter;
class CGdippSettings
{
friend CControlCenter;
friend CFontSubstituteData;
friend BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID);
private:
static CGdippSettings* s_pInstance;
//INI用
CFontSettings m_FontSettings;
bool m_bHookChildProcesses : 1;
bool m_bUseMapping : 1;
bool m_bLoadOnDemand : 1;
bool m_bEnableShadow : 1;
//それ以外
bool m_bIsWinXPorLater : 1;
bool m_bRunFromGdiExe : 1;
bool m_bIsInclude : 1;
bool m_bDelayedInit : 1;
// bool m_bIsHDBench : 1;
// bool m_bHaveNewerFreeType : 1;
bool : 0;
bool m_bUseCustomLcdFilter; //ハケモテラヤカィメ虱cdfilter
BOOL m_bHintSmallFont;
BOOL m_bDirectWrite;
int m_nBolderMode;
int m_nGammaMode;
float m_fGammaValue;
float m_fRenderWeight;
float m_fContrast;
int m_nMaxHeight;
int m_nBitmapHeight;
int m_nLcdFilter;
int m_nShadow[4];
int m_nFontSubstitutes;
int m_bFontLink; //クトホェソノメヤハケモテカ獰ヨイホハ
int m_nWidthMode;
int m_nFontLoader;
DWORD m_nShadowLightColor;
DWORD m_nShadowDarkColor;
unsigned char m_arrLcdFilterWeights[5];
//settings for experimental
bool m_bEnableClipBoxFix;
//FTC_Manager_Newに渡すパラメータ
int m_nCacheMaxFaces;
int m_nCacheMaxSizes;
int m_nCacheMaxBytes;
// アンチエイリアス調整用テーブル
int m_nTuneTable[256];
// LCD用
int m_nTuneTableR[256];
int m_nTuneTableG[256];
int m_nTuneTableB[256];
static TCHAR m_szexeName[MAX_PATH+1];
typedef set<wstring> FontHashMap;
typedef set<wstring> ModuleHashMap;
typedef set<wstring> FontSubSet;
typedef CArray<CFontIndividual> IndividualArray;
FontHashMap m_arrExcludeFont;
ModuleHashMap m_arrExcludeModule;
ModuleHashMap m_arrIncludeModule;
ModuleHashMap m_arrUnloadModule;
ModuleHashMap m_arrUnFontSubModule;
IndividualArray m_arrIndividual;
// 指定フォント
LOGFONT m_lfForceFont;
TCHAR m_szForceChangeFont[LF_FACESIZE];
//INIファイル名
TCHAR m_szFileName[MAX_PATH];
//INIからの読み込み処理
bool LoadAppSettings(LPCTSTR lpszFile);
static bool _IsFreeTypeProfileSectionExists(LPCTSTR lpszKey, LPCTSTR lpszFile);
static LPTSTR _GetPrivateProfileSection (LPCTSTR lpszSection, LPCTSTR lpszFile);
static int _GetFreeTypeProfileInt (LPCTSTR lpszKey, int nDefault, LPCTSTR lpszFile);
static int _GetFreeTypeProfileIntFromSection(LPCTSTR lpszSection, LPCTSTR lpszKey, int nDefault, LPCTSTR lpszFile);
static int _GetFreeTypeProfileBoundInt (LPCTSTR lpszKey, int nDefault, int nMin, int nMax, LPCTSTR lpszFile);
static float _GetFreeTypeProfileFloat (LPCTSTR lpszKey, float fDefault, LPCTSTR lpszFile);
static float _GetFreeTypeProfileBoundFloat(LPCTSTR lpszKey, float fDefault, float fMin, float fMax, LPCTSTR lpszFile);
static DWORD _GetFreeTypeProfileString (LPCTSTR lpszKey, LPCTSTR lpszDefault, LPTSTR lpszRet, DWORD cch, LPCTSTR lpszFile);
static int CALLBACK EnumFontFamProc(const LOGFONT* lplf, const TEXTMETRIC* lptm, DWORD FontType, LPARAM lParam);
static int _GetAlternativeProfileName(LPTSTR lpszName, LPCTSTR lpszFile);
//template <typename T>
static bool AddListFromSection(LPCTSTR lpszSection, LPCTSTR lpszFile, set<wstring> & arr);
static bool AddExcludeListFromSection(LPCTSTR lpszSection, LPCTSTR lpszFile, set<wstring> & arr);
bool AddIndividualFromSection(LPCTSTR lpszSection, LPCTSTR lpszFile, IndividualArray& arr);
bool AddLcdFilterFromSection(LPCTSTR lpszKey, LPCTSTR lpszFile, unsigned char* arr);
static int _StrToInt(LPCTSTR pStr, int nDefault);
static float _StrToFloat(LPCTSTR pStr, float fDefault);
static int _httoi(const TCHAR *value);
void InitInitTuneTable();
static void InitTuneTable(int v, int* table);
void DelayedInit();
CFontLinkInfo m_fontlinkinfo;
CFontSubstitutesInfo m_FontSubstitutesInfo;
CGdippSettings()
: m_bHookChildProcesses(false)
, m_bUseMapping(false)
, m_bLoadOnDemand(false)
, m_bEnableShadow(false)
, m_bFontLink(0)
// , m_bEnableKerning(false)
, m_bIsWinXPorLater(false)
, m_bRunFromGdiExe(false)
, m_bIsInclude(false)
, m_bDelayedInit(false)
// , m_bIsHDBench(false)
// , m_bHaveNewerFreeType(false)
, m_nBolderMode(0)
, m_nGammaMode(0)
, m_fGammaValue(1.0f)
, m_fRenderWeight(1.0f)
, m_fContrast(1.0f)
, m_nMaxHeight(0)
, m_nBitmapHeight(0)
, m_nLcdFilter(0)
, m_nCacheMaxFaces(0)
, m_nCacheMaxSizes(0)
, m_nCacheMaxBytes(0)
, m_bHintSmallFont(true)
, m_bDirectWrite(true)
{
ZeroMemory(m_nTuneTable, sizeof(m_nTuneTable));
ZeroMemory(m_nTuneTableR, sizeof(m_nTuneTableR));
ZeroMemory(m_nTuneTableG, sizeof(m_nTuneTableG));
ZeroMemory(m_nTuneTableB, sizeof(m_nTuneTableB));
ZeroMemory(&m_lfForceFont, sizeof(LOGFONT));
ZeroMemory(m_nShadow, sizeof(m_nShadow));
ZeroMemory(m_szFileName, sizeof(m_szFileName));
ZeroMemory(m_szForceChangeFont, sizeof(m_szForceChangeFont));
}
~CGdippSettings()
{
}
static CGdippSettings* CreateInstance();
static void DestroyInstance();
public:
static CGdippSettings* GetInstance();
static const CGdippSettings* GetInstanceNoInit(); //FreeTypeFontEngine
//INI用
const CFontSettings& GetFontSettings() const { return m_FontSettings; }
bool HookChildProcesses() const { return m_bHookChildProcesses; }
bool UseMapping() const { return m_bUseMapping; }
bool LoadOnDemand() const { return m_bLoadOnDemand; }
char FontLink() const { return m_bFontLink; }
BOOL DirectWrite() const { return m_bDirectWrite; }
BOOL HintSmallFont() const { return m_bHintSmallFont; }
// bool EnableKerning() const { return m_bEnableKerning; }
int BolderMode() const { return m_nBolderMode; }
int GammaMode() const { return m_nGammaMode; }
float GammaValue() const { return m_fGammaValue; }
float RenderWeight() const { return m_fRenderWeight; }
float Contrast() const { return m_fContrast; }
int MaxHeight() const { return m_nMaxHeight; }
int BitmapHeight() const { return m_nBitmapHeight; }
int LcdFilter() const { return m_nLcdFilter; }
const unsigned char* LcdFilterWeights() const { return m_arrLcdFilterWeights; }
bool UseCustomLcdFilter() const { return m_bUseCustomLcdFilter; }
int WidthMode() const { return m_nWidthMode; }
int FontLoader() const { return m_nFontLoader; }
bool EnableClipBoxFix() const { return m_bEnableClipBoxFix; }
DWORD ShadowLightColor() const { return m_nShadowLightColor; }
DWORD ShadowDarkColor() const { return m_nShadowDarkColor; }
int FontSubstitutes() const { return m_nFontSubstitutes; } //ナミカマフ貊サト」ハス
int CacheMaxFaces() const { return m_nCacheMaxFaces; }
int CacheMaxSizes() const { return m_nCacheMaxSizes; }
int CacheMaxBytes() const { return m_nCacheMaxBytes; }
bool EnableShadow() const { return m_bEnableShadow; }
const int* GetShadowParams() const { return m_nShadow; }
// フォント名よみとり
LPCTSTR GetForceFontName() const
{
_ASSERTE(m_bDelayedInit);
LPCTSTR lpszFace = m_lfForceFont.lfFaceName;
return lpszFace[0] ? lpszFace : NULL;
}
bool CopyForceFont(LOGFONT& lf, const LOGFONT& lfOrg) const;
//それ以外
bool IsWinXPorLater() const { return m_bIsWinXPorLater; }
bool IsInclude() const { return m_bIsInclude; }
// bool IsHDBench() const { return m_bIsHDBench; }
bool RunFromGdiExe() const { return m_bRunFromGdiExe; }
// bool HaveNewerFreeType() const { return m_bHaveNewerFreeType; }
const int* GetTuneTable() const { return m_nTuneTable; }
const int* GetTuneTableR() const { return m_nTuneTableR; }
const int* GetTuneTableG() const { return m_nTuneTableG; }
const int* GetTuneTableB() const { return m_nTuneTableB; }
bool LoadSettings();
bool LoadSettings(HINSTANCE hModule);
bool IsFontExcluded(LPCSTR lpFaceName) const;
bool IsFontExcluded(LPCWSTR lpFaceName) const;
//Snowie!!
bool IsProcessUnload() const;
bool IsExeUnload(LPCTSTR lpApp) const;
bool IsExeInclude(LPCTSTR lpApp) const;
void AddFontExclude(LPCWSTR lpFaceName); //オ耻ヨフ袒アスモラヤカッフ晴モオスエヒチミア
bool IsProcessExcluded() const;
bool IsProcessIncluded() const;
const CFontSettings& FindIndividual(LPCTSTR lpFaceName) const;
const CFontLinkInfo& GetFontLinkInfo() const
{ _ASSERTE(m_bDelayedInit); return m_fontlinkinfo; }
const CFontSubstitutesInfo& GetFontSubstitutesInfo() const
{ _ASSERTE(m_bDelayedInit); return m_FontSubstitutesInfo; }
};
class CFontFaceNamesEnumerator
{
private:
enum {
MAXFACENAMES = CFontLinkInfo::FONTMAX * 2 + 1,
};
LPCWSTR m_facenames[MAXFACENAMES];
int m_pos;
int m_endpos;
CFontFaceNamesEnumerator();
public:
CFontFaceNamesEnumerator(LPCWSTR facename, int nFontFamily);
operator LPCWSTR () {
return m_facenames[m_pos];
}
LPCWSTR getname()
{
return m_facenames[m_pos];
}
void next() {
++m_pos;
}
void prev() {
m_pos>0?--m_pos:0;
}
bool atend() {
return !!(m_pos >= m_endpos);
}
};
#include "fteng.h"
#include "ft.h"
#include <freetype/ftlcdfil.h>
#include "strtoken.h"
extern FreeTypeFontEngine* g_pFTEngine;
extern BOOL g_ccbCache;
extern BOOL g_ccbRender;
class CControlCenter: public IControlCenter
{
private:
int m_nRefCount;
bool m_bDirty;
enum eMTSettings{
ATTR_HINTINGMODE,
ATTR_ANTIALIASMODE,
ATTR_NormalWeight,
ATTR_BoldWeight,
ATTR_ItalicSlant,
ATTR_EnableKerning,
ATTR_GammaMode,
ATTR_LcdFilter,
ATTR_BolderMode,
ATTR_TextTuning,
ATTR_TextTuningR,
ATTR_TextTuningG,
ATTR_TextTuningB,
ATTR_GammaValue,
ATTR_Contrast,
ATTR_RenderWeight,
ATTR_ShadowAlpha,
ATTR_ShadowOffset,
ATTR_Fontlink,
ATTR_HookChildProcess,
ATTR_LoadOnDemand,
ATTR_FontLoader,
ATTR_FontSubstitute,
ATTR_LcdFilterWeight,
ATTR_ShadowBuffer
};
typedef CArray<CFontIndividual> IndividualArray;
public:
HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ __RPC__deref_out void __RPC_FAR *__RPC_FAR *ppvObject)
{
ppvObject = (void**)this;
return 0;
}
ULONG STDMETHODCALLTYPE AddRef( void) {return InterlockedIncrement((LONG*)&m_nRefCount);};
ULONG STDMETHODCALLTYPE Release( void) {
int result = InterlockedDecrement((LONG*)&m_nRefCount);
if (!result)
delete this;
return result;
}
ULONG WINAPI GetVersion(void){ return MACTYPE_VERSION; };
BOOL WINAPI SetIntAttribute(int eSet, int nValue)
{
CGdippSettings* pSettings = CGdippSettings::GetInstance();
switch ((eMTSettings)eSet)
{
case ATTR_HINTINGMODE:
pSettings->m_FontSettings.SetHintingMode(nValue);
break;
case ATTR_ANTIALIASMODE:
pSettings->m_FontSettings.SetAntiAliasMode(nValue);
break;
case ATTR_NormalWeight:
pSettings->m_FontSettings.SetNormalWeight(nValue);
break;
case ATTR_BoldWeight:
pSettings->m_FontSettings.SetBoldWeight(nValue);
break;
case ATTR_ItalicSlant:
pSettings->m_FontSettings.SetItalicSlant(nValue);
break;
case ATTR_EnableKerning:
pSettings->m_FontSettings.SetKerning(nValue);
break;
case ATTR_GammaMode:
pSettings->m_nGammaMode = nValue;
RefreshAlphaTable();
break;
case ATTR_LcdFilter:
pSettings->m_nLcdFilter = nValue;
FT_Library_SetLcdFilter(freetype_library, (FT_LcdFilter)nValue);
break;
case ATTR_BolderMode:
pSettings->m_nBolderMode = nValue;
break;
case ATTR_TextTuning:
pSettings->InitTuneTable(nValue, pSettings->m_nTuneTable);
RefreshAlphaTable();
break;
case ATTR_TextTuningR:
pSettings->InitTuneTable(nValue, pSettings->m_nTuneTableR);
RefreshAlphaTable();
break;
case ATTR_TextTuningG:
pSettings->InitTuneTable(nValue, pSettings->m_nTuneTableG);
RefreshAlphaTable();
break;
case ATTR_TextTuningB:
pSettings->InitTuneTable(nValue, pSettings->m_nTuneTableB);
RefreshAlphaTable();
break;
case ATTR_LoadOnDemand:
pSettings->m_bLoadOnDemand = !!nValue;
break;
case ATTR_ShadowAlpha:
pSettings->m_nShadow[2] = nValue;
pSettings->m_bEnableShadow = (nValue!=1);
RefreshAlphaTable();
break;
case ATTR_ShadowOffset:
pSettings->m_nShadow[1] = nValue;
pSettings->m_nShadow[0] = nValue;
case ATTR_Fontlink:
if (!!pSettings->m_bFontLink != !!nValue)
{
pSettings->m_fontlinkinfo.clear();
if (nValue)
pSettings->m_fontlinkinfo.init();
}
pSettings->m_bFontLink = nValue;
break;
case ATTR_FontLoader:
pSettings->m_nFontLoader = nValue;
break;
case ATTR_LcdFilterWeight:
if (!nValue)
pSettings->m_bUseCustomLcdFilter = false; //エォNULLケタエセヘハヌケリアユラヤカィメ蟷ツヒニ
else
{
pSettings->m_bUseCustomLcdFilter = true; //キェケツヒニ
if (!IsBadReadPtr((void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights))) //ネ郢鋓クユ�ミミァ
memcpy(pSettings->m_arrLcdFilterWeights, (void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights)); //クエヨニハセン
}
UpdateLcdFilter(); //ヒ「ミツケツヒニ
break;
case ATTR_ShadowBuffer:
if (nValue && !IsBadReadPtr((void*)nValue, sizeof(pSettings->m_nShadow))) //ヨクユ�ミミァ
{
LPCTSTR szShadow = (LPCTSTR)nValue;
CStringTokenizer token;
if (token.Parse(szShadow) < 3) {
break;
}
for (int i=0; i<3; i++) {
pSettings->m_nShadow[i] = pSettings->_StrToInt(token.GetArgument(i), 0);
/*if (m_nShadow[i] <= 0) {
goto SKIP;
}*/
}
pSettings->m_bEnableShadow = true;
if (token.GetCount()>=4) //ネ郢鋓クカィチヒヌウノォメー
pSettings->m_nShadowDarkColor = pSettings->_httoi(token.GetArgument(3)); //カチネ。メー
else
pSettings->m_nShadowDarkColor = 0; //キェコレノォ
if (token.GetCount()>=6) //ネ郢鋓クカィチヒノ鐱ォメー
{
pSettings->m_nShadowLightColor = pSettings->_httoi(token.GetArgument(5)); //カチネ。メー
pSettings->m_nShadow[3] = pSettings->_StrToInt(token.GetArgument(4), pSettings->m_nShadow[2]); //カチネ。ノ鋐ネ
}
else
{
pSettings->m_nShadowLightColor = pSettings->m_nShadowLightColor; //キヘヌウノォメーマ猩ャ
pSettings->m_nShadow[3] = pSettings->m_nShadow[2]; //ノ鋐ネメイマ猩ャ
}
RefreshAlphaTable();
}
break;
default:
return FALSE;
}
m_bDirty = true;
return true;
}
BOOL WINAPI SetFloatAttribute(int eSet, float nValue)
{
CGdippSettings* pSettings = CGdippSettings::GetInstance();
switch ((eMTSettings)eSet)
{
case ATTR_GammaValue:
pSettings->m_fGammaValue = nValue;
RefreshAlphaTable();
break;
case ATTR_Contrast:
pSettings->m_fContrast = nValue;
RefreshAlphaTable();
break;
case ATTR_RenderWeight:
pSettings->m_fRenderWeight = nValue;
RefreshAlphaTable();
break;
default:
return FALSE;
}
m_bDirty = true;
return true;
};
int WINAPI GetIntAttribute(int eSet) {
CGdippSettings* pSettings = CGdippSettings::GetInstance();
switch ((eMTSettings)eSet)
{
case ATTR_HINTINGMODE:
return pSettings->m_FontSettings.GetHintingMode();
case ATTR_ANTIALIASMODE:
return pSettings->m_FontSettings.GetAntiAliasMode();
case ATTR_NormalWeight:
return pSettings->m_FontSettings.GetNormalWeight();
case ATTR_BoldWeight:
return pSettings->m_FontSettings.GetBoldWeight();
case ATTR_ItalicSlant:
return pSettings->m_FontSettings.GetItalicSlant();
case ATTR_EnableKerning:
return pSettings->m_FontSettings.GetKerning();
case ATTR_GammaMode:
return pSettings->m_nGammaMode;
case ATTR_LcdFilter:
return pSettings->m_nLcdFilter;
case ATTR_BolderMode:
return pSettings->m_nBolderMode;
case ATTR_TextTuning:
return 0;
case ATTR_TextTuningR:
return 0;
case ATTR_TextTuningG:
return 0;
case ATTR_TextTuningB:
return 0;
case ATTR_LoadOnDemand:
return pSettings->m_bLoadOnDemand;
case ATTR_ShadowAlpha:
return pSettings->EnableShadow()? pSettings->m_nShadow[2] : 1;
case ATTR_ShadowOffset:
return pSettings->EnableShadow()? pSettings->m_nShadow[0] : 1;
case ATTR_Fontlink:
return pSettings->m_bFontLink;
case ATTR_LcdFilterWeight:
return pSettings->m_bUseCustomLcdFilter? (int)pSettings->m_arrLcdFilterWeights:NULL;
default:
return 0;
}
return 0;
};
float WINAPI GetFloatAttribute(int eSet) {
CGdippSettings* pSettings = CGdippSettings::GetInstance();
switch ((eMTSettings)eSet)
{
case ATTR_GammaValue:
return pSettings->m_fGammaValue;
case ATTR_Contrast:
return pSettings->m_fContrast;
case ATTR_RenderWeight:
return pSettings->m_fRenderWeight;
default:
return 0;
}
return 0;
};
BOOL WINAPI RefreshSetting(void) {
if (m_bDirty)
g_pFTEngine->ReloadAll();
m_bDirty = false;
return true;
};
BOOL WINAPI EnableRender(BOOL bEnable){g_ccbRender = bEnable; return true;};
BOOL WINAPI EnableCache(BOOL bEnable){g_ccbCache = bEnable; return true;};
BOOL WINAPI ClearIndividual(){
CGdippSettings* pSettings = CGdippSettings::GetInstance();
pSettings->m_arrIndividual.RemoveAll();
m_bDirty = true;
return true;
};
BOOL WINAPI AddIndividual(WCHAR* fontSetting)
{
CGdippSettings* pSettings = CGdippSettings::GetInstance();
IndividualArray& arr = pSettings->m_arrIndividual;
LPTSTR p = fontSetting;
LOGFONT truefont={0};
if (*p) {
bool b = false;
LPTSTR pnext = p;
for (; *pnext; pnext++);
//"MS Pゴシック=0,0" みたいな文字列を分割
LPTSTR value = _tcschr(p, _T('='));
CStringTokenizer token;
int argc = 0;
if (value) {
*value++ = _T('\0');
argc = token.Parse(value);
}
TCHAR buff[LF_FACESIZE+1];
GetFontLocalName(p, buff); //ラェササラヨフ蠹
CFontIndividual fi(buff);
const CFontSettings& fsCommon = pSettings->m_FontSettings;
CFontSettings& fs = fi.GetIndividual();
//Individualが無ければ共通設定を使う
fs = fsCommon;
for (int i = 0; i < MAX_FONT_SETTINGS; i++) {
LPCTSTR arg = token.GetArgument(i);
if (!arg)
break;
const int n = pSettings->_StrToInt(arg, fsCommon.GetParam(i));
fs.SetParam(i, n);
}
for (int i = 0 ; i < arr.GetSize(); i++) {
if (arr[i] == fi) {
b = true;
break;
}
}
if (!b) {
arr.Add(fi);
}
}
m_bDirty = true;
return true; };
BOOL WINAPI DelIndividual(WCHAR* lpFaceName) {
CGdippSettings* pSettings = CGdippSettings::GetInstance();
CFontIndividual* p = pSettings->m_arrIndividual.Begin();
CFontIndividual* end = pSettings->m_arrIndividual.End();
StringHashFont hash(lpFaceName);
for(; p != end; ++p) {
if (p->GetHash() == hash) {
pSettings->m_arrIndividual.Remove(*p);
}
}
m_bDirty = true;
return true;};
void WINAPI LoadSetting(WCHAR* lpFileName)
{
CGdippSettings* pSettings = CGdippSettings::GetInstance();
ClearIndividual();
pSettings->m_FontSubstitutesInfo.RemoveAll();
pSettings->m_fontlinkinfo.clear();
pSettings->LoadAppSettings(lpFileName);
pSettings->m_bDelayedInit = false;
m_bDirty = true;
RefreshAlphaTable();
RefreshSetting();
}
CControlCenter():m_nRefCount(1), m_bDirty(false){};
~CControlCenter(){};
static void WINAPI ReloadConfig()
{
//CCriticalSectionLock __lock(CCriticalSectionLock::CS_LIBRARY);
CGdippSettings* pSettings = CGdippSettings::GetInstance();
extern HINSTANCE g_dllInstance;
pSettings->m_arrIndividual.RemoveAll();
pSettings->m_FontSubstitutesInfo.RemoveAll();
pSettings->m_fontlinkinfo.clear();
pSettings->LoadSettings(g_dllInstance);
pSettings->m_bDelayedInit = false;
RefreshAlphaTable();
UpdateLcdFilter();
if (g_pFTEngine)
g_pFTEngine->ReloadAll();
}
};