Overhaul UI and overall QoL

This commit is contained in:
2026-10-22 21:59:50 +02:00
parent 2ba43fb2d3
commit ac48c24a03
31 changed files with 3181 additions and 1641 deletions
+16 -4
View File
@@ -58,11 +58,23 @@ namespace KernelPanic.UI
}
float advanceRatio = GetAdvanceRatio();
float widthFit = region.width / (columns * advanceRatio);
float heightFit = region.height / (rows * LineHeightRatio);
float widthPerPoint = columns * advanceRatio;
float heightPerPoint = rows * LineHeightRatio;
// Font line spacing is not necessarily 1.05 em. Measure the complete block,
// including its trailing line, so the last ASCII rows cannot be cropped.
float currentSize = _label.resolvedStyle.fontSize;
Vector2 measured = _label.MeasureTextSize(_art, 0f, VisualElement.MeasureMode.Undefined,
0f, VisualElement.MeasureMode.Undefined);
if (IsUsable(currentSize) && IsUsable(measured.x) && IsUsable(measured.y))
{
widthPerPoint = measured.x / currentSize;
heightPerPoint = measured.y / currentSize;
}
float widthFit = region.width / widthPerPoint;
float heightFit = region.height / heightPerPoint;
float fontSize = Mathf.Clamp(Mathf.Floor(Mathf.Min(widthFit, heightFit)), MinFontSize, MaxFontSize);
float blockWidth = columns * fontSize * advanceRatio;
float blockHeight = rows * fontSize * LineHeightRatio;
float blockWidth = fontSize * widthPerPoint;
float blockHeight = fontSize * heightPerPoint;
_label.style.fontSize = fontSize;
_label.style.paddingLeft = Mathf.Max(0f, (region.width - blockWidth) * 0.5f);