WICG / local-font-access

Web API for enumerating fonts on the local system
https://wicg.github.io/local-font-access
Apache License 2.0
75 stars 16 forks source link

Font Metadata lacks information about supported character set and language for fonts #72

Open wffurr opened 2 years ago

wffurr commented 2 years ago

I can't find any reference to supported character set or language or locale in the FontMetadata definition. This seems like a major limitation to any kind of text processing application that wants to work in more than one locale.

My particular use case is to find out what set of fonts are needed to render a particular each character of a string (i.e. itemization) so that those fonts can be requested and embedded in a PDF and text objects created referencing the embedded fonts.

Take, for example, the string "Привет दुनिया". The first half can be typeset in Helvetica, but the second half causes TextEdit on my Mac to fallback to "Kohinoor Devanagari" to render the text.

If I want to find out that same information from a web API, there doesn't seem to be any way to do it. I can't even use a library like fontconfig compiled for wasm as used by Chrome unless I go ahead and request every single font installed on the system and load them in (100s of MBs?).

Ideally there would some web API that could take styled element and tell me which fonts were actually used to render each character, which I could then request with the local font API for writing out into the PDF.

inexorabletash commented 2 years ago

How is this handled by native apps using desktop OS APIs, e.g. DirectWrite, CoreText, and FontConfig? Do they provide this data during font enumeration, or do apps need to slurp in fonts?

Re: actual fonts used for styled text - https://github.com/WICG/canvas-formatted-text might be a good place to raise that request?