Gosub Browser Progress, pt40

Created at 2025-01-13 13:43:06 (1 day ago)

So my planning went completely sideways, as per usual.

I started with doing a little bit of work on rendering some typography to make it a bit better, and ended with writing a multi-source font manager system.

Both the vello and cairo backend render systems are using a very different font system and I wanted to see if we can actually make that a bit better so i don't have to change two backend systems when dealing with font issues. Turns out that isn't that easy (as nothing is, obviously).

Right now, we have a font system proof-of-concept that can be used for both vello and cairo backends. And most likely different backends as well. Having something generic is a bit tricky, because different libraries uses different ways of dealing with fonts, and not only do we need to keep in mind the backend renderer, also we must make sure our layouting system (taffy) can work with the same font.

Unfortunately, we cannot use fonts interchangebly. It would have been nice to have one single font system that could be used for everything. Instead, we load fonts from different sources (parley / fontique, fontkit, pango) and you can select which "type" of font you need. So when dealing with gtk, you need pango fonts for instance.

What makes this abstraction a bit nicer, is that you have one single point on asking for fonts. So when asking for "Arial Bold", it can load this font from the various sources and still provide the same font via different resources. Downside is that fonts are loaded multiple times in memory as the pango Arial Bold font is a different structure as the fontique's Arial Bold font. For now we just keep it that way, but we can look into this more in-depth and see if we can share font resources (as ultimately, they are (mmap'ed) blobs which could be shared. It took too much effort to dive into this at this moment, so at least now we have a functional, yet not very optimized system.

Since we are a proof-of-concept, next steps is to incorporate this into the engine (most likely in a gosub_font crate), and implement it at the different renderers and layouters. Bonus points: since we can detect which font family we need to use for a DOM text node, we can actually have webpages rendered in their correct font (although, we don't do woff yet).

gosub rust font

About jaytaph

Codemuser extraordinaire

avatar Loves building crazy and insane stuff. Happiest when left alone. All I wanted was a Pepsi, just a Pepsi.
Joined:March 24, 2023
Following:2
Followers:2
Posts:53
Comments:3
Upvotes:4
RSS feed