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.
This commit is contained in:
@@ -786,9 +786,14 @@ internal static class ImGuiUtil
|
|||||||
|
|
||||||
private static unsafe int CalcWordWrap(byte* basePtr, int start, int end, float width)
|
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(
|
var result = ImGuiNative.CalcWordWrapPositionA(
|
||||||
ImGui.GetFont().Handle,
|
font.Handle,
|
||||||
ImGuiHelpers.GlobalScale,
|
ImGui.GetFontSize() / font.FontSize,
|
||||||
basePtr + start,
|
basePtr + start,
|
||||||
basePtr + end,
|
basePtr + end,
|
||||||
width
|
width
|
||||||
|
|||||||
Reference in New Issue
Block a user