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 serialization variations #81

Open inexorabletash opened 2 years ago

inexorabletash commented 2 years ago

When a font (e.g. "Optima-Bold") is provided through the API, whether the source is the OS or a locally installed font, the actual data of the font may vary across browsers, OSes, or even time on the same device.

There is the case where the underlying font data is actually identical, but the SFNT serialization has changed in ways such that the files are not byte-identical, e.g. the tables are in a different order, or e.g. within the name table the entries are in a different order.

Do we need browsers to normalize this? Or is this the equivalent of e.g. a JPEG/JFIF file having markers in an undefined order when uploading <input type=file>?

The expected use case is that font data is parsed with a small number of robust libraries (e.g. HarfBuzz and FreeType) which conceal this from the calling code, so for most API users this will not be an issue.

rcombs commented 2 years ago

vary across browsers

Which cases are you expecting this to happen in? TTC handling, maybe? I would expect that for regular TTF or OTF files, the browser would simply hand the caller the contents of the on-disk file.

inexorabletash commented 2 years ago

vary across browsers

Which cases are you expecting this to happen in? TTC handling, maybe? I would expect that for regular TTF or OTF files, the browser would simply hand the caller the contents of the on-disk file.

That's my expectation as well for most implementations. But I could imagine a UA that does things differently, e.g. a UA that bundles a set of fonts, and the font data for those evolves over time e.g. to support new writing scripts.