@liiift-studio/cedars-engine
v1.0.0
Published
Compute a font's CEDARS+ typographic profile (Contrast, Energy, Details, Axis, Rhythm, Structure) from its outline geometry. Framework-agnostic; runs in the browser and Node.
Readme
@liiift-studio/cedars-engine
Compute a font's CEDARS+ typographic profile — Contrast, Energy, Details, Axis, Rhythm, Structure — directly from its outline geometry. Framework-agnostic; runs in the browser and in Node.
Inspired by I Love Typography's CEDARS system. This is the shared engine behind the CEDARS Analyzer app and the @liiift-studio/sanity-font-manager auto-tagging step.
Install
npm install @liiift-studio/cedars-engineopentype.js is a runtime dependency (peer of the geometry parser).
Usage
import { analyzeFont } from "@liiift-studio/cedars-engine";
// buffer: ArrayBuffer from a File (browser) or fs.readFileSync (Node)
const profile = analyzeFont(buffer);
profile.scores; // { contrast, energy, details, axis, rhythm, structure } each 0..100
profile.labels; // human-readable per axis, e.g. { contrast: "extreme", axis: "vertical" }
profile.vector; // normalized [C,E,D,A,R,S] 0..1 — for similarity / pgvector search
profile.plus; // { xHeightRatio, capHeightRatio, isMonospaced }
profile.diagnostics; // raw measurements per axis (for overlays / debugging)Lower-level entry points are also exported: parseFont(buffer) → FontContext, analyzeProfile(ctx), and the similarity helpers euclidean, cosineDistance, nearest.
What each axis measures
| Axis | Glyph | Measurement |
|------|-------|-------------|
| Contrast | o | p95/p5 of stroke thickness sampled around the bowl |
| Energy | n h m | arch shoulder span relative to x-height (uppercase-only faces return unavailable) |
| Details | I | stem-end flare vs mid-stem width (serif prominence) |
| Axis | o | angle of the thinnest bowl diameter, offset from vertical (stress) |
| Rhythm | n | advance width relative to x-height (condensed ↔ extended) |
| Structure | o | bowl fill ratio (area / bounding box) |
Calibration anchors (raw geometry → 0–100) live in src/constants.ts, set from a 110-font reference corpus. Energy and Details are geometric heuristics and the softest axes; the rest are robust.
License
MIT © Liiift Studio
