Gathering detailed insights and metrics for subset-font
Gathering detailed insights and metrics for subset-font
Gathering detailed insights and metrics for subset-font
Gathering detailed insights and metrics for subset-font
Create a subset of a TrueType/OpenType/WOFF/WOFF2 font using the wasm build of harfbuzz/hb-subset
npm install subset-font
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
BSD-3-Clause License
113 Stars
89 Commits
7 Forks
3 Watchers
5 Branches
3 Contributors
Updated on Jun 18, 2025
Latest Version
2.4.0
Package Id
subset-font@2.4.0
Unpacked Size
21.58 kB
Size
7.03 kB
File Count
5
NPM Version
8.11.0
Node Version
16.16.0
Published on
Oct 05, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Create a subset font from an existing font in SFNT (TrueType/OpenType), WOFF, or WOFF2 format. When subsetting a variable font, you can also reduce the variation space at the individual axis level.
These operations are implemented using harfbuzzjs
, which is a WebAssembly build of HarfBuzz.
1const subsetFont = require('subset-font'); 2 3const mySfntFontBuffer = Buffer.from(/*...*/); 4 5// Create a new font with only the characters required to render "Hello, world!" in WOFF2 format: 6const subsetBuffer = await subsetFont(mySfntFontBuffer, 'Hello, world!', { 7 targetFormat: 'woff2', 8});
1const subsetFont = require('subset-font');
2
3const mySfntFontBuffer = Buffer.from(/*...*/);
4
5// Create a new font with only the characters required to render "Hello, world!" in WOFF2 format:
6const subsetBuffer = await subsetFont(mySfntFontBuffer, 'Hello, world!', {
7 targetFormat: 'woff2',
8 variationAxes: {
9 // Pin the axis to 200:
10 wght: 200,
11 // Reduce the variation space, explicitly setting a new default value:
12 GRAD: { min: -50, max: 50, default: 25 },
13 // Reduce the variation space. A new default value will be inferred by clamping the old default to the new range:
14 slnt: { min: -9, max: 0 },
15 // The remaining axes will be kept as-is
16 },
17});
subsetFont(buffer, text, options): Promise<Buffer>
Asynchronously create a subset font as a Buffer instance, optionally converting it to another format.
Returns a promise that gets fulfilled with the subset font as a Buffer instance, or rejected with an error.
Options:
targetFormat
- the format to output, can be either 'sfnt'
, 'woff'
, or 'woff2'
.preserveNameIds
- an array of numbers specifying the extra name ids to preserve in the name
table. By default the harfbuzz subsetter drops most of these. Use case described here.variationAxes
- an object specifying a full or partial instancing of variation axes in the font. Only works with variable fonts. See the example above.noLayoutClosure
- don't perform glyph closure for layout substitution (GSUB). Equivalent to hb-subset --no-layout-closure
and pyftsubset --no-layout-closure
.For backwards compatibility reasons, 'truetype'
is supported as an alias for 'sfnt'
.
This middle-man module only really exists for convenience.
harfbuzzjs
is deliberately low-level bindings for HarfBuzz. While very flexible, it means that you need a series of hard-to-get-right incantations to move data in and out of the WebAssembly heap and carry out a subsetting operation. See harfbuzz/harfbuzzjs#9.subset-font
adds support for reading and writing WOFF and WOFF2 via the fontverter
library.3-clause BSD license -- see the LICENSE
file for details.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 0/25 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More