Having an absolutely wild Saturday evening investigating Unicode combining characters. Lagrange currently utterly fails to render these. A special layout algorithm that adapts to any number of combined extra glyphs is needed.
I haven't thrown in the towel yet, but falling back to using an existing library is always an option...
After a while it became evident that trying to write my own text shaping engine would be a monumental project of its own. And since HarfBuzz already exists, quite a waste a time...
So I've gradually been integrating HarfBuzz into Lagrange's text renderer. There are still a few issues with the current set of fonts not containing all combining glyphs.
Next step: FriBidi for dealing with RTL scripts.
Looks like FriBidi is doing its thing!
(i.e., applying the Unicode Bidirectional Algorithm)
Still need to optimize the text handling a bit to avoid repeated processing of static strings, e.g., UI labels. Text selection is also a bit wonky over RTL runs...
HarfBuzz & FriBidi mean a big step forward in supporting complex scripts. The final big issue remaining is expanding the collection of available fonts.
It's a bit of a challenge to call FriBidi at the right time. I'll need to refactor the document layout somewhat so the text renderer has visibility to the full paragraph and can process it in one go. At the moment it's more of a line-based operation, which makes it more challenging to apply alignment (and justification).
Maybe now? 😅
Support for bidi text and complex scripts has landed in the #Lagrange dev branch.
I had to make a few more fixes for actual bidi typesetting (direction changes inside the paragraph), but it's starting to look acceptable now.
There was a final wrinkle where HarfBuzz wasn't detecting the script correctly, leading to some Arabic glyphs being wrong. It remains to be seen whether this is a problem with other complex scripts as well.
@jk congrats on working on this hard problem, it's really important and often overlooked. I'm glad it's not in my domain with Amfora ;)
skyjake's personal Mastodon instance