diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index e60b1151268..19742372e2d 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -244,7 +244,7 @@ "default": 12, "description": "Size of the font in points.", "minimum": 1, - "type": "integer" + "type": "number" }, "weight": { "default": "normal", @@ -2252,7 +2252,7 @@ "default": 12, "description": "[deprecated] Define 'size' within the 'font' object instead.", "minimum": 1, - "type": "integer", + "type": "number", "deprecated": true }, "fontWeight": { diff --git a/src/cascadia/PublicTerminalCore/HwndTerminal.cpp b/src/cascadia/PublicTerminalCore/HwndTerminal.cpp index 373e9c55046..7514bcc426f 100644 --- a/src/cascadia/PublicTerminalCore/HwndTerminal.cpp +++ b/src/cascadia/PublicTerminalCore/HwndTerminal.cpp @@ -169,7 +169,7 @@ static bool RegisterTermClass(HINSTANCE hInstance) noexcept } HwndTerminal::HwndTerminal(HWND parentHwnd) : - _desiredFont{ L"Consolas", 0, DEFAULT_FONT_WEIGHT, { 0, 14 }, CP_UTF8 }, + _desiredFont{ L"Consolas", 0, DEFAULT_FONT_WEIGHT, 14, CP_UTF8 }, _actualFont{ L"Consolas", 0, DEFAULT_FONT_WEIGHT, { 0, 14 }, CP_UTF8, false }, _uiaProvider{ nullptr }, _currentDpi{ USER_DEFAULT_SCREEN_DPI }, @@ -799,7 +799,7 @@ void _stdcall TerminalSetTheme(void* terminal, TerminalTheme theme, LPCWSTR font publicTerminal->_terminal->SetCursorStyle(static_cast(theme.CursorStyle)); - publicTerminal->_desiredFont = { fontFamily, 0, DEFAULT_FONT_WEIGHT, { 0, fontSize }, CP_UTF8 }; + publicTerminal->_desiredFont = { fontFamily, 0, DEFAULT_FONT_WEIGHT, static_cast(fontSize), CP_UTF8 }; publicTerminal->_UpdateFont(newDpi); // When the font changes the terminal dimensions need to be recalculated since the available row and column diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 2ca286f4a81..7fa53304299 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -95,7 +95,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation Control::IControlAppearance unfocusedAppearance, TerminalConnection::ITerminalConnection connection) : _connection{ connection }, - _desiredFont{ DEFAULT_FONT_FACE, 0, DEFAULT_FONT_WEIGHT, { 0, DEFAULT_FONT_SIZE }, CP_UTF8 }, + _desiredFont{ DEFAULT_FONT_FACE, 0, DEFAULT_FONT_WEIGHT, DEFAULT_FONT_SIZE, CP_UTF8 }, _actualFont{ DEFAULT_FONT_FACE, 0, DEFAULT_FONT_WEIGHT, { 0, DEFAULT_FONT_SIZE }, CP_UTF8, false } { _EnsureStaticInitialization(); @@ -859,15 +859,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - fontSize: The size of the font. // Return Value: // - Returns true if you need to call _refreshSizeUnderLock(). - bool ControlCore::_setFontSizeUnderLock(int fontSize) + bool ControlCore::_setFontSizeUnderLock(float fontSize) { // Make sure we have a non-zero font size - const auto newSize = std::max(fontSize, 1); + const auto newSize = std::max(fontSize, 1.0f); const auto fontFace = _settings->FontFace(); const auto fontWeight = _settings->FontWeight(); - _actualFont = { fontFace, 0, fontWeight.Weight, { 0, newSize }, CP_UTF8, false }; + _desiredFont = { fontFace, 0, fontWeight.Weight, newSize, CP_UTF8 }; + _actualFont = { fontFace, 0, fontWeight.Weight, _desiredFont.GetEngineSize(), CP_UTF8, false }; _actualFontFaceName = { fontFace }; - _desiredFont = { _actualFont }; const auto before = _actualFont.GetSize(); _updateFont(); @@ -893,11 +893,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - Adjust the font size of the terminal control. // Arguments: // - fontSizeDelta: The amount to increase or decrease the font size by. - void ControlCore::AdjustFontSize(int fontSizeDelta) + void ControlCore::AdjustFontSize(float fontSizeDelta) { const auto lock = _terminal->LockForWriting(); - if (_setFontSizeUnderLock(_desiredFont.GetEngineSize().Y + fontSizeDelta)) + if (_setFontSizeUnderLock(_desiredFont.GetFontSize() + fontSizeDelta)) { _refreshSizeUnderLock(); } @@ -1211,10 +1211,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation return static_cast(_actualFont.GetWeight()); } - til::size ControlCore::FontSizeInDips() const + winrt::Windows::Foundation::Size ControlCore::FontSizeInDips() const { - const til::size fontSize{ _actualFont.GetSize() }; - return fontSize.scale(til::math::rounding, 1.0f / ::base::saturated_cast(_compositionScale)); + const auto fontSize = _actualFont.GetSize(); + const auto scale = 1.0f / static_cast(_compositionScale); + return { + fontSize.width * scale, + fontSize.height * scale, + }; } TerminalConnection::ConnectionState ControlCore::ConnectionState() const diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index 07b9b46228b..d2649b53a67 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -76,10 +76,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation void SizeChanged(const double width, const double height); void ScaleChanged(const double scale); - void AdjustFontSize(int fontSizeDelta); + void AdjustFontSize(float fontSizeDelta); void ResetFontSize(); FontInfo GetFont() const; - til::size FontSizeInDips() const; + winrt::Windows::Foundation::Size FontSizeInDips() const; winrt::Windows::Foundation::Size FontSize() const noexcept; winrt::hstring FontFaceName() const noexcept; @@ -282,7 +282,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation std::unique_ptr> _updatePatternLocations; std::shared_ptr> _updateScrollBar; - bool _setFontSizeUnderLock(int fontSize); + bool _setFontSizeUnderLock(float fontSize); void _updateFont(const bool initialUpdate = false); void _refreshSizeUnderLock(); void _updateSelectionUI(); diff --git a/src/cascadia/TerminalControl/ControlCore.idl b/src/cascadia/TerminalControl/ControlCore.idl index 200258fae01..a65384e2bc2 100644 --- a/src/cascadia/TerminalControl/ControlCore.idl +++ b/src/cascadia/TerminalControl/ControlCore.idl @@ -105,7 +105,7 @@ namespace Microsoft.Terminal.Control void ClearHoveredCell(); void ResetFontSize(); - void AdjustFontSize(Int32 fontSizeDelta); + void AdjustFontSize(Single fontSizeDelta); void SizeChanged(Double width, Double height); void ScaleChanged(Double scale); diff --git a/src/cascadia/TerminalControl/ControlInteractivity.cpp b/src/cascadia/TerminalControl/ControlInteractivity.cpp index 75b8cf5b614..25508db5631 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.cpp +++ b/src/cascadia/TerminalControl/ControlInteractivity.cpp @@ -301,7 +301,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const auto touchdownPoint = *_singleClickTouchdownPos; const auto dx = pixelPosition.X - touchdownPoint.X; const auto dy = pixelPosition.Y - touchdownPoint.Y; - const auto w = fontSizeInDips.width; + const auto w = fontSizeInDips.Width; const auto distanceSquared = dx * dx + dy * dy; const auto maxDistanceSquared = w * w / 16; // (w / 4)^2 @@ -337,16 +337,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation const auto fontSizeInDips{ _core->FontSizeInDips() }; // Get the difference between the point we've dragged to and the start of the touch. - const auto dy = static_cast(newTouchPoint.Y - anchor.Y); + const auto dy = static_cast(newTouchPoint.Y - anchor.Y); // Start viewport scroll after we've moved more than a half row of text - if (std::abs(dy) > (fontSizeInDips.height / 2.0)) + if (std::abs(dy) > (fontSizeInDips.Height / 2.0f)) { // Multiply by -1, because moving the touch point down will // create a positive delta, but we want the viewport to move up, // so we'll need a negative scroll amount (and the inverse for // panning down) - const auto numRows = dy / -fontSizeInDips.height; + const auto numRows = dy / -fontSizeInDips.Height; const auto currentOffset = _core->ScrollOffset(); const auto newValue = numRows + currentOffset; @@ -459,7 +459,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // scrolling event. // Arguments: // - mouseDelta: the mouse wheel delta that triggered this event. - void ControlInteractivity::_mouseTransparencyHandler(const double mouseDelta) + void ControlInteractivity::_mouseTransparencyHandler(const int32_t mouseDelta) const { // Transparency is on a scale of [0.0,1.0], so only increment by .01. const auto effectiveDelta = mouseDelta < 0 ? -.01 : .01; @@ -471,9 +471,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation // event. // Arguments: // - mouseDelta: the mouse wheel delta that triggered this event. - void ControlInteractivity::_mouseZoomHandler(const double mouseDelta) + void ControlInteractivity::_mouseZoomHandler(const int32_t mouseDelta) const { - const auto fontDelta = mouseDelta < 0 ? -1 : 1; + const auto fontDelta = mouseDelta < 0 ? -1.0f : 1.0f; _core->AdjustFontSize(fontDelta); } @@ -483,7 +483,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - mouseDelta: the mouse wheel delta that triggered this event. // - pixelPosition: the location of the mouse during this event // - isLeftButtonPressed: true iff the left mouse button was pressed during this event. - void ControlInteractivity::_mouseScrollHandler(const double mouseDelta, + void ControlInteractivity::_mouseScrollHandler(const int32_t mouseDelta, const Core::Point pixelPosition, const bool isLeftButtonPressed) { diff --git a/src/cascadia/TerminalControl/ControlInteractivity.h b/src/cascadia/TerminalControl/ControlInteractivity.h index 3d47ad7c0c9..4025e765425 100644 --- a/src/cascadia/TerminalControl/ControlInteractivity.h +++ b/src/cascadia/TerminalControl/ControlInteractivity.h @@ -132,9 +132,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation unsigned int _numberOfClicks(Core::Point clickPos, Timestamp clickTime); void _updateSystemParameterSettings() noexcept; - void _mouseTransparencyHandler(const double mouseDelta); - void _mouseZoomHandler(const double mouseDelta); - void _mouseScrollHandler(const double mouseDelta, + void _mouseTransparencyHandler(const int32_t mouseDelta) const; + void _mouseZoomHandler(const int32_t mouseDelta) const; + void _mouseScrollHandler(const int32_t mouseDelta, const Core::Point terminalPosition, const bool isLeftButtonPressed); diff --git a/src/cascadia/TerminalControl/IControlSettings.idl b/src/cascadia/TerminalControl/IControlSettings.idl index 66ea5a33625..a7bfcf255a3 100644 --- a/src/cascadia/TerminalControl/IControlSettings.idl +++ b/src/cascadia/TerminalControl/IControlSettings.idl @@ -36,7 +36,7 @@ namespace Microsoft.Terminal.Control Boolean UseAtlasEngine { get; }; String FontFace { get; }; - Int32 FontSize { get; }; + Single FontSize { get; }; Windows.UI.Text.FontWeight FontWeight { get; }; String Padding { get; }; Windows.Foundation.Collections.IMap FontFeatures { get; }; diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 5d4061ee4a3..a965f35ff8c 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1517,7 +1517,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - Adjust the font size of the terminal control. // Arguments: // - fontSizeDelta: The amount to increase or decrease the font size by. - void TermControl::AdjustFontSize(int fontSizeDelta) + void TermControl::AdjustFontSize(float fontSizeDelta) { _core.AdjustFontSize(fontSizeDelta); } @@ -2082,8 +2082,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation // The family is only used to determine if the font is truetype or // not, but DX doesn't use that info at all. // The Codepage is additionally not actually used by the DX engine at all. - FontInfo actualFont = { fontFace, 0, fontWeight.Weight, { 0, fontSize }, CP_UTF8, false }; - FontInfoDesired desiredFont = { actualFont }; + FontInfoDesired desiredFont{ fontFace, 0, fontWeight.Weight, fontSize, CP_UTF8 }; + FontInfo actualFont{ fontFace, 0, fontWeight.Weight, desiredFont.GetEngineSize(), CP_UTF8, false }; // Create a DX engine and initialize it with our font and DPI. We'll // then use it to measure how much space the requested rows and columns diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index cfa0265adf9..afa134dbef3 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -82,7 +82,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void ScrollViewport(int viewTop); - void AdjustFontSize(int fontSizeDelta); + void AdjustFontSize(float fontSizeDelta); void ResetFontSize(); til::point GetFontSize() const; diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl index 745e3d55664..29080e6b8de 100644 --- a/src/cascadia/TerminalControl/TermControl.idl +++ b/src/cascadia/TerminalControl/TermControl.idl @@ -71,7 +71,7 @@ namespace Microsoft.Terminal.Control void SearchMatch(Boolean goForward); - void AdjustFontSize(Int32 fontSizeDelta); + void AdjustFontSize(Single fontSizeDelta); void ResetFontSize(); void ToggleShaderEffects(); diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.idl b/src/cascadia/TerminalSettingsEditor/Appearances.idl index 7963a59e8a7..39068ee8254 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.idl +++ b/src/cascadia/TerminalSettingsEditor/Appearances.idl @@ -34,7 +34,7 @@ namespace Microsoft.Terminal.Settings.Editor IHostedInWindow WindowRoot; // necessary to send the right HWND into the file picker dialogs. OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, FontFace); - OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Int32, FontSize); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Single, FontSize); OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.UI.Text.FontWeight, FontWeight); OBSERVABLE_PROJECTED_APPEARANCE_SETTING(String, ColorSchemeName); diff --git a/src/cascadia/TerminalSettingsModel/ActionArgs.h b/src/cascadia/TerminalSettingsModel/ActionArgs.h index 7dc91ac32e6..62fd9f9a085 100644 --- a/src/cascadia/TerminalSettingsModel/ActionArgs.h +++ b/src/cascadia/TerminalSettingsModel/ActionArgs.h @@ -117,7 +117,7 @@ private: //////////////////////////////////////////////////////////////////////////////// #define ADJUST_FONT_SIZE_ARGS(X) \ - X(int32_t, Delta, "delta", false, 0) + X(float, Delta, "delta", false, 0) //////////////////////////////////////////////////////////////////////////////// #define SEND_INPUT_ARGS(X) \ diff --git a/src/cascadia/TerminalSettingsModel/ActionArgs.idl b/src/cascadia/TerminalSettingsModel/ActionArgs.idl index dba7587a69d..d24322072b6 100644 --- a/src/cascadia/TerminalSettingsModel/ActionArgs.idl +++ b/src/cascadia/TerminalSettingsModel/ActionArgs.idl @@ -187,7 +187,7 @@ namespace Microsoft.Terminal.Settings.Model [default_interface] runtimeclass AdjustFontSizeArgs : IActionArgs { - Int32 Delta { get; }; + Single Delta { get; }; }; [default_interface] runtimeclass SendInputArgs : IActionArgs diff --git a/src/cascadia/TerminalSettingsModel/FontConfig.idl b/src/cascadia/TerminalSettingsModel/FontConfig.idl index 37d2aeb8050..174a6ff74b0 100644 --- a/src/cascadia/TerminalSettingsModel/FontConfig.idl +++ b/src/cascadia/TerminalSettingsModel/FontConfig.idl @@ -16,7 +16,7 @@ namespace Microsoft.Terminal.Settings.Model Microsoft.Terminal.Settings.Model.Profile SourceProfile { get; }; INHERITABLE_FONT_SETTING(String, FontFace); - INHERITABLE_FONT_SETTING(Int32, FontSize); + INHERITABLE_FONT_SETTING(Single, FontSize); INHERITABLE_FONT_SETTING(Windows.UI.Text.FontWeight, FontWeight); INHERITABLE_FONT_SETTING(Windows.Foundation.Collections.IMap, FontFeatures); diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h index 27897ecb60e..3cae1919883 100644 --- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -96,7 +96,7 @@ Author(s): #define MTSM_FONT_SETTINGS(X) \ X(hstring, FontFace, "face", DEFAULT_FONT_FACE) \ - X(int32_t, FontSize, "size", DEFAULT_FONT_SIZE) \ + X(float, FontSize, "size", DEFAULT_FONT_SIZE) \ X(winrt::Windows::UI::Text::FontWeight, FontWeight, "weight", DEFAULT_FONT_WEIGHT) \ X(IFontAxesMap, FontAxes, "axes") \ X(IFontFeatureMap, FontFeatures, "features") diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index 7647cd477ea..0dd65cdfbb7 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -121,7 +121,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::TerminalSettings, double, Opacity, UseAcrylic() ? 0.5 : 1.0); INHERITABLE_SETTING(Model::TerminalSettings, hstring, Padding, DEFAULT_PADDING); INHERITABLE_SETTING(Model::TerminalSettings, hstring, FontFace, DEFAULT_FONT_FACE); - INHERITABLE_SETTING(Model::TerminalSettings, int32_t, FontSize, DEFAULT_FONT_SIZE); + INHERITABLE_SETTING(Model::TerminalSettings, float, FontSize, DEFAULT_FONT_SIZE); INHERITABLE_SETTING(Model::TerminalSettings, winrt::Windows::UI::Text::FontWeight, FontWeight); INHERITABLE_SETTING(Model::TerminalSettings, IFontAxesMap, FontAxes); diff --git a/src/cascadia/inc/ControlProperties.h b/src/cascadia/inc/ControlProperties.h index 8c0468b2018..5911fa26183 100644 --- a/src/cascadia/inc/ControlProperties.h +++ b/src/cascadia/inc/ControlProperties.h @@ -57,7 +57,7 @@ X(bool, UseAcrylic, false) \ X(winrt::hstring, Padding, DEFAULT_PADDING) \ X(winrt::hstring, FontFace, L"Consolas") \ - X(int32_t, FontSize, DEFAULT_FONT_SIZE) \ + X(float, FontSize, DEFAULT_FONT_SIZE) \ X(winrt::Windows::UI::Text::FontWeight, FontWeight) \ X(IFontFeatureMap, FontFeatures) \ X(IFontAxesMap, FontAxes) \ diff --git a/src/renderer/atlas/AtlasEngine.api.cpp b/src/renderer/atlas/AtlasEngine.api.cpp index 8861704b5f6..a3095f2c213 100644 --- a/src/renderer/atlas/AtlasEngine.api.cpp +++ b/src/renderer/atlas/AtlasEngine.api.cpp @@ -561,6 +561,7 @@ void AtlasEngine::_resolveFontMetrics(const wchar_t* requestedFaceName, const Fo { const auto requestedFamily = fontInfoDesired.GetFamily(); auto requestedWeight = fontInfoDesired.GetWeight(); + auto fontSize = fontInfoDesired.GetFontSize(); auto requestedSize = fontInfoDesired.GetEngineSize(); if (!requestedFaceName) @@ -573,6 +574,7 @@ void AtlasEngine::_resolveFontMetrics(const wchar_t* requestedFaceName, const Fo } if (!requestedSize.Y) { + fontSize = 12.0f; requestedSize = { 0, 12 }; } if (!requestedWeight) @@ -614,8 +616,8 @@ void AtlasEngine::_resolveFontMetrics(const wchar_t* requestedFaceName, const Fo // Point sizes are commonly treated at a 72 DPI scale // (including by OpenType), whereas DirectWrite uses 96 DPI. // Since we want the height in px we multiply by the display's DPI. - const auto fontSizeInDIP = requestedSize.Y / 72.0f * 96.0f; - const auto fontSizeInPx = requestedSize.Y / 72.0f * _api.dpi; + const auto fontSizeInDIP = fontSize / 72.0f * 96.0f; + const auto fontSizeInPx = fontSize / 72.0f * _api.dpi; const auto designUnitsPerPx = fontSizeInPx / static_cast(metrics.designUnitsPerEm); const auto ascent = static_cast(metrics.ascent) * designUnitsPerPx; @@ -659,7 +661,7 @@ void AtlasEngine::_resolveFontMetrics(const wchar_t* requestedFaceName, const Fo // Our cells can't overlap each other so we additionally clamp the bottom line to be inside the cell boundaries. doubleUnderlinePosBottom = std::min(doubleUnderlinePosBottom, lineHeight - thinLineWidth); - const auto cellWidth = gsl::narrow(std::roundf(advanceWidth)); + const auto cellWidth = gsl::narrow(std::lroundf(advanceWidth)); const auto cellHeight = gsl::narrow(lineHeight); { @@ -673,7 +675,7 @@ void AtlasEngine::_resolveFontMetrics(const wchar_t* requestedFaceName, const Fo // Since clients expect that settings the font height to Y yields back a font height of Y, // we're scaling the X relative/proportional to the actual cellWidth/cellHeight ratio. // The code below uses a poor form of integer rounding. - requestedSize.X = (requestedSize.Y * cellWidth + cellHeight / 2) / cellHeight; + requestedSize.X = gsl::narrow_cast(std::lroundf((fontSize * cellWidth + cellHeight / 2) / cellHeight)); } fontInfo.SetFromEngine(requestedFaceName, requestedFamily, requestedWeight, false, coordSize, requestedSize); diff --git a/src/renderer/base/FontInfoDesired.cpp b/src/renderer/base/FontInfoDesired.cpp index aa6648d0dbe..8340aeab12b 100644 --- a/src/renderer/base/FontInfoDesired.cpp +++ b/src/renderer/base/FontInfoDesired.cpp @@ -8,23 +8,24 @@ FontInfoDesired::FontInfoDesired(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, - const til::size coordSizeDesired, + const float fontSize, const unsigned int codePage) noexcept : FontInfoBase(faceName, family, weight, false, codePage), - _coordSizeDesired(coordSizeDesired) + _coordSizeDesired{ 0, lroundf(fontSize) }, + _fontSize{ fontSize } { } FontInfoDesired::FontInfoDesired(const FontInfo& fiFont) noexcept : FontInfoBase(fiFont), - _coordSizeDesired(fiFont.GetUnscaledSize()) + _coordSizeDesired{ fiFont.GetUnscaledSize() }, + _fontSize{ static_cast(_coordSizeDesired.height) } { } -bool FontInfoDesired::operator==(const FontInfoDesired& other) noexcept +float FontInfoDesired::GetFontSize() const noexcept { - return FontInfoBase::operator==(other) && - _coordSizeDesired == other._coordSizeDesired; + return _fontSize; } til::size FontInfoDesired::GetEngineSize() const noexcept diff --git a/src/renderer/inc/FontInfoDesired.hpp b/src/renderer/inc/FontInfoDesired.hpp index f4085629202..5e77e466f9c 100644 --- a/src/renderer/inc/FontInfoDesired.hpp +++ b/src/renderer/inc/FontInfoDesired.hpp @@ -27,15 +27,17 @@ class FontInfoDesired : public FontInfoBase FontInfoDesired(const std::wstring_view& faceName, const unsigned char family, const unsigned int weight, - const til::size coordSizeDesired, + const float fontSize, const unsigned int uiCodePage) noexcept; FontInfoDesired(const FontInfo& fiFont) noexcept; - bool operator==(const FontInfoDesired& other) noexcept; + bool operator==(const FontInfoDesired& other) = delete; + float GetFontSize() const noexcept; til::size GetEngineSize() const noexcept; bool IsDefaultRasterFont() const noexcept; private: til::size _coordSizeDesired; + float _fontSize; };