Skip to content

Commit 264f9a9

Browse files
author
git
committed
per-app group setting is back.
1 parent b6821df commit 264f9a9

File tree

5 files changed

+57
-43
lines changed

5 files changed

+57
-43
lines changed

directwrite.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ bool hookDirectWrite(IUnknown ** factory) //此函数需要改进以判断是否
13991399
HOOK(pDWriteFactory, CreateGlyphRunAnalysis, 23);
14001400
HOOK(pDWriteFactory, GetGdiInterop, 17);
14011401
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
1402-
if (pSettings->GetFontSubstitutesInfoForDW().GetSize())
1402+
if (pSettings->GetFontSubstitutesInfo().GetSize())
14031403
hookFontCreation(pDWriteFactory);
14041404
MyDebug(L"DW1 hooked");
14051405

@@ -1514,8 +1514,12 @@ void HookD2DDll()
15141514
#ifdef DEBUG
15151515
MessageBox(0, L"HookD2DDll", NULL, MB_OK);
15161516
#endif
1517-
HMODULE d2d1 = LoadLibrary(_T("d2d1.dll"));
1518-
HMODULE dw = LoadLibrary(_T("dwrite.dll"));
1517+
HMODULE d2d1 = GetModuleHandle(_T("d2d1.dll"));
1518+
if (!d2d1)
1519+
d2d1 = LoadLibrary(_T("d2d1.dll"));
1520+
HMODULE dw = GetModuleHandle(_T("dwrite.dll"));
1521+
if (!dw)
1522+
dw = LoadLibrary(_T("dwrite.dll"));
15191523
void* D2D1Factory = GetProcAddress(d2d1, "D2D1CreateFactory");
15201524
void* D2D1Device = GetProcAddress(d2d1, "D2D1CreateDevice");
15211525
void* D2D1Context = GetProcAddress(d2d1, "D2D1CreateDeviceContext");
@@ -1612,7 +1616,7 @@ HRESULT WINAPI IMPL_CreateFontFace(IDWriteFont* self,
16121616
if (FAILED(g_pGdiInterop->ConvertFontFaceToLOGFONT(*fontFace, &lf)))
16131617
return ret;
16141618
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
1615-
if (pSettings->CopyForceFontForDW(lf, lf))
1619+
if (pSettings->CopyForceFont(lf, lf))
16161620
{
16171621
IDWriteFont* writefont = NULL;
16181622
if (FAILED(g_pGdiInterop->CreateFontFromLOGFONT(&lf, &writefont)))
@@ -1631,7 +1635,7 @@ bool SubstituteDWriteFont3(__out IDWriteFontFace3** fontFace3)
16311635
if (FAILED(g_pGdiInterop->ConvertFontFaceToLOGFONT(*fontFace3, &lf)))
16321636
return false;
16331637
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
1634-
if (pSettings->CopyForceFontForDW(lf, lf))
1638+
if (pSettings->CopyForceFont(lf, lf))
16351639
{
16361640
CComPtr<IDWriteFont> writefont;
16371641
if (FAILED(g_pGdiInterop->CreateFontFromLOGFONT(&lf, &writefont)))
@@ -1686,7 +1690,7 @@ HRESULT WINAPI IMPL_CreateTextFormat(IDWriteFactory* self,
16861690
LOGFONT lf = { 0 };
16871691
StringCchCopy(lf.lfFaceName, LF_FACESIZE, fontFamilyName);
16881692
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
1689-
if (pSettings->CopyForceFontForDW(lf, lf))
1693+
if (pSettings->CopyForceFont(lf, lf))
16901694
return ORIG_CreateTextFormat(self, lf.lfFaceName, fontCollection, fontWeight, fontStyle, fontStretch, fontSize, localeName, textFormat);
16911695
else
16921696
return ORIG_CreateTextFormat(self, fontFamilyName, fontCollection, fontWeight, fontStyle, fontStretch, fontSize, localeName, textFormat);

gdidll.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
2424
//
2525

2626
VS_VERSION_INFO VERSIONINFO
27-
FILEVERSION 1,2018,1019,0
28-
PRODUCTVERSION 1,2018,1019,0
27+
FILEVERSION 1,2018,1107,0
28+
PRODUCTVERSION 1,2018,1107,0
2929
FILEFLAGSMASK 0x8L
3030
#ifdef _DEBUG
3131
FILEFLAGS 0xbL
@@ -43,13 +43,13 @@ BEGIN
4343
VALUE "Comments", "Portions of this software are copyright (c) 2005-2017 The FreeType Project (www.freetype.org). All rights reserved."
4444
VALUE "CompanyName", "2ch & THEMEX"
4545
VALUE "FileDescription", "The Ultimate Font Rasterizer with Infinality patch"
46-
VALUE "FileVersion", "1.2018.1019.0"
46+
VALUE "FileVersion", "1.2018.1107.0"
4747
VALUE "InternalName", "MacType"
4848
VALUE "LegalCopyright", "(C) 460, 168, Higambana, 555 and sy567. All rights reserved. FlyingSnow republished"
4949
VALUE "OriginalFilename", "MacType.dll"
5050
VALUE "PrivateBuild", "True"
5151
VALUE "ProductName", "The Ultimate Font Rasterizer"
52-
VALUE "ProductVersion", "1.2018.1019.0"
52+
VALUE "ProductVersion", "1.2018.1107.0"
5353
VALUE "URL", "http://www.mactype.net http://drwatson.nobody.jp/gdi++/"
5454
END
5555
END

gdipp.vcxproj

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@
5555
<ProjectGuid>{15C33FD9-0811-4981-B08F-E0BAD74A3028}</ProjectGuid>
5656
<RootNamespace>gdipp</RootNamespace>
5757
<Keyword>Win32Proj</Keyword>
58-
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
58+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
5959
</PropertyGroup>
6060
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
6161
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
6262
<ConfigurationType>DynamicLibrary</ConfigurationType>
6363
<CharacterSet>Unicode</CharacterSet>
6464
<WholeProgramOptimization>true</WholeProgramOptimization>
65-
<PlatformToolset>v141</PlatformToolset>
65+
<PlatformToolset>v140_xp</PlatformToolset>
6666
</PropertyGroup>
6767
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Infinality|Win32'" Label="Configuration">
6868
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -72,7 +72,7 @@
7272
</PropertyGroup>
7373
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
7474
<ConfigurationType>DynamicLibrary</ConfigurationType>
75-
<PlatformToolset>v141</PlatformToolset>
75+
<PlatformToolset>v140_xp</PlatformToolset>
7676
<CharacterSet>Unicode</CharacterSet>
7777
</PropertyGroup>
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Infinality|Win32'" Label="Configuration">
@@ -82,7 +82,7 @@
8282
</PropertyGroup>
8383
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
8484
<ConfigurationType>DynamicLibrary</ConfigurationType>
85-
<PlatformToolset>v141</PlatformToolset>
85+
<PlatformToolset>v140</PlatformToolset>
8686
<CharacterSet>Unicode</CharacterSet>
8787
<WholeProgramOptimization>true</WholeProgramOptimization>
8888
</PropertyGroup>
@@ -106,7 +106,7 @@
106106
</PropertyGroup>
107107
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
108108
<ConfigurationType>DynamicLibrary</ConfigurationType>
109-
<PlatformToolset>v141</PlatformToolset>
109+
<PlatformToolset>v140</PlatformToolset>
110110
<CharacterSet>Unicode</CharacterSet>
111111
</PropertyGroup>
112112
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Infinality|x64'" Label="Configuration">
@@ -173,27 +173,31 @@
173173
<LinkIncremental>true</LinkIncremental>
174174
<GenerateManifest>false</GenerateManifest>
175175
<TargetName>$(ProjectName).Core</TargetName>
176+
<IncludePath>$(VC_IncludePath);$(WindowsSDK);D:\Archives\Documents\Visual Studio 2013\Projects\IniParser;D:\Archives\Documents\Visual Studio 2008\Projects\freetype2\include</IncludePath>
176177
</PropertyGroup>
177178
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Infinality|Win32'">
178179
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
179180
<IntDir>$(Configuration)\</IntDir>
180181
<LinkIncremental>true</LinkIncremental>
181182
<GenerateManifest>false</GenerateManifest>
182183
<TargetName>$(ProjectName).Core</TargetName>
184+
<IncludePath>$(VC_IncludePath);$(WindowsSDK);D:\Archives\Documents\Visual Studio 2013\Projects\IniParser;D:\Archives\Documents\Visual Studio 2008\Projects\freetype2\include</IncludePath>
183185
</PropertyGroup>
184186
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
185187
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
186188
<IntDir>$(Platform)\$(Configuration)\</IntDir>
187189
<LinkIncremental>true</LinkIncremental>
188190
<GenerateManifest>false</GenerateManifest>
189191
<TargetName>$(ProjectName)64.Core</TargetName>
192+
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);D:\Archives\Documents\Visual Studio 2013\Projects\IniParser;D:\Archives\Documents\Visual Studio 2008\Projects\freetype2\include</IncludePath>
190193
</PropertyGroup>
191194
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Infinality|x64'">
192195
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
193196
<IntDir>$(Platform)\$(Configuration)\</IntDir>
194197
<LinkIncremental>true</LinkIncremental>
195198
<GenerateManifest>false</GenerateManifest>
196199
<TargetName>$(ProjectName)64.Core</TargetName>
200+
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);D:\Archives\Documents\Visual Studio 2013\Projects\IniParser;D:\Archives\Documents\Visual Studio 2008\Projects\freetype2\include</IncludePath>
197201
</PropertyGroup>
198202
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
199203
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
@@ -215,27 +219,31 @@
215219
<LinkIncremental>false</LinkIncremental>
216220
<GenerateManifest>false</GenerateManifest>
217221
<TargetName>$(ProjectName).Core</TargetName>
222+
<IncludePath>$(VC_IncludePath);$(WindowsSDK);D:\Archives\Documents\Visual Studio 2013\Projects\IniParser;D:\Archives\Documents\Visual Studio 2008\Projects\freetype2\include</IncludePath>
218223
</PropertyGroup>
219224
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Infinality|Win32'">
220225
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
221226
<IntDir>$(Configuration)\</IntDir>
222227
<LinkIncremental>false</LinkIncremental>
223228
<GenerateManifest>false</GenerateManifest>
224229
<TargetName>$(ProjectName).Core</TargetName>
230+
<IncludePath>$(VC_IncludePath);$(WindowsSDK);D:\Archives\Documents\Visual Studio 2013\Projects\IniParser;D:\Archives\Documents\Visual Studio 2008\Projects\freetype2\include</IncludePath>
225231
</PropertyGroup>
226232
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
227233
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
228234
<IntDir>$(Platform)\$(Configuration)\</IntDir>
229235
<LinkIncremental>false</LinkIncremental>
230236
<GenerateManifest>false</GenerateManifest>
231237
<TargetName>$(ProjectName)64.Core</TargetName>
238+
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);D:\Archives\Documents\Visual Studio 2013\Projects\IniParser;D:\Archives\Documents\Visual Studio 2008\Projects\freetype2\include</IncludePath>
232239
</PropertyGroup>
233240
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Infinality|x64'">
234241
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
235242
<IntDir>$(Platform)\$(Configuration)\</IntDir>
236243
<LinkIncremental>false</LinkIncremental>
237244
<GenerateManifest>false</GenerateManifest>
238245
<TargetName>$(ProjectName)64.Core</TargetName>
246+
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);D:\Archives\Documents\Visual Studio 2013\Projects\IniParser;D:\Archives\Documents\Visual Studio 2008\Projects\freetype2\include</IncludePath>
239247
</PropertyGroup>
240248
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
241249
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>

