-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for fractional font sizes #14013
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<double>(newTouchPoint.Y - anchor.Y); | ||
const auto dy = static_cast<float>(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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wat There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to change one of these due to the int -> float change. |
||
{ | ||
// 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) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. flipping these around scares me a bit |
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1110,8 +1110,9 @@ void CascadiaSettings::WriteSettingsToDisk() | |
|
||
// write current settings to current settings file | ||
Json::StreamWriterBuilder wbuilder; | ||
wbuilder.settings_["indentation"] = " "; | ||
wbuilder.settings_["enableYAMLCompatibility"] = true; // suppress spaces around colons | ||
wbuilder.settings_["indentation"] = " "; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i see you sorted this list ;P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's more than 1 line it must be sorted alphabetically! No exceptions! 😄 |
||
wbuilder.settings_["precision"] = 6; // prevent values like 1.1000000000000001 | ||
|
||
FILETIME lastWriteTime{}; | ||
const auto styledString{ Json::writeString(wbuilder, ToJson()) }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we not using
til::size
because it does not use floats?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! I was a bit confused about this bit, as FontSizeInDips is usually not an integer on any display scale but 100%.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra fun bit is that
ControlCore::FontSize()
without theInDips
already returned awinrt::Windows::Foundation::Size
, just not this function. 😅