Skip to content

Notes on removing Pango

Caleb Hearon edited this page Apr 23, 2018 · 4 revisions

Pango depends on glib, gojbject, gthread, and fontconfig, and bundles libpangoft2 and libpangocairo. It may be too high-level for canvas, since it only needs to draw one line of text.

Removing Pango also removes a large layer of code, so we might see real performance improvements.

Switching to calling HarfBuzz directly would make glyph layout the same on all platforms. It might even make the rasterization look the same on all platforms, but I don't know enough about what FreeType does to say for sure.

We lose a few things by ditching Pango, though

Font selection and fallback fonts

This will take a decent amount of code, but will also make the way Canvas.registerFont works a lot less hacky. Two approaches I found:

  • Make native calls to the OS. Upside is it should always work, downside is it might not match w3c spec, and will be different on other platforms.
  • Look in a set of directories. Downside is it might not work on every Linux setup. Upside is we get full control over matching, and it will be the same on all platforms.

We may be able to do a bit of both. Make the OS call, and initialize every file found on the system with FreeType and do font selection internally. Need to look and find out if this is what browsers do.

Font synthesis

For fake italics.

Clone this wiki locally