settings.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ void CGdippSettings::DelayedInit()
124124
m_FontSubstitutesInfo.init(m_nFontSubstitutes, arrFontSubstitutes);
125125

126126
//FontSubstitutesDW
127-
CFontSubstitutesIniArray arrFontSubstitutesForDW;
127+
/*CFontSubstitutesIniArray arrFontSubstitutesForDW;
128128
names = _T("FontSubstitutesDW@") + wstring(m_szexeName);
129129
if (_IsFreeTypeProfileSectionExists(names.c_str(), m_szFileName))
130130
AddListFromSection(names.c_str(), m_szFileName, arrFontSubstitutesForDW);
131131
else
132132
AddListFromSection(_T("FontSubstitutesDW"), m_szFileName, arrFontSubstitutesForDW);
133-
m_FontSubstitutesInfoForDW.init(m_nFontSubstitutes, arrFontSubstitutesForDW);
133+
m_FontSubstitutesInfoForDW.init(m_nFontSubstitutes, arrFontSubstitutesForDW);*/
134134

135135
names = _T("Individual@") + wstring(m_szexeName);
136136
if (_IsFreeTypeProfileSectionExists(names.c_str(), NULL))
@@ -301,8 +301,14 @@ DWORD CGdippSettings::FastGetProfileString(LPCTSTR lpszSection, LPCTSTR lpszKey,
301301
}
302302
else
303303
{
304-
StringCchCopy(lpszRet, cch, lpszDefault);
305-
return wcslen(lpszDefault);
304+
if (lpszDefault) {
305+
StringCchCopy(lpszRet, cch, lpszDefault);
306+
return wcslen(lpszDefault);
307+
}
308+
else {
309+
lpszRet = NULL;
310+
return 0;
311+
}
306312
}
307313
}
308314

