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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user