ltk::theme

Module typography

Source
Expand description

Typography scale used by the default theme.

Designed around the Sora typeface (Google Fonts). If Sora is not installed on the system, ltk falls back to Liberation Sans / DejaVu Sans; glyph metrics will differ slightly but the scale still reads correctly.

Two scales coexist: the historic px constants (H0 through BODY_XS) for code that wants a frozen pixel size, and the new responsive scale (h0, h1, …, body_xs) that returns viewport-relative crate::Length values clamped to the same px range that used to be the constant. Call sites can mix freely: .size( typography::H2 ) still resolves to Length::px( 24.0 ) via From<f32>, while .size( typography::h2() ) scales with the surface’s smaller dimension.

Constants§

  • See H0. Px size of running body text.
  • See H0. Px size of small (secondary) body text.
  • See H0. Px size of the smallest (caption) text.
  • Frozen px sizes for the typographic scale, largest (H0, a display heading) to smallest (BODY_XS, fine print). H0H3 are the heading ramp; BODY is running text, with BODY_S / BODY_XS for secondary and caption text. Each is the px size; for sizes that scale with the surface use the responsive h0body_xs functions instead.
  • See H0. Px size of the second-largest heading level.
  • See H0. Px size of the third heading level.
  • See H0. Px size of the fourth heading level.
  • Interlineado (line-height) multiplier recommended by the kit. Apply as size * LINE_HEIGHT when laying out multi-line text blocks.

Functions§

  • See h0. Running body text: 1.6% of vmin, clamped to 14..=22 px.
  • See h0. Small body text: 1.4% of vmin, clamped to 12..=18 px.
  • See h0. Smallest caption text: 1.2% of vmin, clamped to 11..=15 px.
  • Responsive counterparts of the px constants: each returns a Length that scales with the surface’s smaller dimension (vmin) and is clamped to a sensible px range, so the same level reads correctly from a portrait phone to a 4K desktop. Same hierarchy as the constants — h0 the largest display heading down to body_xs the smallest caption. Largest display heading: scales as 5% of vmin, clamped to 32..=80 px.
  • See h0. Second heading level: 3.4% of vmin, clamped to 24..=56 px.
  • See h0. Third heading level: 2.4% of vmin, clamped to 18..=40 px.
  • See h0. Fourth heading level: 2.0% of vmin, clamped to 16..=32 px.