Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font stack rewrite #2476

Open
1 of 4 tasks
chearon opened this issue Dec 29, 2024 · 0 comments
Open
1 of 4 tasks

Font stack rewrite #2476

chearon opened this issue Dec 29, 2024 · 0 comments

Comments

@chearon
Copy link
Collaborator

chearon commented Dec 29, 2024

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 (make module 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: HarfBuzz and SheenBidi are easy to build, so we could add a vendor folder

Non-goals

  1. Only OpenType will be supported
  2. Not going to cache shaping results

Changes

  1. Native font parser that can be used by FontFace: Native font parser #2475
  2. HarfBuzz-based font stack (see below). This is the biggest part.
  3. Change API: implement only the relevant parts of CSS Font Loading Module Level 3 (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. Script segmentation: use dropflow's trie writer. Reading it is easy to do in C++. Port the logic from dropflow.
  2. Bidi segmentation: use SheenBidi and port dropflow's logic.
  3. Emoji segmentation: could skip for first version if emojis work well enough, but also port from dropflow and add ragel to build.
  4. System fonts: walk entries in the OS and add to our own db, hopefully avoiding open(). Port from Pango and/or use LLMs.
  5. Font selection: port this from dropflow, which implements it as specified by W3C. Use HarfBuzz to read font tables.
  6. Font shaping: grapheme-based font fallbacks, bidi reordering, format for cairo_show_glyphs. Also update metrics functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant