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

Clarify and extend behavior around names in the FontMetadata object #69

Open rcombs opened 3 years ago

rcombs commented 3 years ago

I noticed a few shortcomings here; they can all be addressed by applications by parsing the SFNT directly, but it'd certainly be helpful to have some improvements made:

annevk commented 2 years ago

I don't think all of these are enhancement requests. E.g., the first and last bullet point need to be defined, no?

rcombs commented 2 years ago

Yeah, there's a reasonable argument to be made that those are spec defects that should be corrected.

inexorabletash commented 2 years ago

Updated the label, and suggestions for all of these concerns would be welcome.

rcombs commented 2 years ago

For the last bullet, platform behavior seems to vary a lot. On Windows, the PostScript name isn't even always used for matching (it seems to depend on the font type; if the font isn't either Type 1, Type 42, CID Type 1, or CFF, it instead matches based on the full name). FreeType prefers Windows-formatted PostScript names over Mac-formatted ones; macOS supports both but appears to ignore a Windows name if a corresponding Mac name is available. I think Windows only supports Windows names but I'm not 100% certain.

As a developer, the best thing the API could do for me would be to let me query fonts by passing a font-request object (name + possibly weight/slant + possibly string being rendered) to the OS that is searched for via whatever fast mechanism the system provides. Currently you mention linear searches, but OSs generally provide a faster lookup mechanism that doesn't require retrieving and iterating the full list (e.g. WinGDI uses a hash-table lookup). Note that on some platforms, the relevant API only returns a single font rather than a list (Android, WinGDI), thus the potential need to specify a weight/slant. Specifying a sample string being rendered can be critical if I'm performing fallback due to a missing glyph; the OS generally knows a suitable fallback font for every supported Unicode character range, and usually doesn't expose that mapping directly. If I want to do a slow-but-consistent linear search, I can implement that myself.