@@ -395,6 +401,7 @@ bool CGdippSettings::LoadAppSettings(LPCTSTR lpszFile)
395401
m_Config.LoadFromFile(lpszFile);
396402
}
397403

404+
_GetAlternativeProfileName(m_szexeName, lpszFile);
398405
CFontSettings& fs = m_FontSettings;
399406
fs.Clear();
400407
fs.SetHintingMode(_GetFreeTypeProfileBoundInt(_T("HintingMode"), 0, HINTING_MIN, HINTING_MAX, lpszFile));
@@ -1056,31 +1063,26 @@ const CFontSettings& CGdippSettings::FindIndividual(LPCTSTR lpFaceName) const
10561063
return GetFontSettings();
10571064
}
10581065

1059-
bool CGdippSettings::CopyForceFont(LOGFONT& lf, const LOGFONT& lfOrg) const
1066+
int CGdippSettings::_GetAlternativeProfileName(LPTSTR lpszName, LPCTSTR lpszFile)
10601067
{
1061-
_ASSERTE(m_bDelayedInit);
1062-
//__asm{ int 3 }
1063-
GetEnvironmentVariableW(L"MACTYPE_FONTSUBSTITUTES_ENV", NULL, 0);
1064-
if (GetLastError()!=ERROR_ENVVAR_NOT_FOUND)
1065-
return false;
1066-
//&lf == &lfOrgも可
1067-
bool bForceFont = !!GetForceFontName();
1068-
BOOL bFontExist = true;
1069-
const LOGFONT *lplf;
1070-
if (bForceFont) {
1071-
lplf = &m_lfForceFont;
1072-
} else {
1073-
lplf = GetFontSubstitutesInfo().lookup((LOGFONT&)lfOrg);
1074-
if (lplf) bForceFont = true;
1068+
TCHAR szexe[MAX_PATH + 1];
1069+
TCHAR* pexe = szexe + GetModuleFileName(NULL, szexe, MAX_PATH);
1070+
while (pexe >= szexe && *pexe != '\\')
1071+
pexe--;
1072+
pexe++;
1073+
wstring exename = _T("General@") + wstring((LPTSTR)pexe);
1074+
if (FastGetProfileString(exename.c_str(), _T("Alternative"), NULL, lpszName, MAX_PATH))
1075+
{
1076+
return true;
10751077
}
1076-
if (bForceFont) {
1077-
memcpy(&lf, &lfOrg, sizeof(LOGFONT)-sizeof(lf.lfFaceName));
1078-
StringCchCopy(lf.lfFaceName, LF_FACESIZE, lplf->lfFaceName);
1078+
else
1079+
{
1080+
//StringCchCopy(lpszName, MAX_PATH + 1, pexe);
1081+
return false;
10791082
}
1080-
return bForceFont;
10811083
}
10821084

1083-
bool CGdippSettings::CopyForceFontForDW(LOGFONT& lf, const LOGFONT& lfOrg) const
1085+
bool CGdippSettings::CopyForceFont(LOGFONT& lf, const LOGFONT& lfOrg) const
10841086
{
10851087
_ASSERTE(m_bDelayedInit);
10861088
//__asm{ int 3 }
@@ -1094,7 +1096,7 @@ bool CGdippSettings::CopyForceFontForDW(LOGFONT& lf, const LOGFONT& lfOrg) const
10941096
if (bForceFont) {
10951097
lplf = &m_lfForceFont;
10961098
} else {
1097-
lplf = GetFontSubstitutesInfoForDW().lookup((LOGFONT&)lfOrg);
1099+
lplf = GetFontSubstitutesInfo().lookup((LOGFONT&)lfOrg);
10981100
if (lplf) bForceFont = true;
10991101
}
11001102
if (bForceFont) {

settings.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ class CGdippSettings
357357
void InitInitTuneTable();
358358
static void InitTuneTable(int v, int* table);
359359
void DelayedInit();
360+
int _GetAlternativeProfileName(LPTSTR lpszName, LPCTSTR lpszFile);
360361

361362
CFontLinkInfo m_fontlinkinfo;
362363
CFontSubstitutesInfo m_FontSubstitutesInfo;
@@ -432,8 +433,8 @@ class CGdippSettings
432433
float ContrastForDW() const { return m_fContrastForDW; }
433434
float ClearTypeLevelForDW() const { return m_fClearTypeLevelForDW; }
434435
int RenderingModeForDW() const { return m_nRenderingModeForDW; }
435-
const CFontSubstitutesInfo& GetFontSubstitutesInfoForDW() const
436-
{ _ASSERTE(m_bDelayedInit); return m_FontSubstitutesInfoForDW; }
436+
/*const CFontSubstitutesInfo& GetFontSubstitutesInfoForDW() const
437+
{ _ASSERTE(m_bDelayedInit); return m_FontSubstitutesInfoForDW; }*/
437438

438439
float RenderWeight() const { return m_fRenderWeight; }
439440
float Contrast() const { return m_fContrast; }
@@ -468,7 +469,6 @@ class CGdippSettings
468469
}
469470

470471
bool CopyForceFont(LOGFONT& lf, const LOGFONT& lfOrg) const;
471-
bool CopyForceFontForDW(LOGFONT& lf, const LOGFONT& lfOrg) const;
472472

473473
//それ以外
474474
bool IsWinXPorLater() const { return m_bIsWinXPorLater; }

0 commit comments

Comments
 (0)