The path of the templates, see src/styles or test/templates/styles to get reference about
how to create a template, file names can have the extension .template, like a filename.scss.template
startUnicode
Type: Number Default value: 0xea01
unicode start number
useNameAsUnicode
Type: Boolean Default value: false
should the name(file name) be used as unicode? this switch allows for the support of ligatures.
let’s say you have an svg with a file name of add and you want to use ligatures for it. you would set up your processing as mentioned above and turn on this switch.
{
...
useNameAsUnicode: true
}
while processing, instead of using a single sequential char for the unicode, it uses the file name. using the file name as the unicode allows the following code to work as expected.
Create font class name prefix, default value font name.
css
Type: Boolean|CSSOptions Default value: false
Create CSS/LESS files, default true.
type CSSOptions = {
/**
* Output the css file to the specified directory
*/
output?: string;
/**
* Which files are exported.
*/
include?: RegExp;
/**
* Setting font size.
*/
fontSize?: string;
/**
* Set the path in the css file
* https://github.com/jaywcjlove/svgtofont/issues/48#issuecomment-739547189
*/
cssPath?: string
/**
* Set file name
* https://github.com/jaywcjlove/svgtofont/issues/48#issuecomment-739547189
*/
fileName?: string
}
Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font, Generator of fonts from SVG icons.
Install · Usage · Command · Font Usage · API · options · npm · License
Features:
WOFF2
,WOFF
,EOT
,TTF
andSVG
.React
&TypeScript
.Less
/Sass
/Stylus
.css
,less
and etc).Icon Font Created By svgtofont
React
&TypeScript
.npm run test
in the root directory to see the results.Install
Using With Command
You can add configuration to package.json. #48
Supports
.svgtofontrc
Configuration File.Using With Nodejs
Or
API
options
dist
The output directory.
outSVGReact
Output
./dist/react/
, SVG generatesreact
components.outSVGPath
Output
./dist/svgtofont.json
, The content is as follows:Or you can generate the file separately:
src
output path
emptyDist
Clear output directory contents
fontName
The font family name you want.
styleTemplates
The path of the templates, see
src/styles
ortest/templates/styles
to get reference about how to create a template, file names can have the extension .template, like afilename.scss.template
startUnicode
unicode start number
useNameAsUnicode
should the name(file name) be used as unicode? this switch allows for the support of ligatures.
let’s say you have an svg with a file name of
add
and you want to use ligatures for it. you would set up your processing as mentioned above and turn on this switch.while processing, instead of using a single sequential char for the unicode, it uses the file name. using the file name as the unicode allows the following code to work as expected.
as you add more svgs and process them into your font you would just use the same pattern.
classNamePrefix
Create font class name prefix, default value font name.
css
Create CSS/LESS files, default
true
.svgicons2svgfont
This is the setting for svgicons2svgfont
svgicons2svgfont.fontName
The font family name you want.
svgicons2svgfont.fontId
The font id you want.
svgicons2svgfont.fontStyle
The font style you want.
svgicons2svgfont.fontWeight
The font weight you want.
svgicons2svgfont.fixedWidth
Creates a monospace font of the width of the largest input icon.
svgicons2svgfont.centerHorizontally
Calculate the bounds of a glyph and center it horizontally.
svgicons2svgfont.normalize
Normalize icons by scaling them to the height of the highest icon.
svgicons2svgfont.fontHeight
The outputted font height (defaults to the height of the highest input icon).
svgicons2svgfont.round
Setup SVG path rounding.
svgicons2svgfont.descent
The font descent. It is useful to fix the font baseline yourself.
Warning: The descent is a positive value!
svgicons2svgfont.ascent
The font ascent. Use this options only if you know what you’re doing. A suitable value for this is computed for you.
svgicons2svgfont.metadata
The font metadata. You can set any character data in but it is the be suited place for a copyright mention.
svgicons2svgfont.log
Allows you to provide your own logging function. Set to
function(){}
to disable logging.svgoOptions
Some options can be configured with
svgoOptions
though it. svgosvg2ttf
This is the setting for svg2ttf
svg2ttf.copyright
copyright string
svg2ttf.ts
Unix timestamp (in seconds) to override creation time
svg2ttf.version
font version string, can be Version
x.y
orx.y
.website
Define preview web content. Example:
website.template
Custom template can customize parameters. You can define your own template based on the default template.
website.index
Set default home page.
Font Usage
Suppose the font name is defined as
svgtofont
, The default home page isunicode
, Will generate:Preview demo
font-class.html
,symbol.html
andindex.html
. Automatically generated stylesvgtofont.css
andsvgtofont.less
.symbol svg
Unicode
Class Name
Support for
.less
and.css
styles references.Using With React
Icons are used as components.
v3.16.7+
support.In the project created by create-react-app
In the project created by webpack
Contributors
As always, thanks to our amazing contributors!
Made with github-action-contributors.
License
Licensed under the MIT License.