From 58830aecec51006a9a572a348fa78ec894cc132b Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Wed, 19 Aug 2026 09:44:05 +0200 Subject: [PATCH] feat(style): the arithmetic behind a type scale Quarter-point rounding, not whole points. The base size is 12.75pt, so rounding a derived role to whole points would move it further than the step between two adjacent base sizes -- the scale would quantise away the difference it exists to express. The floor is what keeps the meta role legible when someone runs a small base size; below about seven points a timestamp stops being readable at any display scale. --- HellionChat/Ui/StyleEngine/TypeScaleMath.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 HellionChat/Ui/StyleEngine/TypeScaleMath.cs diff --git a/HellionChat/Ui/StyleEngine/TypeScaleMath.cs b/HellionChat/Ui/StyleEngine/TypeScaleMath.cs new file mode 100644 index 0000000..79a6fb4 --- /dev/null +++ b/HellionChat/Ui/StyleEngine/TypeScaleMath.cs @@ -0,0 +1,13 @@ +namespace HellionChat.Ui.StyleEngine; + +// TEST-MIRROR: Ui/TypeScaleMathTests.cs +// +// Rounds to quarter points rather than whole ones. The base size itself is +// 12.75pt, so whole-point rounding would move a role by more than the step +// between two adjacent base sizes -- the scale would quantise away the very +// difference it exists to express. +internal static class TypeScaleMath +{ + internal static float Resolve(float basePt, float factor, float minPt) => + MathF.Max(minPt, MathF.Round(basePt * factor * 4f) / 4f); +}