Packages

@capsizecss/core

4.1.3 · 12 Nov 2025MIT205.9k / weekRepositoryHomepagenpmAtom feed

Your version

3.1.0

31 Jan 2023Where it was published

3.1.1 is the newest release of 3.x.

In short

2 new

Release note

Minor Changes

  • Add createFontStack for metrics-based font family fallbacks.

    Creates metrics-based @font-face declarations to improve the alignment of font family fallbacks, which can dramatically improve the Cumulative Layout Shift metric for sites that depend on a web font.

Example usage

```ts
import { createFontStack } from '@capsizecss/core';
import lobster from '@capsizecss/metrics/lobster';
import helveticaNeue from '@capsizecss/metrics/helveticaNeue';
import arial from '@capsizecss/metrics/arial';

const { fontFamily, fontFaces } = createFontStack([
  lobster,
  helveticaNeue,
  arial,
]);
```

The returned values are the computed font family and the generated font face declarations:

```ts
// `fontFamily`
"Lobster, 'Lobster Fallback: Helvetica Neue', 'Lobster Fallback: Arial'";
```

```css
/* `fontFaces` */
@font-face {
  font-family: 'Lobster Fallback: Helvetica Neue';
  src: local('Helvetica Neue');
  ascent-override: 115.1741%;
  descent-override: 28.7935%;
  size-adjust: 86.8251%;
}
@font-face {
  font-family: 'Lobster Fallback: Arial';
  src: local('Arial');
  ascent-override: 113.5679%;
  descent-override: 28.392%;
  size-adjust: 88.053%;
}
```

Patch Changes

  • Add additional properties to FontMetrics type definition.

    Previously the FontMetrics type captured only the metrics required by the options for the createStyleObject and createStyleString APIs.
    With additional APIs coming that require a different subset of metrics, the type now reflects the structure of the data from the metrics package.

    The additional properties are: familyName, category, xHeight and xWidthAvg.
    See documentation for more details.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.