Account for custom cell sizes in launch size calculation (#18862)

When calculating the initial terminal window size, we weren't taking
into account the line height and cell width settings, so the resulting
number of rows and columns didn't match the requested launch size.

Verification:
Manually verified that the window is now correctly sized when using a
custom line height and cell width.

Closes #18582
This commit is contained in:
James Holderness 2025-05-01 19:28:44 +01:00 committed by GitHub
parent 08e76da3a1
commit 34b8ed3575
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2825,6 +2825,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const auto fontSize = settings.FontSize();
const auto fontWeight = settings.FontWeight();
const auto fontFace = settings.FontFace();
const auto cellWidth = CSSLengthPercentage::FromString(settings.CellWidth().c_str());
const auto cellHeight = CSSLengthPercentage::FromString(settings.CellHeight().c_str());
const auto scrollState = settings.ScrollState();
const auto padding = settings.Padding();
@ -2836,6 +2838,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// not, but DX doesn't use that info at all.
// The Codepage is additionally not actually used by the DX engine at all.
FontInfoDesired desiredFont{ fontFace, 0, fontWeight.Weight, fontSize, CP_UTF8 };
desiredFont.SetCellSize(cellWidth, cellHeight);
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