Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132// Text size. The settings pane keeps it in px; app.css reads it as two ratios of// the 13px base, --ui-scale for the chrome and --canvas-scale for the canvas.
export interface Text { ui: number; canvas: number; /** Whether the canvas has its own size; otherwise it follows `ui`. */ own: boolean;}
export const BASE_SIZE = 13;export const SIZE_MIN = 10;export const SIZE_MAX = 20;
export const TEXT_DEFAULTS: Text = { ui: BASE_SIZE, canvas: BASE_SIZE, own: false };
/** A whole px inside the sliders' range, or the fallback when `value` is not a finite number. */function readSize(value: unknown, fallback: number): number { return typeof value === 'number' && Number.isFinite(value) ? Math.min(SIZE_MAX, Math.max(SIZE_MIN, Math.round(value))) : fallback;}
/** Saved text sizes from untrusted JSON, with defaults for anything missing or invalid. */export function readText(value: unknown): Text { const given = (value && typeof value === 'object' ? value : {}) as Partial<Text>; return { ui: readSize(given.ui, TEXT_DEFAULTS.ui), canvas: readSize(given.canvas, TEXT_DEFAULTS.canvas), own: given.own === true };}
/** The custom properties to set on <html>; `--canvas-scale` equals `--ui-scale` unless `own`. */export function textScales(text: Text): Record<string, string> { return { '--ui-scale': String(text.ui / BASE_SIZE), '--canvas-scale': String((text.own ? text.canvas : text.ui) / BASE_SIZE) };}