# saberbird/linefont architecture

> Architecture diagram of the GitHub repository saberbird/linefont, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saberbird/linefont
- Repository: https://github.com/saberbird/linefont

## Overview

lineFONT is a single-line vector-font layout library with JavaScript/WASM and Rust/C integration surfaces, bundled fonts, and authoring/preview utilities. The main workflow is an application supplying text, a font stack, and layout options to the JS API; the WASM-backed Rust engine resolves glyphs and produces strokes, metrics, and carets. Separate branches cover font validation/conversion/coverage and printable or interactive previews. The graph uses documented relationships and sampled imports/calls; unsampled tool internals are not assumed.

Main entry points: [`tools/preview-specimen.mjs`](https://github.com/saberbird/linefont/blob/main/tools/preview-specimen.mjs) (SVG specimen), [`bindings/js/index.ts`](https://github.com/saberbird/linefont/blob/main/bindings/js/index.ts) (JavaScript API), [`tools/preview-detail.mjs`](https://github.com/saberbird/linefont/blob/main/tools/preview-detail.mjs) (Glyph detail), [`tools/preview-html.mjs`](https://github.com/saberbird/linefont/blob/main/tools/preview-html.mjs) (HTML generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Layout runtime"]
  node_js_api["JavaScript API<br/>[index.ts]"]
  node_wasm_binding["WASM binding<br/>[wasm.mjs]"]
  node_layout_engine["Layout engine<br/>[lib.rs]"]
  node_geometry["Geometry utilities<br/>[geometry.rs]"]
  node_diagnostics["Diagnostics<br/>[diagnostic.rs]"]
end

subgraph group_fonts["Font resources"]
  node_font_stack["Font stack<br/>[index.ts]"]
  node_ua_font["Ukrainian-English font<br/>[bagling-font.mjs]"]
  node_greek_font["Greek font<br/>[greek-font.mjs]"]
end

subgraph group_authoring["Font authoring"]
  node_validation["Font validation"]
  node_conversion["Font conversion"]
  node_coverage["Glyph coverage"]
end

subgraph group_preview["Preview tools"]
  node_preview_cli["Preview CLI"]
  node_specimen["SVG specimen"]
  node_html_preview["HTML generator<br/>[preview-html.mjs]"]
  node_browser_viewer["Browser viewer"]
  node_glyph_detail["Glyph detail<br/>[preview-detail.mjs]"]
  node_translations["Translations<br/>[preview-i18n.mjs]"]
  node_xml_escape["XML escaping<br/>[preview-xml.mjs]"]
end

node_application(("Application"))

node_application -->|"supplies layout input"| node_js_api
node_js_api -->|"calls WASM"| node_wasm_binding
node_wasm_binding -.->|"dispatches requests"| node_layout_engine
node_layout_engine -->|"uses geometry"| node_geometry
node_layout_engine -->|"creates diagnostics"| node_diagnostics
node_application -->|"provides font stack"| node_font_stack
node_font_stack -->|"can include"| node_ua_font
node_font_stack -->|"can include"| node_greek_font
node_application -->|"validates fonts"| node_validation
node_application -.->|"converts font paths"| node_conversion
node_application -.->|"checks glyph coverage"| node_coverage
node_application -->|"requests preview"| node_preview_cli
node_preview_cli -->|"renders specimen"| node_specimen
node_preview_cli -->|"generates HTML"| node_html_preview
node_specimen -->|"calls layout"| node_js_api
node_specimen -->|"queries ink bounds"| node_geometry
node_html_preview -->|"embeds viewer"| node_browser_viewer
node_html_preview -->|"embeds specimen source"| node_specimen
node_html_preview -->|"escapes markup"| node_xml_escape
node_browser_viewer -.->|"uses runtime API"| node_js_api
node_glyph_detail -->|"calls layout"| node_js_api
node_glyph_detail -->|"queries ink bounds"| node_geometry
node_glyph_detail -->|"translates labels"| node_translations
node_glyph_detail -->|"escapes labels"| node_xml_escape
node_specimen -->|"translates labels"| node_translations
node_specimen -->|"escapes markup"| node_xml_escape

click node_js_api "https://github.com/saberbird/linefont/blob/main/bindings/js/index.ts"
click node_wasm_binding "https://github.com/saberbird/linefont/blob/main/bindings/js/wasm.mjs"
click node_layout_engine "https://github.com/saberbird/linefont/blob/main/core/src/lib.rs"
click node_geometry "https://github.com/saberbird/linefont/blob/main/core/src/geometry.rs"
click node_diagnostics "https://github.com/saberbird/linefont/blob/main/core/src/diagnostic.rs"
click node_font_stack "https://github.com/saberbird/linefont/blob/main/bindings/js/index.ts"
click node_ua_font "https://github.com/saberbird/linefont/blob/main/bindings/js/bagling-font.mjs"
click node_greek_font "https://github.com/saberbird/linefont/blob/main/bindings/js/greek-font.mjs"
click node_validation "https://github.com/saberbird/linefont/blob/main/tools/validate-linefont.mjs"
click node_conversion "https://github.com/saberbird/linefont/blob/main/tools/convert-linefont.mjs"
click node_coverage "https://github.com/saberbird/linefont/blob/main/tools/coverage-linefont.mjs"
click node_preview_cli "https://github.com/saberbird/linefont/blob/main/tools/preview-linefont.mjs"
click node_specimen "https://github.com/saberbird/linefont/blob/main/tools/preview-specimen.mjs"
click node_html_preview "https://github.com/saberbird/linefont/blob/main/tools/preview-html.mjs"
click node_browser_viewer "https://github.com/saberbird/linefont/blob/main/tools/preview-browser.mjs"
click node_glyph_detail "https://github.com/saberbird/linefont/blob/main/tools/preview-detail.mjs"
click node_translations "https://github.com/saberbird/linefont/blob/main/tools/preview-i18n.mjs"
click node_xml_escape "https://github.com/saberbird/linefont/blob/main/tools/preview-xml.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_js_api,node_wasm_binding,node_layout_engine,node_geometry,node_diagnostics toneBlue
class node_font_stack,node_ua_font,node_greek_font toneAmber
class node_validation,node_conversion,node_coverage toneMint
class node_preview_cli,node_specimen,node_html_preview,node_browser_viewer,node_glyph_detail,node_translations,node_xml_escape toneRose
class node_application toneIndigo
```

## Components

### Layout runtime

- [JavaScript API](https://github.com/saberbird/linefont/blob/main/bindings/js/index.ts): `bindings/js/index.ts`
- [WASM binding](https://github.com/saberbird/linefont/blob/main/bindings/js/wasm.mjs): `bindings/js/wasm.mjs`
- [Layout engine](https://github.com/saberbird/linefont/blob/main/core/src/lib.rs): `core/src/lib.rs`
- [Geometry utilities](https://github.com/saberbird/linefont/blob/main/core/src/geometry.rs): `core/src/geometry.rs`
- [Diagnostics](https://github.com/saberbird/linefont/blob/main/core/src/diagnostic.rs): `core/src/diagnostic.rs`

### Font resources

- [Font stack](https://github.com/saberbird/linefont/blob/main/bindings/js/index.ts): `bindings/js/index.ts`
- [Ukrainian-English font](https://github.com/saberbird/linefont/blob/main/bindings/js/bagling-font.mjs): `bindings/js/bagling-font.mjs`
- [Greek font](https://github.com/saberbird/linefont/blob/main/bindings/js/greek-font.mjs): `bindings/js/greek-font.mjs`

### Font authoring

- [Font validation](https://github.com/saberbird/linefont/blob/main/tools/validate-linefont.mjs): `tools/validate-linefont.mjs`
- [Font conversion](https://github.com/saberbird/linefont/blob/main/tools/convert-linefont.mjs): `tools/convert-linefont.mjs`
- [Glyph coverage](https://github.com/saberbird/linefont/blob/main/tools/coverage-linefont.mjs): `tools/coverage-linefont.mjs`

### Preview tools

- [Preview CLI](https://github.com/saberbird/linefont/blob/main/tools/preview-linefont.mjs): `tools/preview-linefont.mjs`
- [SVG specimen](https://github.com/saberbird/linefont/blob/main/tools/preview-specimen.mjs): `tools/preview-specimen.mjs`
- [HTML generator](https://github.com/saberbird/linefont/blob/main/tools/preview-html.mjs): `tools/preview-html.mjs`
- [Browser viewer](https://github.com/saberbird/linefont/blob/main/tools/preview-browser.mjs): `tools/preview-browser.mjs`
- [Glyph detail](https://github.com/saberbird/linefont/blob/main/tools/preview-detail.mjs): `tools/preview-detail.mjs`
- [Translations](https://github.com/saberbird/linefont/blob/main/tools/preview-i18n.mjs): `tools/preview-i18n.mjs`
- [XML escaping](https://github.com/saberbird/linefont/blob/main/tools/preview-xml.mjs): `tools/preview-xml.mjs`

### Other components

- **Application**

## Connections

- Application → JavaScript API: supplies layout input (evidence: `README.md`)
- JavaScript API → WASM binding: calls WASM (evidence: `bindings/js/index.ts`)
- WASM binding → Layout engine: dispatches requests
- Layout engine → Geometry utilities: uses geometry (evidence: `core/src/lib.rs`)
- Layout engine → Diagnostics: creates diagnostics (evidence: `core/src/lib.rs`)
- Application → Font stack: provides font stack (evidence: `README.md`)
- Font stack → Ukrainian-English font: can include
- Font stack → Greek font: can include
- Application → Font validation: validates fonts (evidence: `README.md`)
- Application → Font conversion: converts font paths
- Application → Glyph coverage: checks glyph coverage
- Application → Preview CLI: requests preview (evidence: `README.md`)
- Preview CLI → SVG specimen: renders specimen (evidence: `tools/preview-linefont.mjs`)
- Preview CLI → HTML generator: generates HTML (evidence: `tools/preview-linefont.mjs`)
- SVG specimen → JavaScript API: calls layout (evidence: `tools/preview-specimen.mjs`)
- SVG specimen → Geometry utilities: queries ink bounds (evidence: `tools/preview-specimen.mjs`)
- HTML generator → Browser viewer: embeds viewer (evidence: `tools/preview-html.mjs`)
- HTML generator → SVG specimen: embeds specimen source (evidence: `tools/preview-html.mjs`)
- HTML generator → XML escaping: escapes markup (evidence: `tools/preview-html.mjs`)
- Browser viewer → JavaScript API: uses runtime API
- Glyph detail → JavaScript API: calls layout (evidence: `tools/preview-detail.mjs`)
- Glyph detail → Geometry utilities: queries ink bounds (evidence: `tools/preview-detail.mjs`)
- Glyph detail → Translations: translates labels (evidence: `tools/preview-detail.mjs`)
- Glyph detail → XML escaping: escapes labels (evidence: `tools/preview-detail.mjs`)
- SVG specimen → Translations: translates labels (evidence: `tools/preview-specimen.mjs`)
- SVG specimen → XML escaping: escapes markup (evidence: `tools/preview-specimen.mjs`)
