local-font-access icon indicating copy to clipboard operation
local-font-access copied to clipboard

postscript names of variable fonts

Open sigurdle opened this issue 3 years ago • 4 comments
trafficstars

Hi,

I'm using the Local Fonts API, and writing my own font parser to parse the blob. With regards to variable fonts:

The Local Fonts API gives me this in its array of fonts (the postscriptName) ... Segoe-UI-Variable-Display Segoe-UI-Variable-Display-Bold Segoe-UI-Variable-Display-Light Segoe-UI-Variable-Display-Semibold etc.

These names I believe are all coming from the same font file, a variable font file with an "fvar" table, when I'm parsing that file, the postscript names of these variable font "instances" do not seem to be included, but must be generated. Though I did find a document that suggests how to generate a postscript name from a variable font instance:

https://adobe-type-tools.github.io/font-tech-notes/pdfs/5902.AdobePSNameGeneration.pdf

This document doesn't seem to give the same results however as that returned from Local Fonts API. Even if I tweak it, I'm not getting same results. What I can get however is e.g this:

Segoe-UI-Variable-Light-Display

But Notice: "Light" and "Display" is reversed (There's a string in the file that says "Light Display", which I've used to build the final string) Local Fonts API returns "Display-Light", so its reversed from what I've managed to get, and I don't want to just HACK and reverse strings etc.

In short: How would I parse the truetype font to match it with the postscript names from a variable font, that the Local Fonts API is giving me ??

Thanks, Sigurd Lerstad

sigurdle avatar Apr 14 '22 10:04 sigurdle

Interesting - what platform (OS) are you testing on?

In Chrome's implementation we get the list of fonts via the OS's API - DirectWrite on Windows, CoreText on macOS, FontConfig on Linux/ChromeOS. So it should be the underlying API that is deriving those postscriptNames from the variable font file - we don't synthesize it ourselves.

inexorabletash avatar Apr 22 '22 21:04 inexorabletash

Nice. I tried this with Chrome 102.0.5005.61 and got correct postscript name SegoeUIVariable_Light-Display as per Adobe spec

pranayaggarwal avatar May 30 '22 17:05 pranayaggarwal

So I tried again, and I still get "wrong results":

const fontArray = await queryLocalFonts();
    	for await (const metadata of fontArray)
		{
			metadata.postscriptName

Segoe-UI-Variable-Display-Bold Segoe-UI-Variable-Display-Light etc.

I'm now on chrome 103, windows 11.

sigurdle avatar Jun 30 '22 16:06 sigurdle

Checked and I can confirm, Incorrect names like Segoe-UI-Variable-Display-Bold are coming from windows OS 11 which are not as per the Adobe standard spec.

pranayaggarwal avatar Jul 13 '22 11:07 pranayaggarwal