pax_global_header 0000666 0000000 0000000 00000000064 15220754626 0014523 g ustar 00root root 0000000 0000000 52 comment=2364bc777578d484151acc11c998886911bc8df6
jaywcjlove-svgtofont-2472abc/ 0000775 0000000 0000000 00000000000 15220754626 0016335 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/.editorconfig 0000664 0000000 0000000 00000000105 15220754626 0021006 0 ustar 00root root 0000000 0000000 root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
jaywcjlove-svgtofont-2472abc/.github/ 0000775 0000000 0000000 00000000000 15220754626 0017675 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/.github/FUNDING.yml 0000664 0000000 0000000 00000000166 15220754626 0021515 0 ustar 00root root 0000000 0000000 github: [jaywcjlove]
#ko_fi: jaywcjlove
#buy_me_a_coffee: jaywcjlove
# custom: ["https://wangchujiang.com/#/sponsor"]
jaywcjlove-svgtofont-2472abc/.github/workflows/ 0000775 0000000 0000000 00000000000 15220754626 0021732 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/.github/workflows/ci.yml 0000664 0000000 0000000 00000007550 15220754626 0023057 0 ustar 00root root 0000000 0000000 name: Build
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run checked
- run: npm run example
- run: npm run example:cli
- run: npm run example:simple
- run: npm run example:templates
- run: npm run coverage
- run: cp -rf examples/example/dist coverage/example
- run: cp -rf examples/templates/dist2 coverage/templates
- name: Create idoc config.
run: |
cat > idoc.yml << EOF
site: "SVG To Font {{version}}"
menus:
Home: index.html
Sponsor:
url: https://wangchujiang.com/#/sponsor
target: __blank
Demo:
url: example/font-class.html
target: __blank
EOF
- run: npm install idoc@1 -g
- run: idoc --output coverage
# - name: Converts Markdown to HTML
# uses: jaywcjlove/markdown-to-html-cli@main
# with:
# output: coverage/index.html
# github-corners: https://github.com/jaywcjlove/svgtofont.git
- uses: jaywcjlove/coverage-badges-cli@main
- name: Generate Contributors Images
uses: jaywcjlove/github-action-contributors@main
with:
filter-author: (renovate\[bot\]|renovate-bot|dependabot\[bot\])
avatarSize: 42
output: coverage/CONTRIBUTORS.svg
- name: Create Tag
id: create_tag
uses: jaywcjlove/create-tag-action@main
with:
package-path: ./package.json
- name: get tag version
id: tag_version
uses: jaywcjlove/changelog-generator@main
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
commit_message: ${{steps.tag_version.outputs.tag}} ${{ github.event.head_commit.message }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverage
- name: Generate Changelog
id: changelog
uses: jaywcjlove/changelog-generator@main
if: steps.create_tag.outputs.successful
with:
head-ref: ${{steps.create_tag.outputs.version}}
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
- name: ♻� Create Release
uses: jaywcjlove/create-tag-action@main
with:
package-path: ./package.json
release: true
body: |
[](https://jaywcjlove.github.io/#/sponsor) [](https://uiwjs.github.io/npm-unpkg/#/pkg/svgtofont@${{steps.create_tag.outputs.versionNumber}}/file/README.md) [](https://bundlephobia.com/result?p=svgtofont@${{steps.create_tag.outputs.versionNumber}}) [](https://www.npmjs.com/package/svgtofont)
Documentation ${{ steps.changelog.outputs.tag }}: https://raw.githack.com/jaywcjlove/svgtofont/${{ steps.changelog.outputs.gh-pages-short-hash }}/index.html
Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
```bash
npm i svgtofont
```
${{ steps.changelog.outputs.changelog }}
# - name: 📦 svgtofont publish to NPM
# uses: JS-DevTools/npm-publish@v1
# with:
# token: ${{ secrets.NPM_TOKEN }}
# package: ./package.json
- name: 📦 svgtofont publish to NPM
run: NODE_AUTH_TOKEN="" npm publish --access public --provenance
continue-on-error: true jaywcjlove-svgtofont-2472abc/.gitignore 0000664 0000000 0000000 00000003164 15220754626 0020331 0 ustar 00root root 0000000 0000000 # Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node
dist
examples/example/dist
examples/templates/dist
examples/example#211/font
lib
package-lock.json
yarn.lock
__snapshots__
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# End of https://www.gitignore.io/api/node
.DS_Store
.cache
.vscode
.idea
.env
*.bak
*.tem
*.temp
#.swp
*.*~
~*.*
# IDEA
*.iml
*.ipr
*.iws
.idea/
jaywcjlove-svgtofont-2472abc/.npmignore 0000664 0000000 0000000 00000000005 15220754626 0020327 0 ustar 00root root 0000000 0000000 test
jaywcjlove-svgtofont-2472abc/LICENSE 0000664 0000000 0000000 00000002060 15220754626 0017340 0 ustar 00root root 0000000 0000000 MIT License
Copyright (c) 2018 �弟调调™
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
jaywcjlove-svgtofont-2472abc/README.md 0000664 0000000 0000000 00000073172 15220754626 0017626 0 ustar 00root root 0000000 0000000
[Free Font](https://github.com/jaywcjlove/free-font)
Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font, Generator of fonts from SVG icons.
[Install](#install) · [Usage](#using-with-nodejs) · [Command](#using-with-command) · [Font Usage](#font-usage) · [API](#api) · [options](#options) · [npm](http://npm.im/svgtofont) · [License](#license)
**Features:**
- Supported font formats: `WOFF2`, `WOFF`, `EOT`, `TTF` and `SVG`.
- Support SVG Symbol file.
- Support [`React`](https://github.com/facebook/react), [`ReactNative`](https://github.com/facebook/react-native), [`Vue`](https://github.com/vuejs/core) & [`TypeScript`](https://github.com/microsoft/TypeScript).
- Support [`Less`](https://github.com/less/less.js)/[`Sass`](https://github.com/sass/sass)/[`Stylus`](https://github.com/stylus/stylus).
- Allows to use custom templates (example `css`, `less` and etc).
- Automatically generate a preview site.
```bash
â•┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
┆ Project ┆
┆ â•┈┈┈┈┈┈┈┈┈┈┈╮ ┆
â•┈┈┈┈┈┈┈┈╮ ┆ ┆ svg ┆┈┈╮ ┆
┆iconfont┆┈┈╮ ┆ ╰┈┈┈┈┈┈┈┈┈┈┈╯ ┆ ┆
╰┈┈┈┈┈┈┈┈╯ ┆ â•┈┈┈┈┈┈┈┈┈┈┈┈╮ ┆ â•┈┈┈┈┈┈┈┈┈┈┈╮ ┆ ┆
├┈▶┆download svg┆┈┈▶┆ ┆┈svgtofont┈┆ ┆ ┆
â•┈┈┈┈┈┈┈┈╮ ┆ ╰┈┈┈┈┈┈┈┈┈┈┈┈╯ ┆â•┈┈┆create font┆◀┈╯ ┆
┆icomoon ┆┈┈╯ ┆┆ ╰┈┈┈┈┈┈┈┈┈┈┈╯ ┆
╰┈┈┈┈┈┈┈┈╯ ┆┆ â•┈┈┈┈┈┈┈┈┈┈┈╮ ┆
┆╰┈▶┆ use font ┆ ┆
┆ ╰┈┈┈┈┈┈┈┈┈┈┈╯ ┆
╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╯
```
```mermaid
graph LR;
A[iconfont]-->C[Download SVG];
B[icomoon]-->C;
D[icongo]-->C;
E[yesicon]-->C;
click A "https://www.iconfont.cn" "阿里巴巴矢é‡�å›¾æ ‡åº“" _blank
click B "https://icomoon.io" "Pixel Perfect Icon Solutions" _blank
click D "https://icongo.github.io" "Include popular icons in your React projects easily icons." _blank
click E "https://yesicon.app/" "216,162 High-Quality Vector Icons from Top Design Teams." _blank
C .-> ide1
subgraph ide1 [Project]
svg -->a2[svgtofont create font]
a2 .-> b3[use font]
end
```
**Icon Font Created By svgtofont**
- [file-icons](https://uiwjs.github.io/file-icons/) File icons in the file tree.
- [uiw-iconfont](https://github.com/uiwjs/icons) The premium icon font for [@uiwjs](https://github.com/uiwjs) Component Library. Support [`React`](https://github.com/facebook/react) & [`TypeScript`](https://github.com/microsoft/TypeScript).
- [Bootstrap Icons Font](https://github.com/uiwjs/bootstrap-icons) Official open source SVG icon library for Bootstrap.
- [test example](./test) For a simple test example, run `npm run test` in the root directory to see the results.
## Install
```bash
npm i svgtofont
```
> [!NOTE]
> This package `v5+` is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): Node 18+ is needed to use it and it must be `import` instead of `require`.
> ```js
> import svgtofont from 'svgtofont';
> ```
#### Using With Command
```json
{
"scripts": {
"font": "svgtofont --sources ./svg --output ./font --fontName uiw-font"
},
"svgtofont": {
"css": {
"fontSize": "12px"
}
}
}
```
You can add configuration to package.json. [#48](https://github.com/jaywcjlove/svgtofont/issues/48)
Support for `.svgtofontrc` and [more](https://github.com/jaywcjlove/auto-config-loader/blob/add7ae012f5c3903296fbf0ef06e3631e379c2cc/core/README.md?plain=1#L106-L135) configuration files.
```js
{
"fontName": "svgtofont",
"css": true
}
```
```js
/**
* @type {import('svgtofont').SvgToFontOptions}
*/
export default {
fontName: "iconfont",
}
```
#### Using With Nodejs
> [!NOTE]
> This package `v5+` is now pure ESM. Please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
```js
import svgtofont from 'svgtofont';
import path from 'node:path';
svgtofont({
src: path.resolve(process.cwd(), 'icon'), // svg path, only searches one level, not recursive
dist: path.resolve(process.cwd(), 'fonts'), // output path
fontName: 'svgtofont', // font name
css: true, // Create CSS files.
}).then(() => {
console.log('done!');
});
```
Or
```js
import svgtofont from 'svgtofont';
import path from 'node:path';
svgtofont({
src: path.resolve(process.cwd(), "icon"), // svg path, only searches one level, not recursive
dist: path.resolve(process.cwd(), "fonts"), // output path
styleTemplates: path.resolve(rootPath, "styles"), // file templates path (optional)
fontName: "svgtofont", // font name
css: true, // Create CSS files.
startUnicode: 0xea01, // unicode start number
svgicons2svgfont: {
fontHeight: 1000,
normalize: true
},
// website = null, no demo html files
website: {
title: "svgtofont",
// Must be a .svg format image.
logo: path.resolve(process.cwd(), "svg", "git.svg"),
version: pkg.version,
meta: {
description: "Converts SVG fonts to TTF/EOT/WOFF/WOFF2/SVG format.",
keywords: "svgtofont,TTF,EOT,WOFF,WOFF2,SVG"
},
description: ``,
// Add a Github corner to your website
// Like: https://github.com/uiwjs/react-github-corners
corners: {
url: 'https://github.com/jaywcjlove/svgtofont',
width: 62, // default: 60
height: 62, // default: 60
bgColor: '#dc3545' // default: '#151513'
},
links: [
{
title: "GitHub",
url: "https://github.com/jaywcjlove/svgtofont"
},
{
title: "Feedback",
url: "https://github.com/jaywcjlove/svgtofont/issues"
},
{
title: "Font Class",
url: "index.html"
},
{
title: "Unicode",
url: "unicode.html"
}
],
footerInfo: `Licensed under MIT. (Yes it's free and open-sourced`
}
}).then(() => {
console.log('done!');
});;
```
## API
```js
import { createSVG, createTTF, createEOT, createWOFF, createWOFF2, createSvgSymbol, copyTemplate, createHTML } from 'svgtofont/lib/utils';
const options = { ... };
async function createFont() {
const unicodeObject = await createSVG(options);
const ttf = await createTTF(options); // SVG Font => TTF
await createEOT(options, ttf); // TTF => EOT
await createWOFF(options, ttf); // TTF => WOFF
await createWOFF2(options, ttf); // TTF => WOFF2
await createSvgSymbol(options); // SVG Files => SVG Symbol
}
```
## options
> svgtofont(options)
### config
> Type: `config?: AutoConfOption`
By default, settings are automatically loaded from `.svgtofontrc` and `package.json`. You can add configuration to `package.json`. [#48](https://github.com/jaywcjlove/svgtofont/issues/48)
Support for `.svgtofontrc` and [more](https://github.com/jaywcjlove/auto-config-loader/blob/add7ae012f5c3903296fbf0ef06e3631e379c2cc/core/README.md?plain=1#L106-L135) configuration files.
### log
> Type: `Boolean`
A value of `false` disables logging
### logger
> Type: `(msg) => void`
log callback function
### dist
> Type: `String`
> Default value: ~~`dist`~~ => `fonts`
The output directory.
### outSVGReact
> Type: `Boolean`
> Default value: `false`
Output `./dist/react/`, SVG generates `react` components.
```js
git/git.svg
// ↓↓↓↓↓↓↓↓↓↓
import React from 'react';
export const Git = props => (
);
```
### outSVGReactNative
> Type: `Boolean`
> Default value: `false`
Output `./dist/reactNative/`, SVG generates `reactNative` components.
```js
import { Text } from 'react-native';
const icons = { "Git": "__GitUnicodeChar__", "Adobe": "__AdobeUnicodeChar__" };
export const RangeIconFont = props => {
const { name, ...rest } = props;
return (
{icons[name]}
);
};
```
### outSVGVue
> Type: `Boolean`
> Default value: `false`
Output `./dist/vue/`, SVG generates `vue` components.
```js
git/git.svg
// ↓↓↓↓↓↓↓↓↓↓
import { defineComponent, h } from 'vue';
export const Git = defineComponent({
name: 'Git',
props: {
class: {
type: String,
default: ''
}
},
setup(props, { attrs }) {
return () => h(
'svg',
{
viewBox: '0 0 20 20',
width: undefined,
height: undefined,
class: `svgtofont ${props.class}`,
...attrs
},
[]
);
}
});
```
### outSVGPath
> Type: `Boolean`
> Default value: `false`
Output `./dist/svgtofont.json`, The content is as follows:
```js
{
"adobe": ["M14.868 3H23v19L14.868 3zM1 3h8.138L1 22V3zm.182 11.997H13.79l-1.551-3.82H8.447z...."],
"git": ["M2.6 10.59L8.38 4.8l1.69 1.7c-.24.85.15 1.78.93 2.23v5.54c-.6.34-1 .99-1..."],
"stylelint": ["M129.74 243.648c28-100.109 27.188-100.5.816c2.65..."]
}
```
Or you can generate the file separately:
```js
const { generateIconsSource } = require('svgtofont/src/generate');
const path = require('path');
async function generate () {
const outPath = await generateIconsSource({
src: path.resolve(process.cwd(), 'svg'),
dist: path.resolve(process.cwd(), 'dist'),
fontName: 'svgtofont',
});
}
generate();
```
### generateInfoData
> Type: `Boolean`
> Default value: `false`
Output `./dist/info.json`, The content is as follows:
```js
{
"adobe": {
"encodedCode": "\\ea01",
"prefix": "svgtofont",
"className": "svgtofont-adobe",
"unicode": ""
},
...
}
```
### src
> Type: `String`
> Default value: `svg`
output path
### emptyDist
> Type: `String`
> Default value: `false`
Clear output directory contents
### fontName
> Type: `String`
> Default value: `iconfont`
The font family name you want.
### styleTemplates
> Type: `String`
> Default value: `undefined`
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
### getIconUnicode
Get Icon Unicode
```ts
getIconUnicode?: (name: string, unicode: string, startUnicode: number)
=> [string, 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.
```js
{
...
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.
```css
.icons {
font-family: 'your-font-icon-name' !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
```
```html
add
```
as you add more svgs and process them into your font you would just use the same pattern.
```html
add
remove
edit
```
### addLigatures
> Type: `Boolean`
> Default value: `false`
adds possibility to use name (file name) in addition to codepoints. adds support of ligatures.
let's say you have some svgs and you want to use codepoints but for some of them for example with a file name of `add` you want to use ligatures for it. this option only adds ligatures and still allows for using codepoints as usual. this is in contrary to useNameAsUnicode which basically removes support for codepoints in favour of ligatures.
```js
{
...
addLigatures: true
}
```
### useCSSVars
> Type: `Boolean`
> Default value: `false`
consoles whenever {{ cssString }} template outputs unicode characters or css vars
### classNamePrefix
> Type: `String`
> Default value: font name
Create font class name prefix, default value font name.
### css
> Type: `Boolean|CSSOptions`
> Default value: `false`
Create CSS/LESS files, default `true`.
```ts
type CSSOptions = {
/**
* Output the css file to the specified directory
*/
output?: string;
/**
* Which files are exported.
*/
include?: RegExp;
/**
* Setting font size.
*/
fontSize?: string | boolean;
/**
* 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;
/**
* Ad hoc template variables.
*/
templateVars?: Record;
/**
* When including CSS files in a CSS file,
* you can add a timestamp parameter or custom text to the file path to prevent browser caching issues and ensure style updates are applied. @default true
* @example `path/to/iconfont.css?t=1612345678`
*/
hasTimestamp?: boolean | string;
}
```
### svgicons2svgfont
This is the setting for [svgicons2svgfont](https://github.com/nfroidure/svgicons2svgfont/tree/dd713bea4f97afa59f7dba6a21ff7f22db565bcf#api)
#### svgicons2svgfont.fontName
> Type: `String`
> Default value: `'iconfont'`
The font family name you want.
#### svgicons2svgfont.fontId
> Type: `String`
> Default value: the options.fontName value
The font id you want.
#### svgicons2svgfont.fontStyle
> Type: `String`
> Default value: `''`
The font style you want.
#### svgicons2svgfont.fontWeight
> Type: `String`
> Default value: `''`
The font weight you want.
#### svgicons2svgfont.fixedWidth
> Type: `Boolean`
> Default value: `false`
Creates a monospace font of the width of the largest input icon.
#### svgicons2svgfont.centerHorizontally
> Type: `Boolean`
> Default value: `false`
Calculate the bounds of a glyph and center it horizontally.
#### svgicons2svgfont.normalize
> Type: `Boolean`
> Default value: `false`
Normalize icons by scaling them to the height of the highest icon.
#### svgicons2svgfont.fontHeight
> Type: `Number`
> Default value: `MAX(icons.height)`
The outputted font height (defaults to the height of the highest input icon).
#### svgicons2svgfont.round
> Type: `Number`
> Default value: `10e12`
Setup SVG path rounding.
#### svgicons2svgfont.descent
> Type: `Number`
> Default value: `0`
The font descent. It is useful to fix the font baseline yourself.
**Warning:** The descent is a positive value!
#### svgicons2svgfont.ascent
> Type: `Number`
> Default value: `fontHeight - descent`
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
> Type: `String`
> Default value: `undefined`
The font [metadata](http://www.w3.org/TR/SVG/metadata.html). You can set any
character data in but it is the be suited place for a copyright mention.
#### svgicons2svgfont.log
> Type: `Function`
> Default value: `console.log`
Allows you to provide your own logging function. Set to `function(){}` to
disable logging.
### svgoOptions
> Type: `OptimizeOptions`
> Default value: `undefined`
Some options can be configured with `svgoOptions` though it. [svgo](https://github.com/svg/svgo#configuration)
### svg2ttf
This is the setting for [svg2ttf](https://github.com/fontello/svg2ttf/tree/c33a126920f46b030e8ce960cc7a0e38a6946bbc#svg2ttfsvgfontstring-options---buf)
#### svg2ttf.copyright
> Type: `String`
copyright string
#### svg2ttf.ts
> Type: `String`
Unix timestamp (in seconds) to override creation time
#### svg2ttf.version
> Type: `Number`
font version string, can be Version `x.y` or `x.y`.
### website
Define preview web content. Example:
```js
{
...
// website = null, no demo html files
website: {
title: "svgtofont",
logo: path.resolve(process.cwd(), "svg", "git.svg"),
version: pkg.version,
meta: {
description: "Converts SVG fonts to TTF/EOT/WOFF/WOFF2/SVG format.",
keywords: "svgtofont,TTF,EOT,WOFF,WOFF2,SVG",
favicon: "./favicon.png"
},
// Add a Github corner to your website
// Like: https://github.com/uiwjs/react-github-corners
corners: {
url: 'https://github.com/jaywcjlove/svgtofont',
width: 62, // default: 60
height: 62, // default: 60
bgColor: '#dc3545' // default: '#151513'
},
links: [
{
title: "GitHub",
url: "https://github.com/jaywcjlove/svgtofont"
},
{
title: "Feedback",
url: "https://github.com/jaywcjlove/svgtofont/issues"
},
{
title: "Font Class",
url: "index.html"
},
{
title: "Unicode",
url: "unicode.html"
}
]
}
}
```
#### website.template
> Type: `String`
> Default value: [index.njk](src/website/index.njk)
Custom template can customize parameters. You can define your own template based on the [default template](src/website/index.njk).
```js
{
website: {
template: path.join(process.cwd(), "my-template.njk")
}
}
```
#### website.index
> Type: `String`
> Default value: `font-class`, Enum{`font-class`, `unicode`, `symbol`}
Set default home page.
## Font Usage
Suppose the font name is defined as `svgtofont`, The default home page is `unicode`, Will generate:
```bash
font-class.html
index.html
svgtofont.css
svgtofont.eot
svgtofont.json
svgtofont.less
svgtofont.module.less
svgtofont.scss
svgtofont.styl
svgtofont.svg
svgtofont.symbol.svg
svgtofont.ttf
svgtofont.woff
svgtofont.woff2
symbol.html
```
Preview demo `font-class.html`, `symbol.html` and `index.html`. Automatically generated style `svgtofont.css` and `svgtofont.less`.
### symbol svg
```xml
```
### Unicode
```html
```
### Class Name
Support for `.less` and `.css` styles references.
```html
```
### Using With React
Icons are used as components. `v3.16.7+` support.
```jsx
import { Adobe, Alipay } from '@uiw/icons';
```
#### In the project created by [create-react-app](https://github.com/facebook/create-react-app)
```jsx
import logo from './logo.svg';
```
```jsx
import { ReactComponent as ComLogo } from './logo.svg';
```
#### In the project created by [webpack](https://github.com/webpack/webpack)
```bash
yarn add babel-plugin-named-asset-import
yarn add @svgr/webpack
```
```js
// webpack.config.js
[
require.resolve('babel-plugin-named-asset-import'),
{
loaderMap: {
svg: {
ReactComponent: '@svgr/webpack?-svgo,+ref![path]',
},
},
},
],
```
```jsx
import { ReactComponent as ComLogo } from './logo.svg';
```
### Using With ReactNative
A unique component named after the font name is generated.
Props are TextProps and are used as inline style.
In addition, the iconName prop is mandatory and refers to svg names written in camelCase
```jsx
SvgToFont.jsx
// ↓↓↓↓↓↓↓↓↓↓
import { SvgToFont } from './SvgToFont';
```
```ts
SvgToFont.d.ts
// ↓↓↓↓↓↓↓↓↓↓
import { TextStyle } from 'react-native';
export type SvgToFontIconNames = 'git'| 'adobe'| 'demo' | 'left' | 'styleInline'
export interface SvgToFontProps extends Omit {
iconName: SvgToFontIconNames
}
export declare const SvgToFont: (props: SvgToFontProps) => JSX.Element;
```
### Using with Vue
Icons are used as components. `v3+` support.
```vue
```
## Contributors
As always, thanks to our amazing contributors!
Made with [contributors](https://github.com/jaywcjlove/github-action-contributors).
## License
Licensed under the [MIT License](https://opensource.org/licenses/MIT).
jaywcjlove-svgtofont-2472abc/examples/ 0000775 0000000 0000000 00000000000 15220754626 0020153 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/examples/example#211/ 0000775 0000000 0000000 00000000000 15220754626 0022075 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/examples/example#211/.gitignore 0000664 0000000 0000000 00000000004 15220754626 0024057 0 ustar 00root root 0000000 0000000 font jaywcjlove-svgtofont-2472abc/examples/example#211/.svgtofontrc.js 0000664 0000000 0000000 00000000243 15220754626 0025066 0 ustar 00root root 0000000 0000000 import path from "path";
/**
* @type {import('svgtofont').SvgToFontOptions}
*/
export default {
fontName: "iconfont",
css: {
hasTimestamp: "v1.2.3"
}
} jaywcjlove-svgtofont-2472abc/examples/example#211/package.json 0000664 0000000 0000000 00000000432 15220754626 0024362 0 ustar 00root root 0000000 0000000 {
"name": "ex211",
"version": "6.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "svgtofont --sources ./svg --output ./font"
},
"keywords": [],
"author": "jaywcjlove",
"license": "ISC",
"devDependencies": {
"svgtofont": "^6.0.0"
}
}
jaywcjlove-svgtofont-2472abc/examples/example#211/svg/ 0000775 0000000 0000000 00000000000 15220754626 0022674 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/examples/example#211/svg/adobe.svg 0000664 0000000 0000000 00000000675 15220754626 0024477 0 ustar 00root root 0000000 0000000
jaywcjlove-svgtofont-2472abc/examples/example#211/svg/git.svg 0000664 0000000 0000000 00000001157 15220754626 0024204 0 ustar 00root root 0000000 0000000
jaywcjlove-svgtofont-2472abc/examples/example#211/svg/stylelint.svg 0000664 0000000 0000000 00000004664 15220754626 0025456 0 ustar 00root root 0000000 0000000
jaywcjlove-svgtofont-2472abc/examples/example#233/ 0000775 0000000 0000000 00000000000 15220754626 0022101 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/examples/example#233/simple.mjs 0000664 0000000 0000000 00000000557 15220754626 0024114 0 ustar 00root root 0000000 0000000 import svgtofont from '../../lib/index.js';
import path from 'path';
svgtofont({
src: path.resolve(process.cwd(), "svg"), // svg path
dist: path.resolve(process.cwd(), "dist"), // output path
fontName: 'pst-font', // font name
css: true, // Create CSS files.
}).then(() => {
console.log('done!');
}).catch((error) => {
console.error('Error:', error);
}); jaywcjlove-svgtofont-2472abc/examples/example#233/svg/ 0000775 0000000 0000000 00000000000 15220754626 0022700 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/examples/example#233/svg/adobe.svg 0000664 0000000 0000000 00000000675 15220754626 0024503 0 ustar 00root root 0000000 0000000
jaywcjlove-svgtofont-2472abc/examples/example#233/svg/git.svg 0000664 0000000 0000000 00000001157 15220754626 0024210 0 ustar 00root root 0000000 0000000
jaywcjlove-svgtofont-2472abc/examples/example/ 0000775 0000000 0000000 00000000000 15220754626 0021606 5 ustar 00root root 0000000 0000000 jaywcjlove-svgtofont-2472abc/examples/example/.gitignore 0000664 0000000 0000000 00000000007 15220754626 0023573 0 ustar 00root root 0000000 0000000 example jaywcjlove-svgtofont-2472abc/examples/example/favicon.png 0000664 0000000 0000000 00000002622 15220754626 0023743 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR 0 0 Wù‡ sRGB ®Îé LIDATh½ZMˆE~¯f& ó7Ó³F0A
‹!z0w QvvW=äàÙ”€è%ñ7lð?õ¢'½ „€Ù¨$ñ xYQÐ,âI“ž™�˜(î³ÓU¾×“Zzzªzú§&uØêzïÕ«ïÛ×õªë1#hK³ÞA s àÁÐ=ÂB©s›Oø?º^];ô§ê/ È£
õ�€«ˆê`µÙú */ú,Š:ˆÎo7j/È÷âàÙF�ªHï·¦½ƒÑ9EŸ�EàŸoãr üæa Pà¡ÚIÿè0»4zg¸eÞÿ*• Dè[XIõ®«H8‹€í7îÜ�píŒRPÕ2[ï"…"Ð~rÛÀëâ5ÏýRÈ‘hÛ€k¹‹HäŽ@«Q�6æs¢,&«_\øYƒÒ}§±õ. Á²+A