font-subset-loader2

1.1.7 • Public • Published

font subset loader for webpack

Thanks for dematerializer's work. Consider his package is obsolete, so I have forked this package and make it compatible with webpack 4+

Transforms a TTF font resource so that it contains only a specified subset of glyphs with all other glyphs stripped out.

Install

npm install font-subset-loader2 --save-dev

Usage

Webpack Documentation: Using loaders

Glyphs like ! or , conflict with webpack's query string syntax (i.e. 'font-subset-loader2?glyphs=hey,you!'). It is therefore recommended to instead use a query object for passing the glyphs to the loader as a property:

{
    test: /\.ttf$/,
    use: [{
        loader: 'font-subset-loader2',
        options: { 
            glyphs: 'hey,you!' 
        }
    }]
}
// returns the file content of the subsetted file.ttf
// that contains only the specified glyphs 'h', 'e', 'y', ',', 'o', 'u' and '!'

Usage with other loaders

Process subsetted .ttf files with file-loader:

rules: [
	{
        test: /\.ttf$/,
        use: [
            {
		        loader: 'file-loader'
            },
            {
                loader: 'font-subset-loader2',
                options: { 
                    glyphs: 'hey,you!' 
                }
            }
        ]
	},
]

Process subsetted .ttf files with url-loader:

rules: [
	{
        test: /\.ttf$/,
        use: [
            {
		        loader: 'url-loader'
            },
            {
                loader: 'font-subset-loader2',
                options: { 
                    glyphs: 'hey,you!' 
                }
            }
        ]
	},
]

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i font-subset-loader2

Weekly Downloads

257

Version

1.1.7

License

MIT

Unpacked Size

4.24 kB

Total Files

4

Last publish

Collaborators

  • voidsky