diff --git a/ft.cpp b/ft.cpp index 500f9ae..61df7cf 100644 --- a/ft.cpp +++ b/ft.cpp @@ -3339,32 +3339,6 @@ BOOL FontLInit(void) { return FALSE; } - const int nLcdFilter = pSettings->LcdFilter(); - if ((int)FT_LCD_FILTER_NONE < nLcdFilter && nLcdFilter < (int)FT_LCD_FILTER_MAX) { - FT_Library_SetLcdFilter(freetype_library, (FT_LcdFilter)nLcdFilter); - if (pSettings->UseCustomLcdFilter()) - { - unsigned char buff[5]; - memcpy(buff, pSettings->LcdFilterWeights(), sizeof(buff)); - FT_Library_SetLcdFilterWeights(freetype_library, buff); - } - else - switch (nLcdFilter) - { - case FT_LCD_FILTER_NONE: - case FT_LCD_FILTER_DEFAULT: - case FT_LCD_FILTER_LEGACY: - { - FT_Library_SetLcdFilterWeights(freetype_library, - (unsigned char*)"\x00\x55\x56\x55\x00"); - break; - } - case FT_LCD_FILTER_LIGHT: - default: - FT_Library_SetLcdFilterWeights(freetype_library, - (unsigned char*)"\x10\x40\x70\x40\x10"); - } - } //s_AlphaBlendTable.init(); s_AlphaBlendTable.initRGB(); diff --git a/gdidll.rc b/gdidll.rc index 76bdad5..f24b9c6 100644 --- a/gdidll.rc +++ b/gdidll.rc @@ -1,7 +1,7 @@ // Microsoft Visual C++ generated resource script. // -#pragma code_page(65001) - +#pragma code_page(65001) + #include "resource." #define APSTUDIO_READONLY_SYMBOLS @@ -9,7 +9,8 @@ // // Generated from the TEXTINCLUDE 2 resource. // -//#include "afxres.h" ///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -24,8 +25,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,2021,507,1 - PRODUCTVERSION 1,2021,5,7 + FILEVERSION 1,2022,720,1 + PRODUCTVERSION 1,2022,720,1 FILEFLAGSMASK 0x8L #ifdef _DEBUG FILEFLAGS 0xbL @@ -43,12 +44,12 @@ BEGIN VALUE "Comments", "Portions of this software are copyright (c) 2005-2021 The FreeType Project (www.freetype.org). All rights reserved." VALUE "CompanyName", "2ch & THEMEX & everyone" VALUE "FileDescription", "The Ultimate Font Rasterizer" - VALUE "FileVersion", "1.2021.507.1" + VALUE "FileVersion", "1.2022.720.1" VALUE "InternalName", "MacType" VALUE "LegalCopyright", "(C) 460, 168, Higambana, 555 and sy567. All rights reserved. FlyingSnow republished" VALUE "OriginalFilename", "MacType.dll" VALUE "ProductName", "The Ultimate Font Rasterizer" - VALUE "ProductVersion", "1.2021.5.7" + VALUE "ProductVersion", "1.2022.720.1" VALUE "URL", "http://www.mactype.net http://drwatson.nobody.jp/gdi++/" END END @@ -63,7 +64,7 @@ END ///////////////////////////////////////////////////////////////////////////// -// Chinese (Simplified, PRC) resources +// Chinese (Simplified, China) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED @@ -91,7 +92,7 @@ END #endif // APSTUDIO_INVOKED -#endif // Chinese (Simplified, PRC) resources +#endif // Chinese (Simplified, China) resources ///////////////////////////////////////////////////////////////////////////// @@ -101,6 +102,7 @@ END // // Generated from the TEXTINCLUDE 3 resource. // - ///////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/settings.cpp b/settings.cpp index 1bc9a89..c8ffa14 100644 --- a/settings.cpp +++ b/settings.cpp @@ -43,7 +43,7 @@ static const TCHAR c_szDirectWrite[] = _T("DirectWrite"); #define HINTING_MIN 0 #define HINTING_MAX 2 #define AAMODE_MIN -1 -#define AAMODE_MAX 5 +#define AAMODE_MAX 6 #define GAMMAVALUE_MIN 0.0625f #define GAMMAVALUE_MAX 20.0f #define CONTRAST_MIN 0.0625f @@ -174,6 +174,62 @@ void CGdippSettings::DelayedInit() m_fontlinkinfo.init(); } + // Init LCD settings + this->m_bHarmonyLCDRendering = FT_Library_SetLcdFilter(NULL, FT_LCD_FILTER_NONE) == FT_Err_Unimplemented_Feature; + if (this->m_bHarmonyLCDRendering) { + // Harmony LCD rendering + switch (this->m_FontSettings.GetAntiAliasMode()) { + case 0: + case 1: { + FT_Vector sub[3] = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; // gray scale + FT_Library_SetLcdGeometry(freetype_library, sub); + break; + } + case 2: //RGB + case 4: { + FT_Vector sub[3] = { { -21, 0 }, { 0, 0 }, { 0, 21 } }; + FT_Library_SetLcdGeometry(freetype_library, sub); + break; + } + case 3: //BGR + case 5: { + FT_Vector sub[3] = { { 21, 0 }, { 0, 0 }, { 0, -21 } }; + FT_Library_SetLcdGeometry(freetype_library, sub); + this->m_FontSettings.SetAntiAliasMode(2); + break; + } + case 6: { + //Pentile + FT_Vector sub[3] = { {-11, 16}, {-11, -16}, {22, 0} }; + FT_Library_SetLcdGeometry(freetype_library, sub); + this->m_FontSettings.SetAntiAliasMode(2); + break; + } + case 7: { + // TODO: custom pixel arrangement support + this->m_FontSettings.SetAntiAliasMode(2); + } + } + } + else { + int nLcdFilter = LcdFilter(); + if ((int)FT_LCD_FILTER_NONE < nLcdFilter && nLcdFilter < (int)FT_LCD_FILTER_MAX) { + switch (GetFontSettings().GetAntiAliasMode()) { + case 1: + case 4: + case 5: + nLcdFilter = FT_LCD_FILTER_LIGHT; // now we apply a light filter to lcd based on AA mode automatically, unless a custom lcd filter is defined. + } + FT_Library_SetLcdFilter(freetype_library, (FT_LcdFilter)nLcdFilter); + if (UseCustomLcdFilter()) + { + unsigned char buff[5]; + memcpy(buff, LcdFilterWeights(), sizeof(buff)); + FT_Library_SetLcdFilterWeights(freetype_library, buff); + } + } + } + //強制フォント /* @@ -1113,7 +1169,10 @@ const CFontSettings& CGdippSettings::FindIndividual(LPCTSTR lpFaceName) const for(; p != end; ++p) { if (p->GetHash() == hash) { - return p->GetIndividual(); + CFontSettings& individual = p->GetIndividual(); + if (this->m_bHarmonyLCDRendering && individual.GetAntiAliasMode() > 1) + individual.SetAntiAliasMode(2); + return individual; } } return GetFontSettings(); diff --git a/settings.h b/settings.h index 63fe638..56ac716 100644 --- a/settings.h +++ b/settings.h @@ -270,6 +270,7 @@ class CGdippSettings // bool m_bHaveNewerFreeType : 1; bool : 0; bool m_bUseCustomLcdFilter; //使用自定义lcdfilter + bool m_bHarmonyLCDRendering; BOOL m_bHintSmallFont; BOOL m_bDirectWrite; @@ -286,6 +287,7 @@ class CGdippSettings int m_nFontSubstitutes; int m_bFontLink; //改为可以使用多种参数 int m_nWidthMode; + int m_nFontLoader; int m_nScreenDpi; // screen dpi DWORD m_nShadowLightColor; @@ -400,6 +402,7 @@ class CGdippSettings , m_bHintSmallFont(true) , m_bDirectWrite(true) , m_nScreenDpi(96) + , m_bHarmonyLCDRendering(false) { ZeroMemory(m_nTuneTable, sizeof(m_nTuneTable)); ZeroMemory(m_nTuneTableR, sizeof(m_nTuneTableR)); @@ -454,6 +457,7 @@ class CGdippSettings int LcdFilter() const { return m_nLcdFilter; } const unsigned char* LcdFilterWeights() const { return m_arrLcdFilterWeights; } bool UseCustomLcdFilter() const { return m_bUseCustomLcdFilter; } + int PixelMode() const { return m_nPixelMode; } int WidthMode() const { return m_nWidthMode; } int FontLoader() const { return m_nFontLoader; } bool EnableClipBoxFix() const { return m_bEnableClipBoxFix; }