mirror of
https://github.com/snowie2000/mactype.git
synced 2025-01-05 10:17:02 +08:00
enable to use custom lcd filter in our customized freetype.
Cleartype rendering and harmony lcd rendering can now be switched on the fly. fixed lcd filter reloading via ControlCenter interface. moved UpdateLcdFilter from ft.cpp to settings.h.
This commit is contained in:
parent
585d48450e
commit
588ea2717f
33
ft.cpp
33
ft.cpp
@ -3364,36 +3364,3 @@ void RefreshAlphaTable()
|
||||
{
|
||||
s_AlphaBlendTable.init();
|
||||
}
|
||||
|
||||
void UpdateLcdFilter()
|
||||
{
|
||||
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
|
||||
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*)"\x10\x40\x70\x40\x10" );
|
||||
break;
|
||||
}
|
||||
case FT_LCD_FILTER_LIGHT:
|
||||
default:
|
||||
FT_Library_SetLcdFilterWeights(freetype_library,
|
||||
(unsigned char*)"\x00\x55\x56\x55\x00" );
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
1
ft.h
1
ft.h
@ -404,6 +404,5 @@ BOOL FreeTypeGetGlyph( // Get all the glyphs and widths needed.
|
||||
FT_DRAW_STATE* drState
|
||||
);
|
||||
void RefreshAlphaTable();
|
||||
void UpdateLcdFilter();
|
||||
|
||||
#endif
|
||||
|
10
gdidll.rc
10
gdidll.rc
@ -9,7 +9,7 @@
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
|
||||
#include "afxres.h"
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
@ -25,8 +25,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,2022,720,1
|
||||
PRODUCTVERSION 1,2022,720,1
|
||||
FILEVERSION 1,2022,810,1
|
||||
PRODUCTVERSION 1,2022,810,1
|
||||
FILEFLAGSMASK 0x8L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0xbL
|
||||
@ -44,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.2022.720.1"
|
||||
VALUE "FileVersion", "1.2022.810.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.2022.720.1"
|
||||
VALUE "ProductVersion", "1.2022.810.1"
|
||||
VALUE "URL", "http://www.mactype.net http://drwatson.nobody.jp/gdi++/"
|
||||
END
|
||||
END
|
||||
|
11
settings.cpp
11
settings.cpp
@ -4,6 +4,7 @@
|
||||
#include "supinfo.h"
|
||||
#include "fteng.h"
|
||||
#include <stdlib.h>
|
||||
#include <freetype/ftmodapi.h>
|
||||
#ifdef INFINALITY
|
||||
#include <freetype/ftenv.h>
|
||||
#endif
|
||||
@ -174,9 +175,13 @@ void CGdippSettings::DelayedInit()
|
||||
m_fontlinkinfo.init();
|
||||
}
|
||||
|
||||
// check wheteher harmony LCD should be used over ClearType
|
||||
FT_LCDMode_Set(freetype_library, this->HarmonyLCD() ? 1 : 0);
|
||||
|
||||
// Init LCD settings
|
||||
this->m_bHarmonyLCDRendering = FT_Library_SetLcdFilter(NULL, FT_LCD_FILTER_NONE) == FT_Err_Unimplemented_Feature;
|
||||
if (this->m_bHarmonyLCDRendering) {
|
||||
// this->m_bHarmonyLCDRendering = FT_Library_SetLcdFilter(NULL, FT_LCD_FILTER_NONE) == FT_Err_Unimplemented_Feature; // official method of detecting freetype mode.
|
||||
if (this->HarmonyLCD()) {
|
||||
FT_Library_SetLcdFilter(NULL, FT_LCD_FILTER_NONE);
|
||||
// Harmony LCD rendering
|
||||
if (m_bUseCustomPixelLayout) {
|
||||
FT_Vector sub[3] = { { m_arrPixelLayout[0], m_arrPixelLayout[1]},
|
||||
@ -217,7 +222,7 @@ void CGdippSettings::DelayedInit()
|
||||
}
|
||||
else {
|
||||
int nLcdFilter = LcdFilter();
|
||||
if ((int)FT_LCD_FILTER_NONE < nLcdFilter && nLcdFilter < (int)FT_LCD_FILTER_MAX) {
|
||||
if ((int)FT_LCD_FILTER_NONE <= nLcdFilter && nLcdFilter < (int)FT_LCD_FILTER_MAX) {
|
||||
switch (GetFontSettings().GetAntiAliasMode()) {
|
||||
case 1:
|
||||
case 4:
|
||||
|
47
settings.h
47
settings.h
@ -5,6 +5,7 @@
|
||||
#include "cache.h"
|
||||
#include "hash_list.h"
|
||||
#include <VersionHelpers.h>
|
||||
#include <freetype/ftmodapi.h>
|
||||
#include <IniParser/ParseIni.h>
|
||||
#include "json.hpp"
|
||||
#include <thread>
|
||||
@ -271,7 +272,6 @@ private:
|
||||
bool : 0;
|
||||
bool m_bUseCustomLcdFilter; // use custom lcdfilter
|
||||
bool m_bUseCustomPixelLayout;
|
||||
bool m_bHarmonyLCDRendering;
|
||||
|
||||
BOOL m_bHintSmallFont;
|
||||
BOOL m_bDirectWrite;
|
||||
@ -407,7 +407,7 @@ private:
|
||||
, m_bHintSmallFont(true)
|
||||
, m_bDirectWrite(true)
|
||||
, m_nScreenDpi(96)
|
||||
, m_bHarmonyLCDRendering(false)
|
||||
, m_bUseCustomPixelLayout(false)
|
||||
{
|
||||
ZeroMemory(m_nTuneTable, sizeof(m_nTuneTable));
|
||||
ZeroMemory(m_nTuneTableR, sizeof(m_nTuneTableR));
|
||||
@ -444,7 +444,8 @@ public:
|
||||
int BolderMode() const { return m_nBolderMode; }
|
||||
int GammaMode() const { return m_nGammaMode; }
|
||||
float GammaValue() const { return m_fGammaValue; }
|
||||
bool HarmonyLCD() const { return m_bHarmonyLCDRendering; }
|
||||
// Only fallback to tranditional ClearType mode when Custom LCD Filter is defined, and pixelLayout is not defined and AAMode is not in pentile.
|
||||
bool HarmonyLCD() const { return m_bUseCustomPixelLayout || m_FontSettings.GetAntiAliasMode() == 6 || !m_bUseCustomLcdFilter; }
|
||||
|
||||
//DW options
|
||||
float GammaValueForDW() const { return m_fGammaValueForDW; }
|
||||
@ -609,6 +610,44 @@ public:
|
||||
return result;
|
||||
}
|
||||
ULONG WINAPI GetVersion(void){ return MACTYPE_VERSION; };
|
||||
static void UpdateLcdFilter()
|
||||
{
|
||||
const CGdippSettings* pSettings = CGdippSettings::GetInstance();
|
||||
if (pSettings->HarmonyLCD()) {
|
||||
FT_LCDMode_Set(freetype_library, 1);
|
||||
return;
|
||||
}
|
||||
FT_LCDMode_Set(freetype_library, 0);
|
||||
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*)"\x10\x40\x70\x40\x10" );
|
||||
break;
|
||||
}
|
||||
case FT_LCD_FILTER_LIGHT:
|
||||
default:
|
||||
FT_Library_SetLcdFilterWeights(freetype_library,
|
||||
(unsigned char*)"\x00\x55\x56\x55\x00" );
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI SetIntAttribute(int eSet, int nValue)
|
||||
{
|
||||
CGdippSettings* pSettings = CGdippSettings::GetInstance();
|
||||
@ -638,7 +677,7 @@ public:
|
||||
break;
|
||||
case ATTR_LcdFilter:
|
||||
pSettings->m_nLcdFilter = nValue;
|
||||
FT_Library_SetLcdFilter(freetype_library, (FT_LcdFilter)nValue);
|
||||
UpdateLcdFilter();
|
||||
break;
|
||||
case ATTR_BolderMode:
|
||||
pSettings->m_nBolderMode = nValue;
|
||||
|
Loading…
Reference in New Issue
Block a user