From 5ebda1fec7c32aa209027d7d196af9115c29c4d3 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 16 Sep 2023 01:11:03 +0200 Subject: [PATCH] allow to specify min size for anti-aliased fonts --- src/config.c | 2 +- src/winapi_hooks.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/config.c b/src/config.c index 6498ac5..c8e3bce 100644 --- a/src/config.c +++ b/src/config.c @@ -367,7 +367,7 @@ static void cfg_create_ini() "rgb555=false\n" "no_dinput_hook=false\n" "refresh_rate=0\n" - "non_anti_aliased_fonts=true\n" + "anti_aliased_fonts_min_size=13\n" "custom_width=0\n" "custom_height=0\n" "min_font_size=0\n" diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 6c956bb..3b0ec4c 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -910,7 +910,15 @@ HFONT WINAPI fake_CreateFontIndirectA(CONST LOGFONTA* lplf) LOGFONTA lf; memcpy(&lf, lplf, sizeof(lf)); - if (cfg_get_bool("non_anti_aliased_fonts", TRUE)) + int minFontSize = cfg_get_int("min_font_size", 0); + if (lf.lfHeight < 0) { + lf.lfHeight = min(-minFontSize, lf.lfHeight); + } + else { + lf.lfHeight = max(minFontSize, lf.lfHeight); + } + + if (cfg_get_int("anti_aliased_fonts_min_size", 13) > abs(lf.lfHeight)) lf.lfQuality = NONANTIALIASED_QUALITY; return real_CreateFontIndirectA(&lf); @@ -932,9 +940,6 @@ HFONT WINAPI fake_CreateFontA( DWORD fdwPitchAndFamily, LPCTSTR lpszFace) { - if (cfg_get_bool("non_anti_aliased_fonts", TRUE)) - fdwQuality = NONANTIALIASED_QUALITY; - int minFontSize = cfg_get_int("min_font_size", 0); if (nHeight < 0) { nHeight = min(-minFontSize, nHeight); @@ -943,6 +948,9 @@ HFONT WINAPI fake_CreateFontA( nHeight = max(minFontSize, nHeight); } + if (cfg_get_int("anti_aliased_fonts_min_size", 13) > abs(nHeight)) + fdwQuality = NONANTIALIASED_QUALITY; + return real_CreateFontA( nHeight,