• 1 Post
  • 76 Comments
Joined 2 years ago
cake
Cake day: June 20th, 2023

help-circle





  • HarfBuzz does opentype shaping, that is, transforming strings of unicode characters to lists of glyphs with positioning. The significance of this can be hard to understand for someone used to the latin script, as that needs very little shaping - kerning is often the only thing that’s absolutely necessary.

    But in complex scripts, most notably the Indic, there’s a lot going on. Unicode characters can merge into one glyph under circumstances, or one character can split into several, and relative positioning in both the x and y axis is imperative.

    A reason that OpenType shaping is complex is that part of the rules for what to do will be found in the font, and part will need to be hard-coded in the code implementing it.

    If you’re going to roll your own text renderer, you’ll have to care about the following areas:

    • Rasterization/rendering to bitmaps, including hinting (notoriously difficult, old-style TrueType hinting instructions are bytecode, so you’ll be writing a tiny VM for this)
    • Shaping (Kerning at a minimum, full OpenType shaping for international support)
    • BiDi (for full international support, primarily Hebrew and Perso-Arabic)
    • A caching system for rendered text glyphs and shaped text runa, as it will be too slow to perform this each time you want to render some text

    Let’s just say that I do not recommend going this route unless you’re prepared to spend a lot of time on it.