### Goals 1. **Accurate font selection**: OS APIs don't guarantee a registered font will be used. This finally fixes a huge pain point. 2. **Ability to register fonts from a buffer**: should be possible without Pango 3. **Performance**: This should be faster than going through Pango. 4. **Reduce dependencies**: Pango brings in a lot, and we don't need most of its functionality (e.g. there's no wrapping in canvas). 5. **Context-aware** (#1394): registered fonts will be associated with the module instance. 6. **Fast and native**: this will all be done in C++ 7. **Static build**: since we rid ourselves of so many system deps, this is the time to move to `zig build` ### Non-goals 1. Only OpenType will be supported 2. Not going to cache shaping results 3. We're going to have to drop SVG support, at least for the short-term ### Changes 1. [x] Native `font` parser that can be used by `FontFace`: #2475 2. [x] HarfBuzz-based font stack (see below). This is the biggest part. 3. [x] Change API: implement only the relevant parts of [CSS Font Loading Module Level 3](https://www.w3.org/TR/css-font-loading/) (`FontFace` and `Canvas.fonts`) 4. [ ] New API: `ctx.fillGlyphs`. This is actually my biggest goal because it will significantly speed up dropflow and libraries like it. ### HarfBuzz-based font stack Without Pango, we need to write a lot: 1. [x] **Script segmentation**: use dropflow's trie writer. Reading it is easy to do in C++. Port the logic from dropflow. 2. [x] **Bidi segmentation**: use SheenBidi and port dropflow's logic. 3. [x] **Emoji segmentation**: could skip for first version if emojis work well enough, but also port from dropflow and add ragel to build. 4. [x] **System fonts**: walk entries in the OS and add to our own db, hopefully avoiding `open()`. Port from Pango and/or use LLMs. 5. [x] **Font selection**: port this from dropflow, which implements it as specified by W3C. Use HarfBuzz to read font tables. 6. [x] **Font shaping**: grapheme-based font fallbacks, bidi reordering, format for `cairo_show_glyphs`. Also update metrics functions.
Goals
zig buildNon-goals
Changes
fontparser that can be used byFontFace: Native font parser #2475FontFaceandCanvas.fonts)ctx.fillGlyphs. This is actually my biggest goal because it will significantly speed up dropflow and libraries like it.HarfBuzz-based font stack
Without Pango, we need to write a lot:
open(). Port from Pango and/or use LLMs.cairo_show_glyphs. Also update metrics functions.