From fc67c0852a854d76df4577e5180a721e792d3a6f Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Wed, 19 Aug 2026 09:43:19 +0200 Subject: [PATCH] fix(text): give the wrap calculation the scale imgui actually asks for CalcWordWrapPositionA takes a scale, and imgui means size / FontSize by that -- the ratio between the size being rendered and the size the face was baked at (imgui_draw.cpp, CalcTextSizeA). We were handing it ImGuiHelpers.GlobalScale. That is the same number today, but by coincidence rather than by design. Dalamud bakes every font at SizePx * GlobalScale and then divides the metrics back down, so g.FontSize / font->FontSize lands on GlobalScale for every handle regardless of its size. The coincidence holds only while one face draws a line. The typography work starting with this cycle puts a second size into the same line, and there the two numbers separate: the wrap would be computed for the wrong size while CalcTextSizeA keeps measuring with the right one. Measured height and drawn wrap would drift apart, and the virtualised clipper plans against the measured value. No behaviour change expected here -- the expression evaluates to what the old constant already was. --- HellionChat/Util/ImGuiUtil.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/HellionChat/Util/ImGuiUtil.cs b/HellionChat/Util/ImGuiUtil.cs index 6714aef..db36fe0 100755 --- a/HellionChat/Util/ImGuiUtil.cs +++ b/HellionChat/Util/ImGuiUtil.cs @@ -786,9 +786,14 @@ internal static class ImGuiUtil private static unsafe int CalcWordWrap(byte* basePtr, int start, int end, float width) { + var font = ImGui.GetFont(); + // ImGui reads this as size / FontSize (imgui_draw.cpp, CalcTextSizeA), not + // as UI scale. The two match only while every font is built at + // SizePx * GlobalScale, which stops holding the moment a second size + // enters a line. var result = ImGuiNative.CalcWordWrapPositionA( - ImGui.GetFont().Handle, - ImGuiHelpers.GlobalScale, + font.Handle, + ImGui.GetFontSize() / font.FontSize, basePtr + start, basePtr + end, width