Recursive AI
LibraryC#Available

onefont

Fonts and text shaping for .NET, in C# with no dependency beyond .NET itself. Load a font, shape a run of text, and get glyphs, advances, offsets and clusters back.

dotnet add package RecursiveAI.OneFont

A quick look

Shape Arabic, Indic or Latin text with the font’s own OpenType tables. A fallback chain shapes each cluster with the first face that has its character.

The shaping rules
Program.csC#
using OneFont;
 
byte[] font = File.ReadAllBytes("arabic.ttf");
FontFace face = FontFace.Load(font);
 
// Glyphs, advances and offsets, by cluster.
foreach (ShapedCluster c in TextShaping.ShapeRun(text, face, rightToLeft: true))
    foreach (ShapedGlyph g in c.Glyphs)
        GlyphOutline o = face.GetOutline(g.GlyphId);
 
// Where a line may end.
var breaks = TextSegmentation.GetLineBreakOpportunities(text);
What it does

What it does

Fonts

TrueType, OpenType with CFF outlines and TrueType Collections. Every read is bounds-checked, and glyph outlines come out as move, line, quadratic and cubic segments.

Shaping

OpenType GSUB and GPOS with every lookup type and flag, and shapers for Arabic, the Indic scripts, Khmer, Myanmar, Tibetan and the other Universal Shaping Engine scripts, and Thai and Lao.

Unicode

Bidi levels and visual order (UAX #9), line break opportunities (UAX #14) and grapheme boundaries (UAX #29), on Unicode 17.

Safe on fonts you didn’t make

Safe code only. Work, depth and growth budgets keep hostile fonts cheap, and a fuzz target runs them through the whole public surface.

The package

Go further