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.
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).
The BiDi quest continues.
I now have the ability to wrap an entire paragraph in one go while also having FriBidi tell me the directions.
My initial attempt is going badly. Wrapping the entire paragraph in visual order means that the first wrapped line covers the end of the paragraph.
Back to the drawing board… Seems like wrapping needs to be done in logical order and only the drawing in visual order.
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