seek-oss / capsize

Flipping how we define typography in CSS.
https://seek-oss.github.io/capsize/
MIT License
1.48k stars 37 forks source link

Extract and expose `postscriptName` & `fullName` from font metrics #195

Closed michaeltaranto closed 2 months ago

michaeltaranto commented 2 months ago

The font metrics returned now include the postscriptName and fullName properties as authored by the font creator.

For example:

// Arial Regular metrics
{
  "familyName": "Arial",
  "fullName": "Arial",
  "postscriptName": "ArialMT",
  ...
}

// Arial Bold metrics
{
  "familyName": "Arial",
  "fullName": "Arial Bold",
  "postscriptName": "Arial-BoldMT",
  ...
}

These values are particularly useful when constructing CSS @font-face declarations, as they can be used to specify local(\<font-face-name>) sources. MDN recommends using both “to assure proper matching across platforms”.

@font-face {
  font-family: "Web Font Fallback";
  src: local('Arial Bold'), local('Arial-BoldMT');
  font-weight: 700;
  ascent-override: 89.3502%;
  descent-override: 23.1683%;
  size-adjust: 108.3377%;
}
changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: acf95a7051b417d81ae10874d554ef51e692c929

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | ------------------- | ----- | | @capsizecss/metrics | Minor | | @capsizecss/unpack | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR