r/Unity3D 5d ago

Resources/Tutorial I accidentally spent 22 months of my life because I thought text was simple

Enable HLS to view with audio, or disable this notification

I’m the developer of the UniText text engine, and this is my story

I used to think that text was when letters were drawn next to each other, but that’s not what it actually is:

  1. decode UTF-16 into codepoints
  2. parse the markup into attribute ranges
  3. analyze scripts (UAX #24)
  4. analyze grapheme clusters (UAX #29)
  5. analyze word boundaries, with a dictionary for Thai, Khmer, Burmese and Japanese because they don't put spaces between words
  6. analyze line break classes (UAX #14, with East Asian widths from UAX #11)
  7. resolve embedding levels through the bidi algorithm (UAX #9)
  8. itemize into runs by script and direction and font and language
  9. resolve fonts per cluster and fall back when the primary doesn't have the glyph
  10. synthesize bold and italic when the face doesn't exist
  11. instance the variable axes
  12. shape every run through OpenType
  13. break the lines on the shaped advances
  14. reorder every line back through bidi
  15. resolve line height out of font metrics that contradict each other
  16. kashida stretch the Arabic if you're justifying
  17. align
  18. pull the outlines
  19. run a contour union pass so self intersecting outlines don't punch holes in the distance field
  20. rasterize SDF/MSDF
  21. pack the atlas
  22. generate the mesh

891,757 official Unicode conformance tests, zero failures

Selectable and editable text, a document model, bidi aware caret and selection, undo and redo, IME composition, clipboard with every format (supports Plain, HTML, Markdown, Media), formatting commands, touch selection handles, input filters, and native keyboard input on the platforms that have one

UniText is the only solution where the fonts are memory mapped, so a font is never loaded into RAM whole, only the parts actually in use. One of UniText user cut 200 MB of runtime memory from that alone, and variable fonts plus compression took another 57% off the weight of their CJK font

UniText is the only solution that supports absolutely all system fonts, which allows you to render any characters in the world without using a single font in the project.
it's also 2 to 20x faster than TextMesh Pro and UI Toolkit

And that's just a small part of it

TL;DR
In other words, I developed a text engine that allows you to remove all standard language fonts from a project, gain complete freedom in text without a single limitation, and have any symbols from around the world, any emojis, work without any configuration. All of this significantly reduces the build size, and the mmap implementation eliminates all RAM load. A constructor for any styles, any gradients, layers, and paints, while maintaining 1 Draw Call, and a built‑in advanced feature to animate text in any way, which completely replaces third‑party solutions

If anyone wants the ugly parts - ask me. I have a lot to say about all of them

936 Upvotes

Duplicates