ui/font
lib/ui/font.vklib/ui/font.vk
Crisp mixed-case proportional & monospace bitmap UI typography engine for ui/canvas.
Renders sharp A-Z, a-z (true ascenders & descenders), 0-9, symbols, and bullet masks
across body (size = 1), subheading (size = 2), and display (size = 3) scales.
Zero capabilities required; works identically on VM, Wasm 3.0, and Native.
line-height = fn [size i64] i64
Returns the vertical line height in pixels for font size (1 = 12px, 2 = 20px, 3 = 28px).
measure-text = fn [text str, size i64] i64
Measures the pixel width of text rendered with proportional kerning at size.
use [fnt = ui/font]
w1 = fnt/measure-text 'Veko UI' 1
w2 = fnt/measure-text 'Veko UI' 2
if w1 <= 20 or w2 != (w1 * 2) [ err 'measure-text' ] else [ .ok ]
measure-mono = fn [text str, size i64] i64
Measures fixed-width monospace text width at size.
draw-text = fn [mut c cv/Canvas, x i64, y i64, text str, size i64, col cv/Color]
Draws mixed-case proportional UI text at (x, y) at size (1 = 12px body, 2 = 18px heading, 3 = 27px display).
draw-bold = fn [mut c cv/Canvas, x i64, y i64, text str, size i64, col cv/Color]
Draws semi-bold proportional UI text (ideal for card headers, active tabs, and primary badges).
draw-mono = fn [mut c cv/Canvas, x i64, y i64, text str, size i64, col cv/Color]
Draws fixed-width mixed-case monospace text at (x, y) (ideal for code, numeric columns, and metrics).
draw-truncated = fn [mut c cv/Canvas, x i64, y i64, max_w i64, text str, size i64, col cv/Color]
Draws proportional text truncated with '...' if its pixel width exceeds max_w.
draw-bullets = fn [mut c cv/Canvas, x i64, y i64, count i64, size i64, col cv/Color] i64
Draws count masked secret bullet dots at (x, y) without inspecting secret content.