snapFontSize function

double snapFontSize(
  1. double size
)

Helpers that size and place text from the font tables.

They read only font facts, so every app of monet_ui can use them (docs/design/ADR_fonts_in_monet_ui.md in telosnex, D4). size rounded to 1/64 px, a difference no one can see.

Snap a computed (scaled or matched) font size. At other fractional sizes, FreeType (Linux) rounds glyph advances to 1/64 px and CoreText (macOS) does not, so the same text had different widths on each platform.

Implementation

/// [size] rounded to 1/64 px, a difference no one can see.
///
/// Snap a computed (scaled or matched) font size. At other fractional sizes,
/// FreeType (Linux) rounds glyph advances to 1/64 px and CoreText (macOS)
/// does not, so the same text had different widths on each platform.
double snapFontSize(double size) => (size * 64).roundToDouble() / 64;