95cc7d9625
FontInfoBase and it's descendents are missing noexcept annotations, which virally forces other code to not be noexcept as well during AuditMode checks. Apart from adding noexcept, this commit also * Passes std::wstring_view by reference. * Pass the FillLegacyNameBuffer argument as a simple pointer-to-array, allowing us to fill the buffer with a single memcpy. (gsl::span's iterators inhibit any internal STL optimizations.) * Move operator== declarations inside the class to reduce code size. All other changes are an effect of the virality of noexcept. This is an offshoot from #11623. ## Validation Steps Performed * It still compiles ✔️
52 lines
1.9 KiB
C++
52 lines
1.9 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include "precomp.h"
|
|
|
|
#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 :
|
|
FontInfoBase(faceName, family, weight, false, codePage),
|
|
_coordSizeDesired(coordSizeDesired)
|
|
{
|
|
}
|
|
|
|
FontInfoDesired::FontInfoDesired(const FontInfo& fiFont) noexcept :
|
|
FontInfoBase(fiFont),
|
|
_coordSizeDesired(fiFont.GetUnscaledSize())
|
|
{
|
|
}
|
|
|
|
bool FontInfoDesired::operator==(const FontInfoDesired& other) noexcept
|
|
{
|
|
return FontInfoBase::operator==(other) &&
|
|
_coordSizeDesired == other._coordSizeDesired;
|
|
}
|
|
|
|
COORD FontInfoDesired::GetEngineSize() const noexcept
|
|
{
|
|
COORD coordSize = _coordSizeDesired;
|
|
if (IsTrueTypeFont())
|
|
{
|
|
coordSize.X = 0; // Don't tell the engine about the width for a TrueType font. It makes a mess.
|
|
}
|
|
|
|
return coordSize;
|
|
}
|
|
|
|
// This helper determines if this object represents the default raster font. This can either be because internally we're
|
|
// using the empty facename and zeros for size, weight, and family, or it can be because we were given explicit
|
|
// dimensions from the engine that were the result of loading the default raster font. See GdiEngine::_GetProposedFont().
|
|
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 }));
|
|
}
|