From 3187767cfd50ba5bdf4f04cef7bdf3cfe7f8c50b Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Fri, 29 Oct 2021 14:10:55 +0200 Subject: [PATCH] Address Mike's comments --- src/renderer/base/FontInfoBase.cpp | 14 +++++++++++--- src/renderer/base/FontInfoDesired.cpp | 10 ++++++++-- src/renderer/base/fontinfo.cpp | 19 ++++++++++++++++--- src/renderer/inc/FontInfo.hpp | 14 ++++++++++++-- src/renderer/inc/FontInfoBase.hpp | 11 +++++++++-- src/renderer/inc/FontInfoDesired.hpp | 6 +++++- 6 files changed, 61 insertions(+), 13 deletions(-) diff --git a/src/renderer/base/FontInfoBase.cpp b/src/renderer/base/FontInfoBase.cpp index 5abe478b828..c95abf08dea 100644 --- a/src/renderer/base/FontInfoBase.cpp +++ b/src/renderer/base/FontInfoBase.cpp @@ -7,7 +7,11 @@ #include "../inc/FontInfoBase.hpp" -FontInfoBase::FontInfoBase(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const bool fSetDefaultRasterFont, const unsigned int codePage) noexcept : +FontInfoBase::FontInfoBase(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const bool fSetDefaultRasterFont, + const unsigned int codePage) noexcept : _faceName(faceName), _family(family), _weight(weight), @@ -68,7 +72,10 @@ void FontInfoBase::FillLegacyNameBuffer(wchar_t (&buffer)[LF_FACESIZE]) const no } // NOTE: this method is intended to only be used from the engine itself to respond what font it has chosen. -void FontInfoBase::SetFromEngine(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const bool fSetDefaultRasterFont) noexcept +void FontInfoBase::SetFromEngine(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const bool fSetDefaultRasterFont) noexcept { _faceName = faceName; _family = family; @@ -92,7 +99,8 @@ void FontInfoBase::ValidateFont() noexcept if (_faceName == DEFAULT_TT_FONT_FACENAME) { std::wstring defaultFontFace; - if (SUCCEEDED(s_pFontDefaultList->RetrieveDefaultFontNameForCodepage(GetCodePage(), defaultFontFace))) + if (SUCCEEDED(s_pFontDefaultList->RetrieveDefaultFontNameForCodepage(GetCodePage(), + defaultFontFace))) { _faceName = defaultFontFace; diff --git a/src/renderer/base/FontInfoDesired.cpp b/src/renderer/base/FontInfoDesired.cpp index 027b68f2db9..900648ad69b 100644 --- a/src/renderer/base/FontInfoDesired.cpp +++ b/src/renderer/base/FontInfoDesired.cpp @@ -5,7 +5,11 @@ #include "../inc/FontInfoDesired.hpp" -FontInfoDesired::FontInfoDesired(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const COORD coordSizeDesired, const unsigned int codePage) noexcept : +FontInfoDesired::FontInfoDesired(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const COORD coordSizeDesired, + const unsigned int codePage) noexcept : FontInfoBase(faceName, family, weight, false, codePage), _coordSizeDesired(coordSizeDesired) { @@ -41,5 +45,7 @@ bool FontInfoDesired::IsDefaultRasterFont() const noexcept { // Either the raster was set from the engine... // OR the face name is empty with a size of 0x0 or 8x12. - return WasDefaultRasterSetFromEngine() || (GetFaceName().empty() && (_coordSizeDesired == COORD{ 0, 0 } || _coordSizeDesired == COORD{ 8, 12 })); + return WasDefaultRasterSetFromEngine() || (GetFaceName().empty() && + (_coordSizeDesired == COORD{ 0, 0 } || + _coordSizeDesired == COORD{ 8, 12 })); } diff --git a/src/renderer/base/fontinfo.cpp b/src/renderer/base/fontinfo.cpp index 42ae41eb9b8..c73326c0852 100644 --- a/src/renderer/base/fontinfo.cpp +++ b/src/renderer/base/fontinfo.cpp @@ -5,7 +5,12 @@ #include "../inc/FontInfo.hpp" -FontInfo::FontInfo(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const COORD coordSize, const unsigned int codePage, const bool fSetDefaultRasterFont) noexcept : +FontInfo::FontInfo(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const COORD coordSize, + const unsigned int codePage, + const bool fSetDefaultRasterFont /* = false */) noexcept : FontInfoBase(faceName, family, weight, fSetDefaultRasterFont, codePage), _coordSize(coordSize), _coordSizeUnscaled(coordSize), @@ -31,9 +36,17 @@ COORD FontInfo::GetSize() const noexcept return _coordSize; } -void FontInfo::SetFromEngine(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const bool fSetDefaultRasterFont, const COORD coordSize, const COORD coordSizeUnscaled) noexcept +void FontInfo::SetFromEngine(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const bool fSetDefaultRasterFont, + const COORD coordSize, + const COORD coordSizeUnscaled) noexcept { - FontInfoBase::SetFromEngine(faceName, family, weight, fSetDefaultRasterFont); + FontInfoBase::SetFromEngine(faceName, + family, + weight, + fSetDefaultRasterFont); _coordSize = coordSize; _coordSizeUnscaled = coordSizeUnscaled; _ValidateCoordSize(); diff --git a/src/renderer/inc/FontInfo.hpp b/src/renderer/inc/FontInfo.hpp index bd3102fd2d9..2b5ee35640a 100644 --- a/src/renderer/inc/FontInfo.hpp +++ b/src/renderer/inc/FontInfo.hpp @@ -28,13 +28,23 @@ Author(s): class FontInfo : public FontInfoBase { public: - FontInfo(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const COORD coordSize, const unsigned int codePage, const bool fSetDefaultRasterFont = false) noexcept; + FontInfo(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const COORD coordSize, + const unsigned int codePage, + const bool fSetDefaultRasterFont = false) noexcept; bool operator==(const FontInfo& other) noexcept; COORD GetSize() const noexcept; COORD GetUnscaledSize() const noexcept; - void SetFromEngine(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const bool fSetDefaultRasterFont, const COORD coordSize, const COORD coordSizeUnscaled) noexcept; + void SetFromEngine(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const bool fSetDefaultRasterFont, + const COORD coordSize, + const COORD coordSizeUnscaled) noexcept; bool GetFallback() const noexcept; void SetFallback(const bool didFallback) noexcept; void ValidateFont() noexcept; diff --git a/src/renderer/inc/FontInfoBase.hpp b/src/renderer/inc/FontInfoBase.hpp index 292b6d6f2f0..2ef5478f84d 100644 --- a/src/renderer/inc/FontInfoBase.hpp +++ b/src/renderer/inc/FontInfoBase.hpp @@ -26,7 +26,11 @@ static constexpr wchar_t DEFAULT_RASTER_FONT_FACENAME[]{ L"Terminal" }; class FontInfoBase { public: - FontInfoBase(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const bool fSetDefaultRasterFont, const unsigned int uiCodePage) noexcept; + FontInfoBase(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const bool fSetDefaultRasterFont, + const unsigned int uiCodePage) noexcept; bool operator==(const FontInfoBase& other) noexcept; @@ -36,7 +40,10 @@ class FontInfoBase unsigned int GetCodePage() const noexcept; void FillLegacyNameBuffer(wchar_t (&buffer)[LF_FACESIZE]) const noexcept; bool IsTrueTypeFont() const noexcept; - void SetFromEngine(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const bool fSetDefaultRasterFont) noexcept; + void SetFromEngine(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const bool fSetDefaultRasterFont) noexcept; bool WasDefaultRasterSetFromEngine() const noexcept; void ValidateFont() noexcept; diff --git a/src/renderer/inc/FontInfoDesired.hpp b/src/renderer/inc/FontInfoDesired.hpp index 2157162afc2..44e5858192e 100644 --- a/src/renderer/inc/FontInfoDesired.hpp +++ b/src/renderer/inc/FontInfoDesired.hpp @@ -24,7 +24,11 @@ Author(s): class FontInfoDesired : public FontInfoBase { public: - FontInfoDesired(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, const COORD coordSizeDesired, const unsigned int uiCodePage) noexcept; + FontInfoDesired(const std::wstring_view& faceName, + const unsigned char family, + const unsigned int weight, + const COORD coordSizeDesired, + const unsigned int uiCodePage) noexcept; FontInfoDesired(const FontInfo& fiFont) noexcept; bool operator==(const FontInfoDesired& other) noexcept;