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

Use Bezier curves to improve quality #16

Open
ianthetechie opened this issue Dec 5, 2023 · 1 comment
Open

Use Bezier curves to improve quality #16

ianthetechie opened this issue Dec 5, 2023 · 1 comment

Comments

@ianthetechie
Copy link
Contributor

Background:

There are two approaches to SDF glyph generation in wide use today.

  1. Rasterize the glyphs directly (ex: using FreeType to get an alpha map) and compute the SDF from the bitmap. This is the approach taken by TinySDF: https://github.com/mapbox/tiny-sdf.
  2. Compute the SDF using the bezier curves from the font, as in https://github.com/mapbox/sdf-glyph-foundry/blob/master/include/mapbox/glyph_foundry_impl.hpp (used by many projects including the old node frontend and the more modern https://github.com/maplibre/font-maker).

We currently use the first method as it is fast and easy to implement. However, there is a solid case for supporting the second method, as this would improve the rendering quality of Indic, Khmer, Burmese, etc.

@ianthetechie
Copy link
Contributor Author

I took a deeper look into what it would take to accomplish this today. It's not going to be a trivial implementation, as the Mapbox implementation makes use of FT_Outline_Decompose.

The docs take a minute to grok, but basically it's walking over the outline struct with a bunch of function pointers and an inout that acts as global state. So it should now be obvious why freetype-rs doesn't have a wrapper for this 😂

This actually doesn't look too absurd to implement ourselves after reading over the FT_Outline docs, but it's going to take a fair bit of work. Not exactly something I could knock out in an evening reliably, but probably wouldn't take an entire week either.

It's still not a super high priority for me at the moment, but I'd welcome contributions to this effort by anyone interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant