From 22ae442f8739ada0fb25a54e44b10145b66f4877 Mon Sep 17 00:00:00 2001 From: elasota Date: Thu, 15 Apr 2021 20:08:16 -0400 Subject: [PATCH] Handle preinstalled fonts case --- PortabilityLayer/FontManager.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/PortabilityLayer/FontManager.cpp b/PortabilityLayer/FontManager.cpp index 1ac9a5e..d8aba39 100644 --- a/PortabilityLayer/FontManager.cpp +++ b/PortabilityLayer/FontManager.cpp @@ -6,6 +6,7 @@ #include "GpIOStream.h" #include "IGpFileSystem.h" #include "IGpFont.h" +#include "IGpSystemServices.h" #include "MemReaderStream.h" #include "PLBigEndian.h" @@ -130,6 +131,8 @@ namespace PortabilityLayer void FontManagerImpl::GetFontPreset(FontPreset_t preset, FontFamilyID_t *outFamilyID, int *outSize, int *outVariationFlags, bool *outAA) const { + const bool preinstalledFonts = PLDrivers::GetSystemServices()->IsUsingPreinstalledFonts(); + if (outSize) *outSize = ms_fontPresets[preset].m_textSize; @@ -137,14 +140,22 @@ namespace PortabilityLayer *outVariationFlags = ms_fontPresets[preset].m_variationFlags; if (outAA) - *outAA = ms_fontPresets[preset].m_aa; + { + bool aa = ms_fontPresets[preset].m_aa; + FontFamilyID_t fontFamily = ms_fontPresets[preset].m_familyID; + + if (preinstalledFonts && (fontFamily == FontFamilyIDs::kApplication || fontFamily == FontFamilyIDs::kSystem)) + *outAA = false; + else + *outAA = aa; + } if (outFamilyID) { switch (ms_fontPresets[preset].m_familyID) { case FontFamilyIDs::kApplication: - if (ms_fontPresets[preset].m_textSize < 11 && (ms_fontPresets[preset].m_variationFlags & FontFamilyFlag_Bold) != 0) + if (!preinstalledFonts && ms_fontPresets[preset].m_textSize < 11 && (ms_fontPresets[preset].m_variationFlags & FontFamilyFlag_Bold) != 0) *outFamilyID = FontFamilyIDs::kSystem; // Use heavier font below 11pt else *outFamilyID = FontFamilyIDs::kApplication;