webfont
11.2.20 (2021-07-31)
SVG 아이콘의 글꼴 생성기.
WOFF2 , WOFF , EOT , TTF 및 SVG ;JavaScript , JSON 또는 YAML 파일을 사용하여 전체 디렉토리 및 모든 하위 디렉토리에 대한 구성 정보를 지정합니다.css , scss , styl 등)을 사용할 수 있습니다.gulp , grunt 또는 기타 큰 도구와 같은 추가 종속성은 없습니다.linux , windows 및 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 ;
} ) ;또는
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 ;
} ) ;filesstring | arraynode_modules 및 bower_components 항상 무시됩니다. configFilestring(JSON, YAML, or CommonJS) 또는 node_modules 의 모듈 이름으로의 경로.configFile 제공하지 않으면 WebFont는 다음 위치에서 구성 파일에 대한 디렉토리 트리를 검색합니다.package.json 의 webfont 속성.webfontrc 파일 (파일 이름 확장 유무에 관계없이 : .json , .yaml 및 .js 사용할 수 있습니다)object 내보내는 webfont.config.js 파일. 검색은 작업 디렉토리에서 시작하여 구성 파일을 찾을 때까지 디렉토리 트리를 위로 이동합니다. fontNamestringwebfontformatsarray ,['svg', 'ttf', 'eot', 'woff', 'woff2'] ,svg, ttf, eot, woff, woff2 ,template 유형 : string
기본값 : null
가능한 값 : css , scss , styl (더 많은 기여를하십시오).
참고 : 사용자 정의 템플릿을 사용하려면 다음과 같은 경로 string 에서이 옵션 패스를 사용하십시오.
webfont ( {
template : "./path/to/my-template.css" ,
} ) ;또는
webfont ( {
template : path . resolve ( __dirname , "./my-template.css" ) ,
} ) ;또는
webfont ( {
template : path . resolve ( __dirname , "./my-template.styl" ) ,
} ) ; templateClassNamestringnulltemplateFontPathstring./CSS 파일에서 생성 된 글꼴로가는 경로. templateFontNamestringfontName 에서 가져 오지만 값을 지정할 수 있습니다.ligaturesbooleantrueglyphTransformFn 유형 : function
기본값 : null
설명 : 아이콘의 스타일 템플릿에서 전송하기 전에 Glyph 메타 데이터 (예 : CSS 클래스 또는 유니 코드 제목)를 변환하려면 Glyphs 메타 데이터 객체와 함께이 옵션을 사용할 수 있습니다.
예:
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 ;
} ) ; sortbooltrue이들은 WebFont 옵션에 추가 될 수 있습니다. 이것들은 svgicons2svgfont로 직접 전달됩니다.
svgicons2svgfont.fontNamestringsvgicons2svgfont.fontIdstringfontName 값svgicons2svgfont.fontStylestring''svgicons2svgfont.fontWeightstring''svgicons2svgfont.fixedWidthbooleanfalsesvgicons2svgfont.centerHorizontallybooleanfalsesvgicons2svgfont.normalizebooleanfalsesvgicons2svgfont.fontHeightnumberMAX(icons.height)svgicons2svgfont.roundnumber10e12 설정 SVG 경로 반올림. svgicons2svgfont.descentnumber0svgicons2svgfont.ascentnumberfontHeight - descentsvgicons2svgfont.metadatastringundefinedsvgicons2svgfont.logfunctionconsole.logfunction(){} 로 설정합니다. 다음 사용 섹션에서 볼 수 있듯이이 단계에서는 명령 줄 사용의 인터페이스가 상당히 단순합니다.
cli 스크립트를 package.json 파일의 scripts 객체에 추가하십시오.
{
"scripts" : {
"webfont" : " node node_modules/webfont/dist/cli.js "
}
}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]
CLI는 다음 출구 코드로 프로세스를 종료 할 수 있습니다.
webpack 플러그인.ttf2woff2 구현할 수 있음);MIT 라이센스에 따라 게시에 동의하면 코드를 자유롭게 푸시하십시오.
Changelog를 확인하십시오
라이센스를 확인하십시오