Projects / 03
oglyph
Fonts and text shaping in native Odin. It reads TrueType and OpenType fonts and shapes text with them the way HarfBuzz does, and is tested against HarfBuzz.
- Odin
- MIT
- core: only
- HarfBuzz 14.6
- Unicode 17.0.0

Where it came from
oglyph was ovg's font and shape packages until ovg v0.0.23, and their history is in ovg's repository. ovg draws its text through oglyph, so onimite does too. Bidi and line breaking are left to the caller (ovg orders right-to-left runs itself).
By the numbers
- differences from HarfBuzz
- 0
- glyphs, clusters, advances and offsets: 1,043 curated, 27,118 feature-set, 24,400 random and 384 variable-instance cases
- random strings over 40 downloaded fonts
- 51,600
- Google and SIL fonts for Arabic, Indic, Myanmar, Khmer, Korean and more; 0 differences
- HarfBuzz's time
- 0.96×
- on the 1,043 curated cases, one core; Arabic sentences alone take 1.06–1.10×
- of HarfBuzz's shapers
- 9
- Arabic, Hebrew, Thai, Hangul, Indic, Khmer, Myanmar, USE and the default
tools/shape_corpus at v0.0.5 against the system libharfbuzz 14.6.0 (its OpenType shaper) on Arch Linux, re-run 2026-10-24; the curated count depends on which of the tool's fonts are installed. Time: its -bench (each a median of 15 alternating runs) at v0.0.5, 0.96–0.97× in four runs alternated with v0.0.4 (0.98–0.99× in the same runs), at -o:speed on one core of a Ryzen 9 9900X3D; the sentence figures are the README's, on a busy machine.
What's in it
01Fonts
A face's tables, the character map (cmap formats 0, 4, 6, 12 and 13, and variation sequences), metrics, kerning from the kern table and GPOS pairs, glyf outlines with composites, CFF and CFF2 charstrings, names (family, subfamily, and a variable font's axis and instance names) and glyph names, and the characters a face maps.
02Variable fonts
fvar's axes and named instances, avar versions 1 and 2, gvar, HVAR and CFF2 blends. set_variations or set_coords picks an instance, and outlines, advances and shaping follow it; ovg draws a chosen instance since v0.0.24.
03HarfBuzz's shapers
The default, Arabic, Hebrew, Thai, Hangul, Indic, Khmer and Myanmar shapers and the Universal Shaping Engine, with HarfBuzz's syllable machines, and Unicode properties, script runs and normalization from the Unicode 17.0.0 character database.
04GSUB and GPOS
Substitution and positioning lookups, the legacy kern table, fallback mark positioning, features set over all or part of the text, and variable fonts' FeatureVariations and device deltas.
05Three owners
A Layout per face, read-only while shaping; a Plan per script, direction, language and set of features; a Shaper per call at a time. A warm shaper allocates nothing.
06Only the lookups that can apply
A plan knows which lookups can start at each glyph, so a shaping call visits only those lookups, and each lookup only the positions where it can start.
07Untrusted fonts
Every read is bounds-checked: a corrupt or truncated font gives wrong glyphs or a load error, never a read out of bounds. Work is bounded by the font's own data and by HarfBuzz's limits, and the tests mutate real fonts' tables and shape and draw them.
08Checked against HarfBuzz
tools/shape_corpus compares every glyph, cluster, advance and offset with the system libharfbuzz; tools/shape_unicode regenerates the Unicode and syllable tables from HarfBuzz's source. Before v0.0.1's fixes and speed work, an independent verification run of an earlier build agreed with HarfBuzz on every glyph and cluster of 1.45 million random strings in 38 scripts, and its outlines at variable instances with an unrounded fontTools oracle within 0.001 units over 2.4 million glyph instances.
09About HarfBuzz's speed
On one core, oglyph shapes the 1,043 curated cases in 0.96× HarfBuzz's time. The README's own timing on Noto fonts, both in one process taking turns: words and random strings 0.66–0.90× and Latin sentences 1.00×, but Arabic sentences 1.06–1.10×, Devanagari sentences 0.99–1.04× and Devanagari words 1.02–1.03×.
Where it differs from HarfBuzz
- Arabic fonts without GSUB aren't shaped from presentation forms (HarfBuzz's fallback).
- Mongolian variation selectors in text shaped as Arabic.
- gvar advances within about 0.0001 of a half unit, which oglyph sums exactly where HarfBuzz rounds in single precision.
Use it
import ft "deps:oglyph/font" // -collection:deps=.. (the directory holding oglyph)
import sh "deps:oglyph/shape"
face, err := ft.load(font_bytes) // the bytes are borrowed
layout: sh.Layout // the face's tables, prepared once
sh.layout_init(&layout, &face)
plan: sh.Plan // per script, direction, language, features
sh.plan_init(&plan, &layout, &face, .Latin, .LTR)
shaper: sh.Shaper // the glyph buffer, kept warm
sh.shaper_init(&shaper)
glyphs: [dynamic]sh.Glyph
sh.shape(&shaper, &plan, &face, text_runes, nil, &glyphs) // visual orderodin test font -vet -strict-style
odin test shape -vet -strict-style
odin run tools/shape_corpus -o:speed -- -quiet # against the system libharfbuzz
odin run tools/shape_corpus -o:speed -- -feature-sets -quiet
odin run tools/shape_corpus -o:speed -- -random:200 -quiet
perl tools/shape_unicode/gen.pl HARFBUZZ/src > shape/unicode_data.odin # from HarfBuzz 14.6.0's sourceThe family
- ocurves
Curve geometry: exact pixel coverage, and booleans that keep their curves
- ovg
2D vector graphics: paths, SVG, Lottie, text, filters
- oglyph
Fonts and OpenType text shaping, checked against HarfBuzz
- oicut
Video, audio and image codecs with no FFmpeg
- oksl
SkSL and Shadertoy shaders to SPIR-V, MSL and CPU
- o3d
3D in three.js terms, on the GPU or the CPU
- ottis
Text to speech with a time for every word
- odawg
Music from songs as data: synths, sampled instruments, an 808, a 909 and a 303, mixed and mastered
- onimite
Videos from Lua scripts, written by you or your coding agent