Parser and renderer for .lettering stroke-based font files.
Lingenic Lettering provides a human-readable format for defining stroke-based fonts. Unlike outline fonts (TrueType, OpenType), stroke fonts define glyphs as pen strokes along paths, enabling:
- Simpler glyph definitions
- Variable stroke width
- Calligraphic effects
- Efficient monospace and technical fonts
- Lingenic Pen-Path — 2D stroke graphics primitives
.font-begin FontName
units-per-em 1000
ascender 800
descender -200
.circular-pen-begin main
diameter 80
.circular-pen-end
.glyph-begin A U+0041
advance-width 650
stroke main 50,0 ⏤ 325,700 ⏤ 600,0
stroke main 150,250 ⏤ 500,250
.glyph-end
.font-end
| Model | Description | Syntax |
|---|---|---|
| A | Uniform pen width | stroke pen path |
| B | Explicit diameter per point | 30,0⌀150 ⏤ 325,700⌀100 |
| C | Width track (separate array) | stroke pen path [widths] |
| Symbol | Name | Description |
|---|---|---|
⏤ |
Line | Straight segment |
⌒ |
Curve | Smooth curve (Hobby's algorithm) |
∠ |
Corner | Sharp angle break |
↻ |
Cycle | Close path to start |
- Circular:
.circular-pen-begin name - Elliptical:
.elliptical-pen-begin name - Rectangular:
.rectangular-pen-begin name
use lettering::parse::parse;
use lettering::render::{render_glyph_to_svg, render_text};
use pen_path::Color;
// Parse a .lettering file
let source = std::fs::read_to_string("myfont.lettering")?;
let font = parse(&source)?;
// Render a glyph to SVG
if let Some(glyph) = font.get_glyph(0x0041) {
let svg = render_glyph_to_svg(&font, glyph, Color::BLACK);
}
// Render text to PDF operators
let pdf_ops = render_text(
&font,
"Hello",
0, // x position
72000, // y position (1 inch from bottom)
7200, // 1 inch tall
Color::BLACK,
792 * 100, // page height (11 inches)
);parse— Tokenizer and parserfont— Font structure and metricsglyph— Glyph, stroke, and fill definitionspen— Pen definitionspath— Stroke paths with modifiersrender— SVG and PDF output
Apache-2.0
Lettering is a component of the 「」 Lingenic Compose typesetting system.