Skip to content

Commit

Permalink
Address Mike's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed Oct 29, 2021
1 parent 1ede43f commit 3187767
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 13 deletions.
14 changes: 11 additions & 3 deletions src/renderer/base/FontInfoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down
10 changes: 8 additions & 2 deletions src/renderer/base/FontInfoDesired.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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 }));
}
19 changes: 16 additions & 3 deletions src/renderer/base/fontinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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();
Expand Down
14 changes: 12 additions & 2 deletions src/renderer/inc/FontInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/inc/FontInfoBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion src/renderer/inc/FontInfoDesired.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3187767

Please sign in to comment.