Repository: microsoft/terminal (language: cpp)

Issue:
Text display area does not scale correctly
### Windows Terminal version (or Windows build number)

Windows Terminal version 1.10.2383.0

### Other Software

_No response_

### Steps to reproduce

1. Open Windows terminal (spawns on primary/1080p monitor)
2. Execute commands till text reaches the bottom of the window
3. Move window to secondary monitor (4k, 125% scaling)
4. Text at bottom and right is cut off, and scrolling does not update the bottom of the window
5. Input is also cut off at the bottom, so I can't see what I'm typing

### Expected Behavior

The text display area should scale correctly 

### Actual Behavior

Window on 1080p monitor:
![image](https://user-images.githubusercontent.com/22267435/134522778-3e56b99c-2a47-4b93-b7a0-3b892d28db36.png)

Window on 4k monitor:
![image](https://user-images.githubusercontent.com/22267435/134522820-7496b03d-42c7-4e86-a1d2-93cfefdaca12.png)

Scrolling also seems to only affect the top 3 lines while on the 4k display?
![image](https://user-images.githubusercontent.com/22267435/134523101-64418b9b-7cc0-46ec-af7a-5d861622806c.png)

And there's also something about cutting off the output of commands above the fold, which seems to apply regardless of monitor:
![image](https://user-images.githubusercontent.com/22267435/134523538-a066b8b4-9dda-486e-8789-94eb5d2217f8.png)




I also just accidentally discovered that resizing the window fixes both the text display area and the scrolling issue on the 4k monitor


Discussion / hints:
From #11525: 
![image](https://user-images.githubusercontent.com/18356694/137723043-3ff7779a-d458-40db-a875-57ce868798e7.png)

* this issue:  1.10.2383.0, 1080p,100% -> 4k,125%
* #11525: 1.10.2714.0, 3840x2160,150% -> 3840x2160,300% 
From _@itsamemarkus_ in 11659


> ### Windows Terminal version (or Windows build number)
> 1.11.2921.0
> 
> ### Steps to reproduce
> Use 4k and lower resolution monitor. **Start new terminal session on lower resolution monitor.** Drag window from lower resolution monitor to 4k monitor.
> 
>  https://user-images.githubusercontent.com/34944988/139568896-2e4caeda-0e05-4632-a86e-1195f2e68a17.mp4
>
> Windows Terminal 1.11.2921.0 Windows 21H1 19043.1320
> 
> ```
> BitsPerPixel : 32
> Bounds       : {X=3840,Y=1,Width=1680,Height=1050}
> DeviceName   : \\.\DISPLAY1
> Primary      : False
> WorkingArea  : {X=3840,Y=1,Width=1680,Height=1010}
> 
> BitsPerPixel : 32
> Bounds       : {X=0,Y=0,Width=1920,Height=1080}
> DeviceName   : \\.\DISPLAY2
> Primary      : True
> WorkingArea  : {X=0,Y=0,Width=1920,Height=1040}
> 
> BitsPerPixel : 32
> Bounds       : {X=-1680,Y=0,Width=1680,Height=1050}
> DeviceName   : \\.\DISPLAY3
> Primary      : False
> WorkingArea  : {X=-1680,Y=0,Width=1680,Height=1010}
> ```



I have two 4k monitors and set one to 100% and the other to 300% scale.
With that setup I can't replicate this issue in Windows Terminal 1.12.10393.0 on Windows 11.

Do we maybe have to swap these two lines? https://github.com/microsoft/terminal/blob/09e99156727a92f84b309f18aee59ea7293b1264/src/cascadia/WindowsTerminal/BaseWindow.h#L112-L114
See, I dunno about that. I feel like the root cause has got to be somewhere in the `TermControl` / `Renderer` area. Look at the screenshot [above](https://github.com/microsoft/terminal/issues/11317#issuecomment-945676588). The scrollbar is positioned correctly, but seemingly the DX surface isn't? Either the `SpawChainPanel` didn't get resized up, or the `Control` didn't resize the actual swapchain to the new size. 

It's just annoying that we seemingly can't get a local repro even with a bunch of reports of this 😕 Even if we did have a psychic debugging theory why this happened, we'd have no way to confirm the fix. 
I haven't changed my setup except regular updates and the bug appears to be gone.

**Current version where I don't have the bug**
Windows Terminal 1.11.3471.0 Windows 21H2 19044.1526

**Version where I experienced the bug**
Windows Terminal 1.11.2921.0 Windows 21H1 19043.1320
Hey anyone who's still hitting this: (@zdavidsen, @flcdrg, @itsamemarkus, I think @oising was as well) - any chance you're using the `font` object in your profile settings somewhere? The fix in #12492 just has me curious. 
> Hey anyone who's still hitting this: (zdavidsen, flcdrg, itsamemarkus, I think oising was as well) - any chance you're using the `font` object in your profile settings somewhere? The fix in 12492 just has me curious.

Huh, changing the `font` seems to do it.  Default is 12, I have all of my profiles set to 10.  If I change them back to 12, then the scaling issue goes away. (I only tested it with the cmd profile)
WHAT
I just double checked and the scrolling issue I mentioned seems to be fixed as well, regardless of text size.  Haven't really been watching that one, so I'm not sure when that changed
@zadjii-msft my profile is [here](https://gist.github.com/flcdrg/db52f72b9e63d01d15c36840e4175d2f)

The only reference to font is for PowershellCore

```json
               "font": 
                {
                    "face": "CaskaydiaCove NF"
                },
```

though that is my default profile. I have not changed the font size 
Alright so for some weird reason I can only consistently reproduce it if I do these exact steps:
* use Cascadia Code 10pt
* print text (`Get-Help Get-ChildItem`)
* _then_ resize the window to be smaller
* _then_ scroll up slightly
* and only then move the window to the higher DPI one

Horrifying.
I'm not sure if this is related, but if I have terminal on my external monitor, then undock, I *always* get a screwed up/clipped window. Maximize/restore fixes it. I just got used to it. Example:

![image](https://user-images.githubusercontent.com/1844001/154185593-bd1bc25d-bdf5-4266-9fd1-ed2b3278cb1c.png)




And yes, I use a one of the nerdfonts modified Cascadia fonts, I think (for oh-my-posh) -- note that I have force full repaint on for that _other_ bug.

```json
{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": "toggleShaderEffects",
            "keys": "shift+f10"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "toggleFocusMode",
            "keys": "shift+f11"
        },
        {
            "command": "unbound",
            "keys": "win+`"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": 
            {
                "action": "quakeMode"
            },
            "keys": "ctrl+`"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
    "experimental.rendering.forceFullRepaint": true,
    "experimental.rendering.software": false,
    "profiles": 
    {
        "defaults": 
        {
            "antialiasingMode": "cleartype",
            "colorScheme": "Vintage",
            "font": 
            {
                "face": "FiraCode NF Retina"
            },
            "opacity": 100,
            "useAcrylic": true
        },
        "list": 
        [
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "backgroundImage": null,
                "backgroundImageOpacity": 0.75,
                "backgroundImageStretchMode": "fill",
                "colorScheme": "Vintage",
                "commandline": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
                "experimental.retroTerminalEffect": false,
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "intenseTextStyle": "bright",
                "name": "PowerShell",
                "opacity": 100,
                "source": "Windows.Terminal.PowershellCore",
                "useAcrylic": true
            },
            {
                "commandline": "pwsh.exe -noe -c \"&{$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\\Microsoft Visual Studio\\Installer\\vswhere.exe') -property installationpath; Import-Module (Join-Path $vsPath 'Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll'); Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation}\"",
                "guid": "{febde9c2-43c9-4971-9499-a96a69a6a89b}",
                "icon": "%ProgramFiles(x86)%\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\\Assets\\VisualStudio.70x70.contrast-standard_scale-180.png",
                "name": "Developer PowerShell for VS 2019"
            },
            {
                "commandline": "%comspec%  /k \"%ProgramFiles(x86)%\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\Tools\\VsDevCmd.bat\"",
                "guid": "{ba122f80-9cdf-47b8-ba11-ce8955bb212f}",
                "icon": "%ProgramFiles(x86)%\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\\Assets\\VisualStudio.70x70.contrast-standard_scale-180.png",
                "name": "Developer Command Prompt for VS 2019"
            },
            {
                "colorScheme": "Vintage",
                "guid": "{a3a2e83a-884a-5379-baa8-16f193a13b21}",
                "hidden": false,
                "name": "PowerShell 7 Preview",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
                "hidden": false,
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{ee76f40e-e821-5b26-819e-d1c8414e1e57}",
                "hidden": false,
                "name": "Developer Command Prompt for VS 2022 [Preview]",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{823e2542-ca2f-5a92-99a7-6bceebe80ef3}",
                "hidden": false,
                "name": "Developer PowerShell for VS 2022 [Preview]",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{f137a298-4fbc-55df-b998-45767d3e5339}",
                "hidden": true,
                "name": "Developer Command Prompt for VS 2019",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{b5e4d867-8168-5ec8-8ac7-38c60e470e4d}",
                "hidden": true,
                "name": "Developer PowerShell for VS 2019",
                "source": "Windows.Terminal.VisualStudio"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        }
    ],
    "startOnUserLogin": true,
    "windowingBehavior": "useAnyExisting"
}
```
Just in case this helps at all, here's my [full profile](https://github.com/microsoft/terminal/files/8080335/settings.txt)

Fix patch:
diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp
index 21a71077389..f473a817439 100644
--- a/src/cascadia/TerminalControl/ControlCore.cpp
+++ b/src/cascadia/TerminalControl/ControlCore.cpp
@@ -620,19 +620,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
             _runtimeUseAcrylic = true;
         }
 
-        // Initialize our font information.
-        const auto fontFace = _settings->FontFace();
-        const short fontHeight = ::base::saturated_cast<short>(_settings->FontSize());
-        const auto fontWeight = _settings->FontWeight();
-        // The font width doesn't terribly matter, we'll only be using the
-        //      height to look it up
-        // The other params here also largely don't matter.
-        //      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.
-        _actualFont = { fontFace, 0, fontWeight.Weight, { 0, fontHeight }, CP_UTF8, false };
-        _actualFontFaceName = { fontFace };
-        _desiredFont = { _actualFont };
+        const auto sizeChanged = _setFontSizeUnderLock(_settings->FontSize());
 
         // Update the terminal core with its new Core settings
         _terminal->UpdateSettings(*_settings);
@@ -651,11 +639,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
 
         _updateAntiAliasingMode();
 
-        // Refresh our font with the renderer
-        const auto actualFontOldSize = _actualFont.GetSize();
-        _updateFont();
-        const auto actualFontNewSize = _actualFont.GetSize();
-        if (actualFontNewSize != actualFontOldSize)
+        if (sizeChanged)
         {
             _refreshSizeUnderLock();
         }
@@ -768,30 +752,22 @@ namespace winrt::Microsoft::Terminal::Control::implementation
     // - Set the font size of the terminal control.
     // Arguments:
     // - fontSize: The size of the font.
-    void ControlCore::_setFontSize(int fontSize)
+    // Return Value:
+    // - Returns true if you need to call _refreshSizeUnderLock().
+    bool ControlCore::_setFontSizeUnderLock(int fontSize)
     {
-        try
-        {
-            // Make sure we have a non-zero font size
-            const auto newSize = std::max<short>(gsl::narrow_cast<short>(fontSize), 1);
-            const auto fontFace = _settings->FontFace();
-            const auto fontWeight = _settings->FontWeight();
-            _actualFont = { fontFace, 0, fontWeight.Weight, { 0, newSize }, CP_UTF8, false };
-            _actualFontFaceName = { fontFace };
-            _desiredFont = { _actualFont };
-
-            auto lock = _terminal->LockForWriting();
-
-            // Refresh our font with the renderer
-            _updateFont();
-
-            // Resize the terminal's BUFFER to match the new font size. This does
-            // NOT change the size of the window, because that can lead to more
-            // problems (like what happens when you change the font size while the
-            // window is maximized?)
-            _refreshSizeUnderLock();
-        }
-        CATCH_LOG();
+        // Make sure we have a non-zero font size
+        const auto newSize = std::max<short>(gsl::narrow_cast<short>(fontSize), 1);
+        const auto fontFace = _settings->FontFace();
+        const auto fontWeight = _settings->FontWeight();
+        _actualFont = { fontFace, 0, fontWeight.Weight, { 0, newSize }, CP_UTF8, false };
+        _actualFontFaceName = { fontFace };
+        _desiredFont = { _actualFont };
+
+        const auto before = _actualFont.GetSize();
+        _updateFont();
+        const auto after = _actualFont.GetSize();
+        return before != after;
     }
 
     // Method Description:
@@ -800,7 +776,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
     // - none
     void ControlCore::ResetFontSize()
     {
-        _setFontSize(_settings->FontSize());
+        const auto lock = _terminal->LockForWriting();
+
+        if (_setFontSizeUnderLock(_settings->FontSize()))
+        {
+            _refreshSizeUnderLock();
+        }
     }
 
     // Method Description:
@@ -809,69 +790,46 @@ namespace winrt::Microsoft::Terminal::Control::implementation
     // - fontSizeDelta: The amount to increase or decrease the font size by.
     void ControlCore::AdjustFontSize(int fontSizeDelta)
     {
-        const auto newSize = _desiredFont.GetEngineSize().Y + fontSizeDelta;
-        _setFontSize(newSize);
+        const auto lock = _terminal->LockForWriting();
+
+        if (_setFontSizeUnderLock(_desiredFont.GetEngineSize().Y + fontSizeDelta))
+        {
+            _refreshSizeUnderLock();
+        }
     }
 
     // Method Description:
-    // - Perform a resize for the current size of the swapchainpanel. If the
-    //   font size changed, we'll need to resize the buffer to fit the existing
-    //   swapchain size. This helper will call _doResizeUnderLock with the
-    //   current size of the swapchain, accounting for scaling due to DPI.
+    // - Process a resize event that was initiated by the user. This can either
+    //   be due to the user resizing the window (causing the swapchain to
+    //   resize) or due to the DPI changing (causing us to need to resize the
+    //   buffer to match)
     // - Note that a DPI change will also trigger a font size change, and will
     //   call into here.
     // - The write lock should be held when calling this method, we might be
-    //   changing the buffer size in _doResizeUnderLock.
+    //   changing the buffer size in _refreshSizeUnderLock.
     // Arguments:
     // - <none>
     // Return Value:
     // - <none>
     void ControlCore::_refreshSizeUnderLock()
     {
-        const auto widthInPixels = _panelWidth * _compositionScale;
-        const auto heightInPixels = _panelHeight * _compositionScale;
-
-        _doResizeUnderLock(widthInPixels, heightInPixels);
-    }
-
-    // Method Description:
-    // - Process a resize event that was initiated by the user. This can either
-    //   be due to the user resizing the window (causing the swapchain to
-    //   resize) or due to the DPI changing (causing us to need to resize the
-    //   buffer to match)
-    // Arguments:
-    // - newWidth: the new width of the swapchain, in pixels.
-    // - newHeight: the new height of the swapchain, in pixels.
-    void ControlCore::_doResizeUnderLock(const double newWidth,
-                                         const double newHeight)
-    {
-        SIZE size;
-        size.cx = static_cast<long>(newWidth);
-        size.cy = static_cast<long>(newHeight);
+        auto cx = gsl::narrow_cast<short>(_panelWidth * _compositionScale);
+        auto cy = gsl::narrow_cast<short>(_panelHeight * _compositionScale);
 
         // Don't actually resize so small that a single character wouldn't fit
         // in either dimension. The buffer really doesn't like being size 0.
-        if (size.cx < _actualFont.GetSize().X || size.cy < _actualFont.GetSize().Y)
-        {
-            return;
-        }
+        cx = std::max(cx, _actualFont.GetSize().X);
+        cy = std::max(cy, _actualFont.GetSize().Y);
 
         // Convert our new dimensions to characters
-        const auto viewInPixels = Viewport::FromDimensions({ 0, 0 },
-                                                           { static_cast<short>(size.cx), static_cast<short>(size.cy) });
+        const auto viewInPixels = Viewport::FromDimensions({ 0, 0 }, { cx, cy });
         const auto vp = _renderEngine->GetViewportInCharacters(viewInPixels);
         const auto currentVP = _terminal->GetViewport();
 
-        // Don't actually resize if viewport dimensions didn't change
-        if (vp.Height() == currentVP.Height() && vp.Width() == currentVP.Width())
-        {
-            return;
-        }
-
         _terminal->ClearSelection();
 
         // Tell the dx engine that our window is now the new size.
-        THROW_IF_FAILED(_renderEngine->SetWindowSize(size));
+        THROW_IF_FAILED(_renderEngine->SetWindowSize({ cx, cy }));
 
         // Invalidate everything
         _renderer->TriggerRedrawAll();
@@ -888,15 +846,18 @@ namespace winrt::Microsoft::Terminal::Control::implementation
     void ControlCore::SizeChanged(const double width,
                                   const double height)
     {
+        // _refreshSizeUnderLock redraws the entire terminal.
+        // Don't call it if we don't have to.
+        if (_panelWidth == width && _panelHeight == height)
+        {
+            return;
+        }
+
         _panelWidth = width;
         _panelHeight = height;
 
         auto lock = _terminal->LockForWriting();
-        const auto currentEngineScale = _renderEngine->GetScaling();
-
-        auto scaledWidth = width * currentEngineScale;
-        auto scaledHeight = height * currentEngineScale;
-        _doResizeUnderLock(scaledWidth, scaledHeight);
+        _refreshSizeUnderLock();
     }
 
     void ControlCore::ScaleChanged(const double scale)
@@ -906,30 +867,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
             return;
         }
 
-        const auto currentEngineScale = _renderEngine->GetScaling();
-        // If we're getting a notification to change to the DPI we already
-        // have, then we're probably just beginning the DPI change. Since
-        // we'll get _another_ event with the real DPI, do nothing here for
-        // now. We'll also skip the next resize in _swapChainSizeChanged.
-        const bool dpiWasUnchanged = currentEngineScale == scale;
-        if (dpiWasUnchanged)
+        // _refreshSizeUnderLock redraws the entire terminal.
+        // Don't call it if we don't have to.
+        if (_compositionScale == scale)
         {
             return;
         }
 
-        const auto actualFontOldSize = _actualFont.GetSize();
-
-        auto lock = _terminal->LockForWriting();
         _compositionScale = scale;
 
+        auto lock = _terminal->LockForWriting();
         // _updateFont relies on the new _compositionScale set above
         _updateFont();
-
-        const auto actualFontNewSize = _actualFont.GetSize();
-        if (actualFontNewSize != actualFontOldSize)
-        {
-            _refreshSizeUnderLock();
-        }
+        _refreshSizeUnderLock();
     }
 
     void ControlCore::SetSelectionAnchor(til::point const& position)
diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h
index 2a86c2585cd..a8cd204f1ef 100644
--- a/src/cascadia/TerminalControl/ControlCore.h
+++ b/src/cascadia/TerminalControl/ControlCore.h
@@ -242,11 +242,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
 
         winrt::fire_and_forget _asyncCloseConnection();
 
-        void _setFontSize(int fontSize);
+        bool _setFontSizeUnderLock(int fontSize);
         void _updateFont(const bool initialUpdate = false);
         void _refreshSizeUnderLock();
-        void _doResizeUnderLock(const double newWidth,
-                                const double newHeight);
 
         void _sendInputToConnection(std::wstring_view wstr);
 


Test patch: