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).

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.

Follow

@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 ;)

Sign in to participate in the conversation
Sunbeam City 🌻

Sunbeam City is a anticapitalist, antifascist solarpunk instance that is run collectively.