From 6fce9a2fffcb3922a833f4bbba9be873609dff52 Mon Sep 17 00:00:00 2001 From: git Date: Thu, 2 Aug 2018 11:07:50 +0800 Subject: [PATCH] Infinality patch support (with custom FT_Env calls) --- common.h | 3 +- directwrite.cpp | 348 +++++++++++++++++++++--------------------- expfunc.cpp | 12 ++ ft.cpp | 9 ++ ft2vert.c | 8 +- gdidll.rc | 8 +- gdipp.sln | 12 ++ gdipp.vcxproj | 313 +++++++++++++++++++++++++++++++++++++ gdipp.vcxproj.filters | 3 + hook.cpp | 12 ++ override.cpp | 11 +- settings.cpp | 73 +++++++++ settings.h | 3 + 13 files changed, 631 insertions(+), 184 deletions(-) diff --git a/common.h b/common.h index 4d81f7e..a0ce42c 100644 --- a/common.h +++ b/common.h @@ -626,4 +626,5 @@ float _StrToFloat(LPCTSTR pStr, float fDefault) void HookD2DDll(); bool HookD2D1(); void HookGdiplus(); -void ChangeFileName(LPWSTR lpSrc, int nSize, LPCWSTR lpNewFileName); \ No newline at end of file +void ChangeFileName(LPWSTR lpSrc, int nSize, LPCWSTR lpNewFileName); +std::string WstringToString(const std::wstring str); \ No newline at end of file diff --git a/directwrite.cpp b/directwrite.cpp index 9abc487..78bc2e7 100644 --- a/directwrite.cpp +++ b/directwrite.cpp @@ -48,14 +48,14 @@ LONG bDWLoaded = false, bD2D1Loaded = false, bParamInited = false, bParamCreated IDWriteFactory* g_pDWriteFactory = NULL; IDWriteGdiInterop* g_pGdiInterop = NULL; -template -inline HRESULT IfSupport(IUnknown* pUnknown, void(*lpFunc)(Intf*)) { - CComPtr comObject; - HRESULT hr = pUnknown->QueryInterface(&comObject); - if (SUCCEEDED(hr)) { - lpFunc(comObject); - } - return hr; +template +inline HRESULT IfSupport(IUnknown* pUnknown, void(*lpFunc)(Intf*)) { + CComPtr comObject; + HRESULT hr = pUnknown->QueryInterface(&comObject); + if (SUCCEEDED(hr)) { + lpFunc(comObject); + } + return hr; } IDWriteRenderingParams* CreateParam(Params* d2dParams, IDWriteFactory *dw_factory) @@ -186,8 +186,8 @@ bool MakeD2DParams() break; case 1: g_D2DParams.GridFitMode = DWRITE_GRID_FIT_MODE_DISABLED; break; - default: - g_D2DParams.GridFitMode = DWRITE_GRID_FIT_MODE_ENABLED; + default: + g_D2DParams.GridFitMode = DWRITE_GRID_FIT_MODE_ENABLED; break; } g_D2DParams.RenderingMode1 = (DWRITE_RENDERING_MODE1)pSettings->RenderingModeForDW(); @@ -1305,75 +1305,75 @@ HRESULT WINAPI IMPL_CreateTextFormat(IDWriteFactory* self, return ORIG_CreateTextFormat(self, fontFamilyName, fontCollection, fontWeight, fontStyle, fontStretch, fontSize, localeName, textFormat); } -void WINAPI IMPL_D2D1DeviceContext_DrawGlyphRun( - ID2D1DeviceContext *This, - D2D1_POINT_2F baselineOrigin, - CONST DWRITE_GLYPH_RUN *glyphRun, - CONST DWRITE_GLYPH_RUN_DESCRIPTION *glyphRunDescription, - ID2D1Brush *foregroundBrush, - DWRITE_MEASURING_MODE measuringMode - ) { - if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { - D2D1_MATRIX_3X2_F prev; - This->GetTransform(&prev); - D2D1_MATRIX_3X2_F rotate = prev; - rotate.m12 += 1.0f / 0xFFFF; - rotate.m21 += 1.0f / 0xFFFF; - This->SetTransform(&rotate); - ORIG_D2D1DeviceContext_DrawGlyphRun( - This, - baselineOrigin, - glyphRun, - glyphRunDescription, - foregroundBrush, - measuringMode - ); - This->SetTransform(&prev); - } - else { - ORIG_D2D1DeviceContext_DrawGlyphRun( - This, - baselineOrigin, - glyphRun, - glyphRunDescription, - foregroundBrush, - measuringMode - ); - } +void WINAPI IMPL_D2D1DeviceContext_DrawGlyphRun( + ID2D1DeviceContext *This, + D2D1_POINT_2F baselineOrigin, + CONST DWRITE_GLYPH_RUN *glyphRun, + CONST DWRITE_GLYPH_RUN_DESCRIPTION *glyphRunDescription, + ID2D1Brush *foregroundBrush, + DWRITE_MEASURING_MODE measuringMode + ) { + if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { + D2D1_MATRIX_3X2_F prev; + This->GetTransform(&prev); + D2D1_MATRIX_3X2_F rotate = prev; + rotate.m12 += 1.0f / 0xFFFF; + rotate.m21 += 1.0f / 0xFFFF; + This->SetTransform(&rotate); + ORIG_D2D1DeviceContext_DrawGlyphRun( + This, + baselineOrigin, + glyphRun, + glyphRunDescription, + foregroundBrush, + measuringMode + ); + This->SetTransform(&prev); + } + else { + ORIG_D2D1DeviceContext_DrawGlyphRun( + This, + baselineOrigin, + glyphRun, + glyphRunDescription, + foregroundBrush, + measuringMode + ); + } } -void WINAPI IMPL_D2D1RenderTarget_DrawGlyphRun( - ID2D1RenderTarget* This, - D2D1_POINT_2F baselineOrigin, - CONST DWRITE_GLYPH_RUN *glyphRun, - ID2D1Brush *foregroundBrush, - DWRITE_MEASURING_MODE measuringMode - ) { - if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { - D2D1_MATRIX_3X2_F prev; - This->GetTransform(&prev); - D2D1_MATRIX_3X2_F rotate = prev; - rotate.m12 += 1.0f / 0xFFFF; - rotate.m21 += 1.0f / 0xFFFF; - This->SetTransform(&rotate); - ORIG_D2D1RenderTarget_DrawGlyphRun( - This, - baselineOrigin, - glyphRun, - foregroundBrush, - measuringMode - ); - This->SetTransform(&prev); - } - else { - ORIG_D2D1RenderTarget_DrawGlyphRun( - This, - baselineOrigin, - glyphRun, - foregroundBrush, - measuringMode - ); - } +void WINAPI IMPL_D2D1RenderTarget_DrawGlyphRun( + ID2D1RenderTarget* This, + D2D1_POINT_2F baselineOrigin, + CONST DWRITE_GLYPH_RUN *glyphRun, + ID2D1Brush *foregroundBrush, + DWRITE_MEASURING_MODE measuringMode + ) { + if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { + D2D1_MATRIX_3X2_F prev; + This->GetTransform(&prev); + D2D1_MATRIX_3X2_F rotate = prev; + rotate.m12 += 1.0f / 0xFFFF; + rotate.m21 += 1.0f / 0xFFFF; + This->SetTransform(&rotate); + ORIG_D2D1RenderTarget_DrawGlyphRun( + This, + baselineOrigin, + glyphRun, + foregroundBrush, + measuringMode + ); + This->SetTransform(&prev); + } + else { + ORIG_D2D1RenderTarget_DrawGlyphRun( + This, + baselineOrigin, + glyphRun, + foregroundBrush, + measuringMode + ); + } } @@ -1388,28 +1388,28 @@ HRESULT WINAPI IMPL_BitmapRenderTarget_DrawGlyphRun( RECT* blackBoxRect) { HRESULT hr = E_FAIL; - if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { - DWRITE_MATRIX prev; - hr = This->GetCurrentTransform(&prev); - if (SUCCEEDED(hr)) { - DWRITE_MATRIX rotate = prev; - rotate.m12 += 1.0f / 0xFFFF; - rotate.m21 += 1.0f / 0xFFFF; - hr = This->SetCurrentTransform(&rotate); - if (SUCCEEDED(hr)) { - hr = ORIG_BitmapRenderTarget_DrawGlyphRun( - This, - baselineOriginX, - baselineOriginY, - measuringMode, - glyphRun, - g_DWParams.GetRenderingParams(renderingParams), - textColor, - blackBoxRect - ); - This->SetCurrentTransform(&prev); - } - } + if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { + DWRITE_MATRIX prev; + hr = This->GetCurrentTransform(&prev); + if (SUCCEEDED(hr)) { + DWRITE_MATRIX rotate = prev; + rotate.m12 += 1.0f / 0xFFFF; + rotate.m21 += 1.0f / 0xFFFF; + hr = This->SetCurrentTransform(&rotate); + if (SUCCEEDED(hr)) { + hr = ORIG_BitmapRenderTarget_DrawGlyphRun( + This, + baselineOriginX, + baselineOriginY, + measuringMode, + glyphRun, + g_DWParams.GetRenderingParams(renderingParams), + textColor, + blackBoxRect + ); + This->SetCurrentTransform(&prev); + } + } } if (FAILED(hr)) { hr = ORIG_BitmapRenderTarget_DrawGlyphRun( @@ -1446,79 +1446,79 @@ HRESULT WINAPI IMPL_BitmapRenderTarget_DrawGlyphRun( } -void WINAPI IMPL_D2D1RenderTarget_DrawText( - ID2D1RenderTarget* This, - CONST WCHAR *string, - UINT32 stringLength, - IDWriteTextFormat *textFormat, - CONST D2D1_RECT_F *layoutRect, - ID2D1Brush *defaultForegroundBrush, - D2D1_DRAW_TEXT_OPTIONS options, - DWRITE_MEASURING_MODE measuringMode - ) { - if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { - D2D1_MATRIX_3X2_F prev; - This->GetTransform(&prev); - D2D1_MATRIX_3X2_F rotate = prev; - rotate.m12 += 1.0f / 0xFFFF; - rotate.m21 += 1.0f / 0xFFFF; - This->SetTransform(&rotate); - ORIG_D2D1RenderTarget_DrawText( - This, - string, - stringLength, - textFormat, - layoutRect, - defaultForegroundBrush, - options, - measuringMode - ); - This->SetTransform(&prev); - } - else { - ORIG_D2D1RenderTarget_DrawText( - This, - string, - stringLength, - textFormat, - layoutRect, - defaultForegroundBrush, - options, - measuringMode - ); - } -} - -void WINAPI IMPL_D2D1RenderTarget_DrawTextLayout( - ID2D1RenderTarget* This, - D2D1_POINT_2F origin, - IDWriteTextLayout *textLayout, - ID2D1Brush *defaultForegroundBrush, - D2D1_DRAW_TEXT_OPTIONS options - ) { - if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { - D2D1_MATRIX_3X2_F prev; - This->GetTransform(&prev); - D2D1_MATRIX_3X2_F rotate = prev; - rotate.m12 += 1.0f / 0xFFFF; - rotate.m21 += 1.0f / 0xFFFF; - This->SetTransform(&rotate); - ORIG_D2D1RenderTarget_DrawTextLayout( - This, - origin, - textLayout, - defaultForegroundBrush, - options - ); - This->SetTransform(&prev); - } - else { - ORIG_D2D1RenderTarget_DrawTextLayout( - This, - origin, - textLayout, - defaultForegroundBrush, - options - ); - } +void WINAPI IMPL_D2D1RenderTarget_DrawText( + ID2D1RenderTarget* This, + CONST WCHAR *string, + UINT32 stringLength, + IDWriteTextFormat *textFormat, + CONST D2D1_RECT_F *layoutRect, + ID2D1Brush *defaultForegroundBrush, + D2D1_DRAW_TEXT_OPTIONS options, + DWRITE_MEASURING_MODE measuringMode + ) { + if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { + D2D1_MATRIX_3X2_F prev; + This->GetTransform(&prev); + D2D1_MATRIX_3X2_F rotate = prev; + rotate.m12 += 1.0f / 0xFFFF; + rotate.m21 += 1.0f / 0xFFFF; + This->SetTransform(&rotate); + ORIG_D2D1RenderTarget_DrawText( + This, + string, + stringLength, + textFormat, + layoutRect, + defaultForegroundBrush, + options, + measuringMode + ); + This->SetTransform(&prev); + } + else { + ORIG_D2D1RenderTarget_DrawText( + This, + string, + stringLength, + textFormat, + layoutRect, + defaultForegroundBrush, + options, + measuringMode + ); + } +} + +void WINAPI IMPL_D2D1RenderTarget_DrawTextLayout( + ID2D1RenderTarget* This, + D2D1_POINT_2F origin, + IDWriteTextLayout *textLayout, + ID2D1Brush *defaultForegroundBrush, + D2D1_DRAW_TEXT_OPTIONS options + ) { + if (g_DWParams.GridFitMode == DWRITE_GRID_FIT_MODE_DISABLED) { + D2D1_MATRIX_3X2_F prev; + This->GetTransform(&prev); + D2D1_MATRIX_3X2_F rotate = prev; + rotate.m12 += 1.0f / 0xFFFF; + rotate.m21 += 1.0f / 0xFFFF; + This->SetTransform(&rotate); + ORIG_D2D1RenderTarget_DrawTextLayout( + This, + origin, + textLayout, + defaultForegroundBrush, + options + ); + This->SetTransform(&prev); + } + else { + ORIG_D2D1RenderTarget_DrawTextLayout( + This, + origin, + textLayout, + defaultForegroundBrush, + options + ); + } } \ No newline at end of file diff --git a/expfunc.cpp b/expfunc.cpp index c0973d0..13dc1f8 100644 --- a/expfunc.cpp +++ b/expfunc.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "wow64ext.h" #include @@ -174,6 +175,17 @@ void ChangeFileName(LPWSTR lpSrc, int nSize, LPCWSTR lpNewFileName) { wcscat(lpSrc, lpNewFileName); } +std::string WstringToString(const std::wstring str) +{// wstringתstring + unsigned len = str.size() * 4; + setlocale(LC_CTYPE, ""); + char *p = new char[len]; + wcstombs(p, str.c_str(), len); + std::string str1(p); + delete[] p; + return str1; +} + #ifndef Assert #include #define Assert _ASSERTE diff --git a/ft.cpp b/ft.cpp index 75e207f..3bca57e 100644 --- a/ft.cpp +++ b/ft.cpp @@ -3110,6 +3110,15 @@ BOOL FontLInit(void){ if(FT_Init_FreeType(&freetype_library)){ return FALSE; } + +#ifdef INFINALITY +#define TT_INTERPRETER_VERSION_35 35 +#define TT_INTERPRETER_VERSION_38 38 +#define TT_INTERPRETER_VERSION_40 40 + FT_UInt interpreter_version = TT_INTERPRETER_VERSION_38; + FT_Property_Set(freetype_library, "truetype", "interpreter-version", &interpreter_version); +#endif + //enable stem darkening feature introduced in 2.6.2 FT_Bool no_stem_darkening = FALSE; FT_Property_Set(freetype_library, "cff", "no-stem-darkening", &no_stem_darkening); diff --git a/ft2vert.c b/ft2vert.c index 5eba045..a0abd64 100644 --- a/ft2vert.c +++ b/ft2vert.c @@ -20,7 +20,7 @@ //#include "xdvi-config.h" //#include "xdvi.h" //#ifdef USE_ZEIT -#include +//#include #include #include FT_FREETYPE_H #include FT_OPENTYPE_VALIDATE_H @@ -114,12 +114,12 @@ struct RangeRecord_st { int isInIndex(FT_Bytes s, int index) { int i, count; - if (s == NULL) return FALSE; + if (s == NULL) return 0; count = BYTE2(s); for (i = 0; i < count; i++) { - if (index == BYTE2(s)) return TRUE; + if (index == BYTE2(s)) return 1; } - return FALSE; + return 0; } diff --git a/gdidll.rc b/gdidll.rc index d7fcb49..d4dab32 100644 --- a/gdidll.rc +++ b/gdidll.rc @@ -24,8 +24,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,2017,1017,0 - PRODUCTVERSION 1,2017,1017,0 + FILEVERSION 1,2018,719,0 + PRODUCTVERSION 1,2018,719,0 FILEFLAGSMASK 0x8L #ifdef _DEBUG FILEFLAGS 0xbL @@ -43,13 +43,13 @@ BEGIN VALUE "Comments", "Portions of this software are copyright (c) 2005-2017 The FreeType Project (www.freetype.org). All rights reserved." VALUE "CompanyName", "2ch & THEMEX" VALUE "FileDescription", "The Ultimate Font Rasterizer with Infinality patch" - VALUE "FileVersion", "1.2017.1017.0" + VALUE "FileVersion", "1.2018.719.0" VALUE "InternalName", "MacType" VALUE "LegalCopyright", "(C) 460, 168, Higambana, 555 and sy567. All rights reserved. FlyingSnow republished" VALUE "OriginalFilename", "MacType.dll" VALUE "PrivateBuild", "True" VALUE "ProductName", "The Ultimate Font Rasterizer" - VALUE "ProductVersion", "1.2017.1017.0" + VALUE "ProductVersion", "1.2018.719.0" VALUE "URL", "http://mactype.themex.net http://drwatson.nobody.jp/gdi++/" END END diff --git a/gdipp.sln b/gdipp.sln index 76159f9..5b7a8d0 100644 --- a/gdipp.sln +++ b/gdipp.sln @@ -7,16 +7,28 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MacType", "gdipp.vcxproj", EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Infinality|Win32 = Debug Infinality|Win32 + Debug Infinality|x64 = Debug Infinality|x64 Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 + Release Infinality|Win32 = Release Infinality|Win32 + Release Infinality|x64 = Release Infinality|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Debug Infinality|Win32.ActiveCfg = Debug Infinality|Win32 + {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Debug Infinality|Win32.Build.0 = Debug Infinality|Win32 + {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Debug Infinality|x64.ActiveCfg = Debug Infinality|x64 + {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Debug Infinality|x64.Build.0 = Debug Infinality|x64 {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Debug|Win32.ActiveCfg = Debug|Win32 {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Debug|Win32.Build.0 = Debug|Win32 {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Debug|x64.ActiveCfg = Debug|x64 {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Debug|x64.Build.0 = Debug|x64 + {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release Infinality|Win32.ActiveCfg = Release Infinality|Win32 + {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release Infinality|Win32.Build.0 = Release Infinality|Win32 + {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release Infinality|x64.ActiveCfg = Release Infinality|x64 + {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release Infinality|x64.Build.0 = Release Infinality|x64 {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release|Win32.ActiveCfg = Release|Win32 {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release|Win32.Build.0 = Release|Win32 {15C33FD9-0811-4981-B08F-E0BAD74A3028}.Release|x64.ActiveCfg = Release|x64 diff --git a/gdipp.vcxproj b/gdipp.vcxproj index ff78109..ce03632 100644 --- a/gdipp.vcxproj +++ b/gdipp.vcxproj @@ -1,6 +1,18 @@  + + Debug Infinality + ARM + + + Debug Infinality + Win32 + + + Debug Infinality + x64 + Debug ARM @@ -13,6 +25,18 @@ Debug x64 + + Release Infinality + ARM + + + Release Infinality + Win32 + + + Release Infinality + x64 + Release ARM @@ -39,54 +63,105 @@ Unicode true + + DynamicLibrary + v120_xp + Unicode + true + DynamicLibrary v120 Unicode + + DynamicLibrary + v120 + Unicode + DynamicLibrary v120_xp Unicode true + + DynamicLibrary + v120_xp + Unicode + true + DynamicLibrary v120_xp Unicode true + + DynamicLibrary + v120_xp + Unicode + true + DynamicLibrary v120 Unicode + + DynamicLibrary + v120 + Unicode + DynamicLibrary v120 Unicode + + DynamicLibrary + v120 + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>12.0.21005.1 @@ -100,6 +175,15 @@ D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) $(ProjectName).Core + + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + false + D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) + $(ProjectName).Core + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) $(SolutionDir)$(Platform)\$(Configuration)\ @@ -109,6 +193,15 @@ D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) $(ProjectName)64.Core + + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + false + D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) + $(ProjectName)64.Core + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) $(SolutionDir)$(Platform)\$(Configuration)\ @@ -118,6 +211,15 @@ D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) $(ProjectName)64.Core + + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + false + D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) + $(ProjectName)64.Core + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) $(SolutionDir)$(Configuration)\ @@ -128,6 +230,16 @@ C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x86;$(LibraryPath) $(ProjectName).Core + + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + false + D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) + C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x86;$(LibraryPath) + $(ProjectName).Core + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) $(SolutionDir)$(Platform)\$(Configuration)\ @@ -138,6 +250,16 @@ $(ProjectName)64.Core $(VC_LibraryPath_x64);C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64 + + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + false + D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) + $(ProjectName)64.Core + $(VC_LibraryPath_x64);C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64 + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) $(SolutionDir)$(Platform)\$(Configuration)\ @@ -148,6 +270,16 @@ $(ProjectName)64.Core $(VC_LibraryPath_x64);C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64 + + D:\Program Files\Microsoft Research\Detours Express 2.1\lib;$(ReferencePath) + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + false + D:\Archives\Documents\Visual Studio 2008\Projects\freetype\include;$(WinSDK)\um;$(WinSDK)\shared;C:\Users\Peace\Documents\Visual Studio 2013\Projects\IniParser\;$(IncludePath) + $(ProjectName)64.Core + $(VC_LibraryPath_x64);C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x64 + Disabled @@ -174,6 +306,33 @@ Easyhk32.dll + + + Disabled + Neither + false + false + WIN32;_DEBUG;_WINDOWS;_USRDLL;GDIPP_EXPORTS;_GDIPP_DLL;INFINALITY;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + freetype_inf.lib;usp10.lib;%(AdditionalDependencies) + LIBCMT;%(IgnoreSpecificDefaultLibraries) + expfunc.def + true + Windows + true + MachineX86 + /DEBUG + Easyhk32.dll + + X64 @@ -203,6 +362,36 @@ Easyhk64.dll + + + X64 + + + Disabled + Neither + false + false + WIN32;_DEBUG;_WINDOWS;_USRDLL;GDIPP_EXPORTS;_GDIPP_DLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + freetype64.lib;usp10.lib;%(AdditionalDependencies) + LIBCMT;%(IgnoreSpecificDefaultLibraries) + expfunc.def + true + Windows + true + MachineX64 + /DEBUG %(AdditionalOptions) + Easyhk64.dll + + @@ -230,6 +419,33 @@ Easyhk64.dll + + + + Disabled + Neither + false + false + WIN32;_DEBUG;_WINDOWS;_USRDLL;GDIPP_EXPORTS;_GDIPP_DLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + freetype64.lib;usp10.lib;%(AdditionalDependencies) + LIBCMT;%(IgnoreSpecificDefaultLibraries) + expfunc.def + true + Windows + true + /DEBUG %(AdditionalOptions) + Easyhk64.dll + + MaxSpeed @@ -261,6 +477,38 @@ Easyhk32.dll + + + MaxSpeed + true + Speed + false + WIN32;NDEBUG;_WINDOWS;_USRDLL;GDIPP_EXPORTS;_GDIPP_DLL;INFINALITY;%(PreprocessorDefinitions) + Sync + MultiThreaded + false + false + StreamingSIMDExtensions2 + Precise + + + Level3 + ProgramDatabase + + + freetype_inf.lib;usp10.lib;dwrite.lib;%(AdditionalDependencies) + false + expfunc.def + true + Windows + true + true + true + true + MachineX86 + Easyhk32.dll + + X64 @@ -293,6 +541,39 @@ Easyhk64.dll + + + X64 + + + MaxSpeed + true + Speed + NDEBUG;_WINDOWS;_USRDLL;GDIPP_EXPORTS;_GDIPP_DLL;INFINALITY;%(PreprocessorDefinitions) + Sync + MultiThreaded + false + true + StreamingSIMDExtensions2 + + + Level3 + ProgramDatabase + + + freetype64_inf.lib;usp10.lib;%(AdditionalDependencies) + false + expfunc.def + true + Windows + true + true + true + true + MachineX64 + Easyhk64.dll + + @@ -323,6 +604,36 @@ Easyhk64.dll + + + + MaxSpeed + true + Speed + NDEBUG;_WINDOWS;_USRDLL;GDIPP_EXPORTS;_GDIPP_DLL;%(PreprocessorDefinitions) + Sync + MultiThreaded + false + true + StreamingSIMDExtensions2 + + + Level3 + ProgramDatabase + + + freetype64.lib;usp10.lib;%(AdditionalDependencies) + false + expfunc.def + true + Windows + true + true + true + true + Easyhk64.dll + + @@ -340,6 +651,7 @@ Sync + Sync @@ -364,6 +676,7 @@ + diff --git a/gdipp.vcxproj.filters b/gdipp.vcxproj.filters index d1d6c8e..ef4f09a 100644 --- a/gdipp.vcxproj.filters +++ b/gdipp.vcxproj.filters @@ -151,6 +151,9 @@ Header Files + + Header Files + diff --git a/hook.cpp b/hook.cpp index ee79751..496b88b 100644 --- a/hook.cpp +++ b/hook.cpp @@ -24,6 +24,9 @@ #ifndef _WIN64 #include "wow64ext.h" #endif +#ifdef INFINALITY +#include +#endif #pragma comment(lib, "delayimp") HINSTANCE g_dllInstance; @@ -470,6 +473,10 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID lpReserved) //4 { +#ifdef INFINALITY + // enable infinality exclusive features + FT_initEnv(); +#endif CGdippSettings* pSettings = CGdippSettings::CreateInstance(); if (!pSettings || !pSettings->LoadSettings(instance)) { CGdippSettings::DestroyInstance(); @@ -563,6 +570,11 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID lpReserved) if (g_pFTEngine) { delete g_pFTEngine; } + +#ifdef INFINALITY + // enable infinality exclusive features + FT_freeEnv(); +#endif //if (g_alterGUIFont) // DeleteObject(g_alterGUIFont); FontLFree(); diff --git a/override.cpp b/override.cpp index f3736d6..659aa7e 100644 --- a/override.cpp +++ b/override.cpp @@ -487,7 +487,11 @@ DWORD WINAPI IMPL_GetGlyphOutlineW(__in HDC hdc, __in UINT uChar, __in UINT fuFo } else nDeltaY = 0; lpgm->gmptGlyphOrigin.y += nDeltaY; - + if (lpgm->gmptGlyphOrigin.x > 0) + lpgm->gmBlackBoxX += n; // increase blackbox width if it's not a ligature + if (lpgm->gmBlackBoxX > tm.tmMaxCharWidth) { + lpgm->gmBlackBoxX = tm.tmMaxCharWidth; + } lpgm->gmBlackBoxY += nDeltaY; if (tm.tmAscent - lpgm->gmptGlyphOrigin.y + lpgm->gmBlackBoxY - 1 < tm.tmHeight) // still has some room to scale up { @@ -526,6 +530,11 @@ DWORD WINAPI IMPL_GetGlyphOutlineA(__in HDC hdc, __in UINT uChar, __in UINT fuFo } } else nDeltaY = 0; + if (lpgm->gmptGlyphOrigin.x > 0) + lpgm->gmBlackBoxX += n; // increase blackbox width if it's not a ligature + if (lpgm->gmBlackBoxX > tm.tmMaxCharWidth) { + lpgm->gmBlackBoxX = tm.tmMaxCharWidth; + } lpgm->gmptGlyphOrigin.y += nDeltaY; lpgm->gmBlackBoxY += nDeltaY; diff --git a/settings.cpp b/settings.cpp index 8087967..9c336f2 100644 --- a/settings.cpp +++ b/settings.cpp @@ -4,6 +4,9 @@ #include "supinfo.h" #include "fteng.h" #include +#ifdef INFINALITY +#include +#endif CGdippSettings* CGdippSettings::s_pInstance; CParseIni CGdippSettings::m_Config; @@ -177,6 +180,30 @@ int CGdippSettings::_GetFreeTypeProfileIntFromSection(LPCTSTR lpszSection, LPCTS return nDefault; } +bool CGdippSettings::_GetFreeTypeProfileBoolFromSection(LPCTSTR lpszSection, LPCTSTR lpszKey, bool nDefault, LPCTSTR lpszFile) +{ + wstring names = wstring((LPTSTR)lpszSection) + _T("@") + wstring((LPTSTR)m_szexeName); + if (m_Config.IsPartExists(names.c_str()) && m_Config[names.c_str()].IsValueExists(lpszKey)) + return m_Config[names.c_str()][lpszKey].ToBool(); + else + if (m_Config[lpszSection].IsValueExists(lpszKey)) + return m_Config[lpszSection][lpszKey].ToBool(); + else + return nDefault; +} + +wstring CGdippSettings::_GetFreeTypeProfileStrFromSection(LPCTSTR lpszSection, LPCTSTR lpszKey, const TCHAR* nDefault, LPCTSTR lpszFile) +{ + wstring names = wstring((LPTSTR)lpszSection) + _T("@") + wstring((LPTSTR)m_szexeName); + if (m_Config.IsPartExists(names.c_str()) && m_Config[names.c_str()].IsValueExists(lpszKey)) + return m_Config[names.c_str()][lpszKey].ToString(); + else + if (m_Config[lpszSection].IsValueExists(lpszKey)) + return m_Config[lpszSection][lpszKey].ToString(); + else + return nDefault; +} + int CGdippSettings::_GetFreeTypeProfileInt(LPCTSTR lpszKey, int nDefault, LPCTSTR lpszFile) { int ret = _GetFreeTypeProfileIntFromSection(c_szFreeType, lpszKey, nDefault, lpszFile); @@ -461,6 +488,52 @@ SKIP: //experimental settings: m_bEnableClipBoxFix = !!_GetFreeTypeProfileIntFromSection(_T("Experimental"), _T("ClipBoxFix"), 1, lpszFile); +#ifdef INFINALITY + // define some macros +#define INF_INT_ENV(y, def) \ + nTemp = _GetFreeTypeProfileIntFromSection(_T("Infinality"), _T(y), def, lpszFile); \ + FT_PutEnv(y, _ltoa(nTemp, buff, 10)); +#define INF_BOOL_ENV(y, def) \ + bTemp = _GetFreeTypeProfileBoolFromSection(_T("Infinality"), _T(y), def, lpszFile); \ + FT_PutEnv(y, bTemp?"true":"false"); +#define INF_STR_ENV(y, def) \ + sTemp = _GetFreeTypeProfileStrFromSection(_T("Infinality"), _T(y), def, lpszFile); \ + FT_PutEnv(y, WstringToString(sTemp).c_str()); + + char* buff = (char*)malloc(256); + int nTemp; bool bTemp; wstring sTemp; + + // INFINALITY settings: + INF_INT_ENV( "INFINALITY_FT_CHROMEOS_STYLE_SHARPENING_STRENGTH", 0); + INF_INT_ENV( "INFINALITY_FT_CONTRAST", 0); + INF_INT_ENV( "INFINALITY_FT_STEM_FITTING_STRENGTH", 25); + INF_INT_ENV( "INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT", 100); + INF_INT_ENV( "INFINALITY_FT_GRAYSCALE_FILTER_STRENGTH", 0); + INF_INT_ENV( "INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH", 20); + INF_INT_ENV( "INFINALITY_FT_BRIGHTNESS", 0); + INF_INT_ENV( "INFINALITY_FT_AUTOHINT_HORIZONTAL_STEM_DARKEN_STRENGTH", 10); + INF_INT_ENV( "INFINALITY_FT_STEM_ALIGNMENT_STRENGTH", 25); + INF_INT_ENV( "INFINALITY_FT_AUTOHINT_VERTICAL_STEM_DARKEN_STRENGTH", 25); + INF_INT_ENV( "INFINALITY_FT_FRINGE_FILTER_STRENGTH", 0); + INF_INT_ENV("INFINALITY_FT_GLOBAL_EMBOLDEN_X_VALUE", 0); + INF_INT_ENV("INFINALITY_FT_GLOBAL_EMBOLDEN_Y_VALUE", 0); + INF_INT_ENV("INFINALITY_FT_BOLD_EMBOLDEN_X_VALUE", 0); + INF_INT_ENV("INFINALITY_FT_BOLD_EMBOLDEN_Y_VALUE", 0); + INF_INT_ENV("INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE", 0); + + INF_BOOL_ENV("INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS", true); + INF_BOOL_ENV( "INFINALITY_FT_AUTOFIT_ADJUST_HEIGHTS", true); + INF_BOOL_ENV( "INFINALITY_FT_USE_VARIOUS_TWEAKS", true); + INF_BOOL_ENV( "INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS", true); + INF_BOOL_ENV( "INFINALITY_FT_STEM_DARKENING_CFF", true); + INF_BOOL_ENV( "INFINALITY_FT_STEM_DARKENING_AUTOFIT", true); + + INF_STR_ENV( "INFINALITY_FT_GAMMA_CORRECTION", _T("0 100")); + INF_STR_ENV( "INFINALITY_FT_FILTER_PARAMS", _T("11 22 38 22 11")); + + free(buff); +#endif + if (m_nFontLoader == SETTING_FONTLOADER_WIN32) { // APIĂ͂Ȃ̂ŎO͖ if (m_nFontSubstitutes == SETTING_FONTSUBSTITUTE_ALL) { diff --git a/settings.h b/settings.h index 6d9450d..09cb6a9 100644 --- a/settings.h +++ b/settings.h @@ -289,6 +289,7 @@ private: //settings for experimental bool m_bEnableClipBoxFix; + //settings for directwrite float m_fGammaValueForDW; float m_fContrastForDW; @@ -335,6 +336,8 @@ private: 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 bool _GetFreeTypeProfileBoolFromSection(LPCTSTR lpszSection, LPCTSTR lpszKey, bool nDefault, LPCTSTR lpszFile); + static wstring _GetFreeTypeProfileStrFromSection(LPCTSTR lpszSection, LPCTSTR lpszKey, const TCHAR* 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);