
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Generator of fonts from svg icons, svg icons to svg font, svg font to ttf, ttf to eot, ttf to woff, ttf to woff2
Generator of fonts from SVG icons.
WOFF2
, WOFF
, EOT
, TTF
and SVG
;JavaScript
, JSON
or YAML
file to specify configuration information for an entire directory and all of its subdirectories;css
, scss
, styl
etc);gulp
, grunt
or other big tools;linux
, windows
and osx
);npm install --save-dev webfont
import webfont from "webfont";
webfont({
files: "src/svg-icons/**/*.svg",
fontName: "my-font-name",
})
.then((result) => {
// Do something with result
Function.prototype(result);
// Or return it
return result;
})
.catch((error) => {
throw error;
});
or
const webfont = require("webfont").default;
webfont({
files: "src/svg-icons/**/*.svg",
fontName: "my-font-name",
})
.then((result) => {
// Do something with result
Function.prototype(result);
// Or return it
return result;
})
.catch((error) => {
throw error;
});
files
string
| array
node_modules
and bower_components
are always ignored.configFile
string
(JSON, YAML, or CommonJS)
or the name of a module in node_modules
that points to one.configFile
, webfont will search up the directory tree for configuration file in the following places, in this order:
webfont
property in package.json
.webfontrc
file (with or without filename extension: .json
, .yaml
, and .js
are available)webfont.config.js
file exporting a JS object
.
The search will begin in the working directory and move up the directory tree until it finds a configuration file.fontName
string
webfont
formats
array
,['svg', 'ttf', 'eot', 'woff', 'woff2']
,svg, ttf, eot, woff, woff2
,template
Type: string
Default: null
Possible values: css
, scss
, styl
(feel free to contribute more).
Note: If you want to use a custom template use this option pass in a path string
like this:
webfont({
template: "./path/to/my-template.css",
});
Or
webfont({
template: path.resolve(__dirname, "./my-template.css"),
});
Or
webfont({
template: path.resolve(__dirname, "./my-template.styl"),
});
templateClassName
string
null
templateFontPath
string
./
CSS
file.templateFontName
string
fontName
if not set, but you can specify any value.glyphTransformFn
Type: function
Default: null
Description: If you want to transform glyph metadata (e.g. titles of CSS classes or unicode) before transferring it in your style template for your icons, you can use this option with glyphs metadata object.
Example:
import webfont from "webfont";
webfont({
files: "src/svg-icons/**/*.svg",
glyphTransformFn: (obj) => {
obj.name += "_transform";
something();
return obj;
},
})
.then((result) => {
// Do something with result
Function.prototype(result);
// Or return it
return result;
})
.catch((error) => {
throw error;
});
sort
bool
true
These can be appended to webfont options. These are passed directly to svgicons2svgfont.
svgicons2svgfont.fontName
string
svgicons2svgfont.fontId
string
fontName
valuesvgicons2svgfont.fontStyle
string
''
svgicons2svgfont.fontWeight
string
''
svgicons2svgfont.fixedWidth
boolean
false
svgicons2svgfont.centerHorizontally
boolean
false
svgicons2svgfont.normalize
boolean
false
svgicons2svgfont.fontHeight
number
MAX(icons.height)
svgicons2svgfont.round
number
10e12
Setup SVG path rounding.svgicons2svgfont.descent
number
0
svgicons2svgfont.ascent
number
fontHeight - descent
svgicons2svgfont.metadata
string
undefined
svgicons2svgfont.log
function
console.log
function(){}
to disable logging.The interface for command-line usage is fairly simplistic at this stage, as seen in the following usage section.
Add the cli
script to your package.json
file's scripts
object:
{
"scripts": {
"webfont": "node node_modules/webfont/dist/cli.js"
}
}
If you're using cross-env:
{
"scripts": {
"webfont": "cross-env node_modules/webfont/dist/cli.js"
}
}
Usage: webfont [input] [options]
Input: File(s) or glob(s).
If an input argument is wrapped in quotation marks, it will be passed to "fast-glob"
for cross-platform glob support.
Options:
--config
Path to a specific configuration file (JSON, YAML, or CommonJS)
or the name of a module in \`node_modules\` that points to one.
If no \`--config\` argument is provided, webfont will search for
configuration files in the following places, in this order:
- a \`webfont\` property in \`package.json\`
- a \`.webfontrc\` file (with or without filename extension:
\`.json\`, \`.yaml\`, and \`.js\` are available)
- a \`webfont.config.js\` file exporting a JS object
The search will begin in the working directory and move up the
directory tree until a configuration file is found.
-f, --font-name
The font family name you want, default: "webfont".
-h, --help
Output usage information.
-v, --version
Output the version number.
-r, --formats
Only this formats generate.
-d, --dest
Destination for generated fonts.
-m, --dest-create
Create destination directory if it does not exist.
-t, --template
Type of template (\`css\`, \`scss\`, \`styl\`) or path to custom template.
'
-s, --dest-template
Destination for generated template. If not passed used \`dest\` argument value.
-c, --template-class-name
Class name in css template.
-p, --template-font-path
Font path in css template.
-n, --template-font-name
Font name in css template.
--no-sort
Keeps the files in the same order of entry
--verbose
Tell me everything!.
For "svgicons2svgfont":
--font-id
The font id you want, default as "--font-name".
--font-style
The font style you want.
--font-weight
The font weight you want.
--fixed-width
Creates a monospace font of the width of the largest input icon.
--center-horizontally
Calculate the bounds of a glyph and center it horizontally.
--normalize
Normalize icons by scaling them to the height of the highest icon.
--font-height
The outputted font height [MAX(icons.height)].
--round
Setup the SVG path rounding [10e12].
--descent
The font descent [0].
--ascent
The font ascent [height - descent].
--start-unicode
The start unicode codepoint for files without prefix [0xEA01].
--prepend-unicode
Prefix files with their automatically allocated unicode codepoint.
--metadata
Content of the metadata tag.
--add-hash-in-font-url
Generated font url will be : [webfont].[ext]?v=[hash]
The CLI can exit the process with the following exit codes:
webpack
plugin.ttf2woff2
with native js library);Feel free to push your code if you agree with publishing under the MIT license.
Check our Changelog
Check our License
FAQs
Generator of fonts from svg icons, svg icons to svg font, svg font to ttf, ttf to eot, ttf to woff, ttf to woff2
The npm package webfont receives a total of 18,354 weekly downloads. As such, webfont popularity was classified as popular.
We found that webfont demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.