AtelierText
Unicode to positioned SVG outlines.
Text placed in an SVG depends on the fonts of whoever opens it. This package removes that
dependency: it reads a font file, looks each codepoint up in its cmap, positions the glyphs,
and returns their outlines as path data. What ships is geometry, and geometry renders the same
everywhere.
Features
- Outlines, not text elements
Path data from the font's own contours, so nothing depends on what is installed where the drawing is opened. - One group per glyph
Each carries adata-charattribute, andidPrefixmakes the ids deterministic, which is what a stylesheet or an animation needs to address a single letter. - Placement is arguments
x,baselineY,letterSpacingandwordSpacingare parameters of the call, not post-processing.baselineYis the line the glyphs sit on, not the top of the text. - A file or a query
fromFile()takes a path;fromFinder()takes aFontQueryof family, weight and style against a directory of fonts. - A seam for real shaping
The built-in mapper is onecmaplookup per codepoint.TextShaperInterfaceis where a shaping engine plugs in, and everything downstream consumes itsGlyphRun. - A missing glyph throws
MissingGlyphExceptionrather than a blank where a letter should be. A size that is not finite and positive throws too.
Draw a word as path data
use Atelier\Text\SvgText;
$path = SvgText::fromFile('Inter-Regular.woff2')
->path('Atelier', size: 64, baselineY: 72);
echo $path->d();
d() is the combined outline of the whole run, ready to drop into a drawing you are already
building.
Get a whole document
$svg = SvgText::fromFile('Inter-Regular.woff2')
->svg('Atelier', size: 64, idPrefix: 'headline');
echo $svg->toPrettyString();
An atelier/svg document, one group per glyph. Passing idPrefix makes those ids deterministic,
so headline-glyph-0 can be targeted from CSS or animated.
Choose a font by query
use Alto\Font\FontFinder;
use Alto\Font\FontQuery;
$finder = FontFinder::fromDirectories(__DIR__.'/fonts');
$font = SvgText::fromFinder($finder, FontQuery::family('Inter')->weight(700));
$path = $font->path('Atelier', size: 64);
What it does not do
One cmap lookup per codepoint, left to right. No font fallback, no bidirectional text, no
ligatures, no kerning, no script shaping. That is a boundary, not a gap: everything downstream
consumes a GlyphRun, so a real shaping engine replaces the mapper without touching the rest.
A codepoint the font has no glyph for throws MissingGlyphException rather than rendering a
blank.
Documentation
Start
- Installation: install Atelier Text and its font dependency.
- Getting started: turn a font and a string into positioned outlines.
Fonts and output
- Fonts: load a font file or select one with a family, weight, and style query.
- Outlines: inspect combined path data and per-glyph geometry.
- Documents: create an Atelier SVG document with addressable glyph groups.
Text behavior
- Shaping: understand the built-in mapper and plug in a shaping engine.
- Errors: handle missing glyphs, invalid sizes, and unreadable font sources.