Lorp / figma-colrv1

Figma plugin to support COLRv1 fonts including variable
6 stars 0 forks source link

Determine locations for font files #13

Open Lorp opened 10 months ago

Lorp commented 10 months ago

The Noto Color Emoji font, as well as the default set of fonts in the Text mode, need to be hosted somewhere rather than be delivered with the plugin. Their locations are defined in fontlist.js, and are currently either https://www.axis-praxis.org/ or https://raw.githubusercontent.com/. Neither of these domains is ideal for production — githubusercontent.com is not a CDN, and axis-praxis.org is not set up for heavy traffic.

Note that any domains from which assets may be downloaded by a plugin must be listed in manifest.json — one cannot dynamically download from arbitrary URLs (e.g. by letting users enter a URL).

Note also that, to minimize bandwidth, Noto Color Emoji has had its SVG table removed and is compressed as a WOFF2 file.

Lorp commented 10 months ago

The WOFF2 font at this URL appears to be what we want:

https://fonts.gstatic.com/s/notocoloremoji/v25/Yq6P-KqIXTD0t4D9z1ESnKM3-HpFWRxHy9WY8YXt1PQ.woff2

It is 1.9MB (that is comparable to the size of the font created by manually removing the SVG table from the unmodified binary font, after WOFF2-compression).

We need confirmation that this is safe to hard-code.

Obtained via:

Lorp commented 10 months ago

Note also that this URL is for the updated Noto Color Emoji with Emoji 15.1 support, whereas testing until now has been with the font covering Emoji 15.0.

For reference: new emojis in Emoji 15.0, Emoji 15.1

Lorp commented 10 months ago

We can also use this location for Noto Emoji (mono):

https://fonts.gstatic.com/s/notoemoji/v47/bMrymSyK7YY-MEu6aWjPJGaTe34h0Wq7.woff2

Lorp commented 10 months ago

The two emoji font references now point to fonts.gstatic.com links mentioned above (commit: 5815fb0609af85cd266479409684e9e6bdcaa284)

Lorp commented 10 months ago

Since they are available at fonts.google.com, it’s tempting to use the same technique for Bitter, Foldit and Nabla. However, in each case, the CSS does not point to any single font covering the whole character set; they are split into Latin, Vietnamese and (in the case of Bitter) Cyrillic. A method to get a URL for the non-subset WOFF2 font would be ideal.

tomasdev commented 10 months ago

I think https://fonts.gstatic.com/s/foldit/v5/aFTV7PF3Y3c9WdjXozeyCYQ.woff2 has the un-subsetted Foldit.

The hashes can be pre-calculated for the specific settings you need (undocumented)

Lorp commented 10 months ago

Thanks for this, looks good!

Note that it has 615 glyphs vs 619 glyphs in the binary I’ve been using. Perhaps an optimization based on unused glyphs or a minor version difference.

Do you have similar URLs for Bitter, Bitter Italic, Blaka Ink, Bungee Spice, Nabla (those are the other Google fonts I’ve been using in the text fonts menu).