linebender / skribo

A Rust library for low-level text layout.
Apache License 2.0
327 stars 35 forks source link

Choice of font fallback API on macOS #14

Open raphlinus opened 5 years ago

raphlinus commented 5 years ago

My writing on font fallback (see font fallback blog post) has generally suggested using CTFontCopyDefaultCascadeListForLanguages. Responding on Twitter, Jiang Jiang suggests we use CTFontCreateForString instead.

This is much more like the Windows approach, and saves the trouble of having to go through a long font list, but on the other hand involves calling into CoreText API's on a fine grained basis every time a layout is needed. Part of my idea of getting the cascade list is that it could be retained on a per-locale basis.

Probably measurement is needed to figure out which is better. If CTFontCreateForString is very fast, then maybe that is the best choice.

jjgod commented 5 years ago

I'd suggest you consider it since it will take care of a lot of things such as Emoji VS, etc. for you for free.

To customize the fallback order you will still need the kCTFontCascadeListAttribute.

If the performance of CTFontCreateForString is not to your liking, I'd like to see a test case for that.