Soft Type
- group .........
- Text effects
- source ........
- https://ui.aryank.space/components/soft-type
- markdown ......
- /lab/soft-type.md
- human .........
- /lab/soft-type
── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────
Lettering you type into. Each character is traced from Nunito Black down to its centreline and rebuilt as a chain of particles, so letters press against each other, stretch when you drag them, and pop when you press and hold. The tracing works on any glyph the device can draw, from Latin and Cyrillic to Han and Hangul, and every counter stays open because each letter's pen only fattens until a hole would close. Emoji become soft circles. Canvas 2D, no dependencies.
── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────
* Letters are traced, not stored
Each character is drawn once in Nunito Black on a hidden canvas, thinned to a one-pixel centreline and traced into strokes. The distance transform along that centreline gives the pen radius. A rounded heavy letter is almost exactly a centreline swept by a round pen, so the rebuilt tube matches the font, and it works for any glyph the device can draw.
* Short arms survive, corner spurs do not
Thinning grows little branches into square corners. A real stroke ends at the centre of its round cap, a pen radius inside the ink; a spur runs out to the edge. Pruning by that depth keeps the crossbar of an f and the arms of a star while removing spurs from square-ended fallback fonts.
* As bold as it can go with counters open
Each letter's pen fattens toward the weight setting, then stops where a counter would close or lose half its area, or where an aperture like the mouth of an s would seal shut. That is why o goes heavier than e.
* Grabbing pins one particle
The particle nearest the pointer follows it exactly and the rest of the letter gets a fifth of the same motion. Distance links, a bending constraint and a shape spring with no rotation term do the rest, so a letter stretches and drags its neighbours but always swings back upright.
* Editing keeps the letters you did not touch
New text is matched against the letters on screen by common prefix and suffix, so typing in the middle only grows or shrinks the changed letters. After each edit every letter springs to its new slot for about four seconds, then the arrangement is yours to push around.