Giter VIP home page Giter VIP logo

svgtofont's Introduction

SVG To Font

Buy me a coffee Build & Deploy Coverage Status Gitee Repo Open in unpkg NPM Download npm version

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:

  • Supported font formats: WOFF2, WOFF, EOT, TTF and SVG.
  • Support SVG Symbol file.
  • Support React, ReactNative & TypeScript.
  • Support Less/Sass/Stylus.
  • Allows to use custom templates (example css, less and etc).
  • Automatically generate a preview site.
                                ╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
                                ┆      Project       ┆
                                ┆                    ┆
╭┈┈┈┈┈┈┈┈╮                      ┆   ╭┈┈┈┈┈┈┈┈┈┈┈╮    ┆
┆iconfont┆┈┈╮                   ┆   ┆    svg    ┆┈┈╮ ┆
╰┈┈┈┈┈┈┈┈╯  ┆  ╭┈┈┈┈┈┈┈┈┈┈┈┈╮   ┆   ╰┈┈┈┈┈┈┈┈┈┈┈╯  ┆ ┆
            ├┈▶┆download svg┆┈┈▶┆   ╭┈┈┈┈┈┈┈┈┈┈┈╮  ┆ ┆
╭┈┈┈┈┈┈┈┈╮  ┆  ╰┈┈┈┈┈┈┈┈┈┈┈┈╯   ┆╭┈┈┆create font┆◀┈╯ ┆
┆icomoon ┆┈┈╯                   ┆┆  ╰┈┈┈┈┈┈┈┈┈┈┈╯    ┆
╰┈┈┈┈┈┈┈┈╯                      ┆┆  ╭┈┈┈┈┈┈┈┈┈┈┈╮    ┆
                                ┆╰┈▶┆ use font  ┆    ┆
                                ┆   ╰┈┈┈┈┈┈┈┈┈┈┈╯    ┆
                                ╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╯
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[create font]
        a2 .-> b3[use font]
    end

Icon Font Created By svgtofont

Install

npm i svgtofont

Using With Command

{
  "scripts": {
    "font": "svgtofont --sources ./svg --output ./font --fontName uiw-font"
  },
  "svgtofont": {
    "css": {
      "fontSize": "12px"
    }
  }
}

You can add configuration to package.json. #48

Support for .svgtofontrc and more configuration files.

{
  "fontName": "svgtofont",
  "css": true
}
/**
 * @type {import('svgtofont').SvgToFontOptions}
 */
export default {
  fontName: "iconfont",
}

Using With Nodejs

const svgtofont = require('svgtofont');
const path = require('path');
 
svgtofont({
  src: path.resolve(process.cwd(), 'icon'), // svg path
  dist: path.resolve(process.cwd(), 'fonts'), // output path
  fontName: 'svgtofont', // font name
  css: true, // Create CSS files.
}).then(() => {
  console.log('done!');
});

Or

const svgtofont = require("svgtofont");
const path = require("path");

svgtofont({
  src: path.resolve(process.cwd(), "icon"), // svg path
  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 <a href="https://github.com/jaywcjlove/svgtofont">open-sourced</a>`
  }
}).then(() => {
  console.log('done!');
});;

API

import { createSVG, createTTF, createEOT, createWOFF, createWOFF2, createSvgSymbol, copyTemplate, createHTML } from 'svgtofont/lib/utils';

const options = { ... };

async function creatFont() {
  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<SvgToFontOptions>

By default, settings are automatically loaded from .svgtofontrc and package.json. You can add configuration to package.json. #48

Support for .svgtofontrc and more 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.

git/git.svg

// ↓↓↓↓↓↓↓↓↓↓

import React from 'react';
export const Git = props => (
  <svg viewBox="0 0 20 20" {...props}><path d="M2.6 10.59L8.38 4.8l1.69 -." fillRule="evenodd" /></svg>
);

outSVGReactNative

Type: Boolean
Default value: false

Output ./dist/reactNative/, SVG generates reactNative components.

import { Text } from 'react-native';

const icons = { "Git": "__GitUnicodeChar__", "Adobe": "__AdobeUnicodeChar__" };

export const RangeIconFont = props => {
  const { name, ...rest } = props;
  return (<Text style={{ fontFamily: 'svgtofont', fontSize: 16, color: '#000000', ...rest }}>
    {icons[name]}
  </Text>);
};

outSVGPath

Type: Boolean
Default value: false

Output ./dist/svgtofont.json, The content is as follows:

{
  "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:

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:

{
  "adobe": {
    "encodedCode": "\\ea01",
    "prefix": "svgtofont",
    "className": "svgtofont-adobe",
    "unicode": "&#59905;"
  },
  ...
}

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

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.

{
  ...
  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.

.icons {
  font-family: 'your-font-icon-name' !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
<i class="icons">add</i>

as you add more svgs and process them into your font you would just use the same pattern.

<i class="icons">add</i>
<i class="icons">remove</i>
<i class="icons">edit</i>

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.

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
  /**
   * Ad hoc template variables.
   */
  templateVars?: Record<string, any>;
}

svgicons2svgfont

This is the setting for svgicons2svgfont

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. 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

svg2ttf

This is the setting for svg2ttf

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:

{
  ...
  // 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.ejs

Custom template can customize parameters. You can define your own template based on the default template.

{
  website: {
    template: path.join(process.cwd(), "my-template.ejs")
  }
}

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:

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

<svg class="icon" aria-hidden="true">
  <use xlink:href="svgtofont.symbol.svg#svgtofont-git"></use>
</svg>

Unicode

<style>
.iconfont {
  font-family: "svgtofont-iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: 0.2px;
  -moz-osx-font-smoothing: grayscale;
}
</style>
<span class="iconfont">&#59907;</span>

Class Name

Support for .less and .css styles references.

<link rel="stylesheet" type="text/css" href="node_modules/fonts/svgtofont.css">
<i class="svgtofont-apple"></i>

Using With React

Icons are used as components. v3.16.7+ support.

import { Adobe, Alipay } from '@uiw/icons';

<Adobe style={{ fill: 'red' }} />
<Alipay height="36" />

In the project created by create-react-app

import logo from './logo.svg';

<img src={logo}  />
import { ReactComponent as ComLogo } from './logo.svg';

<ComLogo />

In the project created by webpack

yarn add babel-plugin-named-asset-import
yarn add @svgr/webpack
// webpack.config.js
[
  require.resolve('babel-plugin-named-asset-import'),
  {
    loaderMap: {
      svg: {
        ReactComponent: '@svgr/webpack?-svgo,+ref![path]',
      },
    },
  },
],
import { ReactComponent as ComLogo } from './logo.svg';

<ComLogo />

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

SvgToFont.jsx
// ↓↓↓↓↓↓↓↓↓↓

import { SvgToFont } from './SvgToFont';

<SvgToFont fontSize={32} color="#fefefe" iconName={"git"}  />
SvgToFont.d.ts
// ↓↓↓↓↓↓↓↓↓↓

import { TextStyle } from 'react-native';

export type SvgToFontIconNames = 'git'| 'adobe'| 'demo' | 'left' | 'styleInline'

export interface SvgToFontProps extends Omit<TextStyle, 'fontFamily' | 'fontStyle' | 'fontWeight'> {
  iconName: SvgToFontIconNames
}

export declare const SvgToFont: (props: SvgToFontProps) => JSX.Element;

Contributors

As always, thanks to our amazing contributors!

Made with contributors.

License

Licensed under the MIT License.

svgtofont's People

Contributors

bstaley avatar btmurrell avatar chenyulun avatar dependabot[bot] avatar erjanmx avatar hairyf avatar jaywcjlove avatar jgab-net avatar lucasbourgeois avatar manbearwiz avatar renovate-bot avatar renovate[bot] avatar robbyuitbeijerse avatar serkodev avatar stefanreimert avatar stevematney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svgtofont's Issues

React components

I'd like to use icons as React components... but viewPort is not customizable and there are no templates for React.

Set a font size to the CSS generated?

It would be nice to have the possibility to set the font-size on the css generated before build it, this would avoid me to change it manually after the build.

So instead to have 16px every time:

.iconfont {
  font-family: "svgtofont-iconfont" !important;
  font-size: 16px;
  ...
}

Have the possibility to set a custom font-size:

.iconfont {
  font-family: "svgtofont-iconfont" !important;
  font-size: 24px; /* material icons like font-size */
  ...
}

Duotone?

This is a really great app, and much appreciated. I'm not sure what would be involved in getting the duotone functionality that is in fontawesome icons going. I have some duotone SVG's, but I'm not sure what needs to be done to make that work in a font. Is that something you might be able to take on?

Typo in 'clssaNamePrefix' option

Hello!
I think classNamePrefix what is meant. Struggled a few minutes to understand is typo only in markdown or in code in general.
The variable with a typo is working for me. I think this should be fixed.
image

documented method does not work

your readme says use this script target to run:

{
  "scripts": {
    "font": "svgtofont --sources ./svg --output ./font --fontName uiw-font"
  },
}

but svgtofont does not exist. It is not installed as a linked bin under node_modules/.bin because your package.json has no bin directive.

as a workaround, i was able to get it to run by referencing your cli directly as in:

{
  "scripts": {
    "font": "node ./node_modules/svgtofont/bin/cli.js --sources ./svg --output ./font --fontName uiw-font"
  },
}

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update peaceiris/actions-gh-pages action to v4

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • actions/setup-node v4
  • peaceiris/actions-gh-pages v3
  • ncipollo/release-action v1
npm
package.json
  • auto-config-loader ^1.7.4
  • cheerio ~1.0.0-rc.12
  • colors-cli ~1.0.28
  • copy-template-dir ~1.4.0
  • del ~6.1.0
  • ejs ~3.1.6
  • fs-extra ~11.2.0
  • image2uri ~1.0.5
  • move-file ~2.1.0
  • svg2ttf ~6.0.3
  • svgicons2svgfont ~12.0.0
  • svgo ~3.2.0
  • ttf2eot ~3.1.0
  • ttf2woff ~3.0.0
  • ttf2woff2 ~5.0.0
  • yargs ~17.7.1
  • @types/cheerio ~0.22.31
  • @types/ejs ~3.1.0
  • @types/fs-extra ^11.0.1
  • @types/ttf2eot ~2.0.0
  • @types/ttf2woff ~2.0.2
  • @types/ttf2woff2 ~2.0.0
  • @types/svg2ttf ~5.0.1
  • @types/svgicons2svgfont ~10.0.1
  • tsbb ^4.1.5
  • @types/svg2ttf ~5.0.1
  • @types/svgicons2svgfont ~10.0.1
  • node >=16.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Feature request: Generate typescript enums

Proposal: Generate Typescript file with enum for icon class names. Copped this idea from a similar library.

export enum Icon {
  SomeIcon: 'my-font-some-icon'
}

Advantages:

  • Users would get Typescript errors if an icon was removed or renamed
  • No code changes required when changing prefixes

部分svg图形无法以symbol的方式预览?

部分svg的图像在导出后以symbol模式无法正常预览,可能是因为linearGradient标签?无渐变的图像没有碰到这样的问题,供测试的一个图形:

<svg width="80" height="80" 
  xmlns="http://www.w3.org/2000/svg" 
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <filter x="-56.1%" y="-47.1%" width="212.1%" height="236.4%" filterUnits="objectBoundingBox" id="a">
      <feOffset dy="11" in="SourceAlpha" result="shadowOffsetOuter1"/>
      <feGaussianBlur stdDeviation="10.5" in="shadowOffsetOuter1" result="shadowBlurOuter1"/>
      <feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"/>
      <feColorMatrix values="0 0 0 0 0.99607843 0 0 0 0 0.7137255 0 0 0 0 0.19607843 0 0 0 0.3 0" in="shadowBlurOuter1"/>
    </filter>
    <filter x="-22.6%" y="-10.6%" width="145.1%" height="141.5%" filterUnits="objectBoundingBox" id="d">
      <feOffset dy="14" in="SourceAlpha" result="shadowOffsetOuter1"/>
      <feGaussianBlur stdDeviation="9" in="shadowOffsetOuter1" result="shadowBlurOuter1"/>
      <feColorMatrix values="0 0 0 0 0.99607843 0 0 0 0 0.7137255 0 0 0 0 0.19607843 0 0 0 0.3 0" in="shadowBlurOuter1"/>
    </filter>
    <path d="M57.3825547,16.6671252 C56.2117999,15.0843216 49.3786159,6.46906501 46.7680316,3.18193612 C46.1289184,2.37721435 45.1482311,1.90702871 44.1097632,1.90702871 L16.4094217,1.90702871 C15.3463819,1.90702871 14.3455018,2.39983998 13.7083957,3.23651915 L3.57807331,16.553163 C3.43508175,16.739642 3.32517714,16.9490072 3.2526778,17.1714057 C3.01620346,17.9032459 2.60699581,19.6304052 3.24100006,21.4614131 C3.32286592,21.6966363 3.44700278,21.9154376 3.60793671,22.1073384 L27.3182604,49.5139639 C28.0206281,50.3362544 29.1412659,51.1369619 30.1195811,51.1369619 C31.4243867,51.1369619 32.1751684,50.8106628 33.2596782,49.8283767 C35.0214972,48.2332176 56.6387066,22.6780361 57.4028083,21.7358923 C57.7178641,21.3458347 58.3608091,17.9894214 57.3825547,16.6671252 L57.3825547,16.6671252 Z" id="b"/>
    <path d="M23.2669778,14.4813425 L37.7482943,14.4813425 C39.3479021,14.4813425 40.6446184,15.7780414 40.6446184,17.3774755 C40.6446184,18.977118 39.3479021,20.2738169 37.7482943,20.2738169 L23.2669778,20.2738169 C21.6674308,20.2738169 20.3707145,18.977118 20.3707145,17.3774755 C20.3707145,15.7780414 21.6674308,14.4813425 23.2669778,14.4813425 Z" id="e"/>
    <linearGradient x1="50%" y1="100%" x2="50%" y2="0%" id="c">
      <stop stop-color="#FEB22B" offset="0%"/>
      <stop stop-color="#FAE37B" offset="100%"/>
    </linearGradient>
  </defs>
  <g fill="none" fill-rule="evenodd">
    <g transform="translate(9 .546)">
      <use fill="#000" filter="url(#a)" xlink:href="#b"/>
      <use fill="url(#c)" xlink:href="#b"/>
    </g>
    <g transform="translate(9 .546)">
      <use fill="#000" filter="url(#d)" xlink:href="#e"/>
      <use fill="#FFF" xlink:href="#e"/>
    </g>
    <text font-family="PingFang-SC-Medium, PingFang SC" font-size="24" font-weight="400" fill="#404040" transform="translate(-13)">
      <tspan x="28.5" y="104">积分</tspan>
    </text>
  </g>
</svg>

同样的图形使用webpack的svg-sprite-loader生成的图像可以正常加载。

svgicons2svgfont settings not adopted ?

Hi @jaywcjlove ,

First of all, thanks for sharing this useful software !

Though, I'm have a small issue.
It seems the settings from the svgicons2svgfont object aren't adopted in the generated css file.

Please take a look at this printscreen.
image

Can you please tell give me some help / a hint ?

Thanks in advance for your reply,

Kind regards,
Johnny Driesen
Belgium

CLI more options

Hey @jaywcjlove @btmurrell , can someone help me how i can modify npm cli command svgtofont --sources build/icons/svg --output ./font --fontName icons to get only font and less file not other files.

Attribute fill-rule seems to be ignored

I'm trying to build a font with some svg exported from Figma, as flatten shape, when I export it from Figma it generates this svg as a terminal icon:

<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 6C2 4.89543 2.89543 4 4 4H20C21.1046 4 22 4.89543 22 6V18C22 19.1046 21.1046 20 20 20H4C2.89543 20 2 19.1046 2 18V6ZM4 6H6V8H4V6ZM14 6H8V8H14V6ZM4 10H10V12H4V10ZM20 6H16V8H20V6Z" fill="black"/>
</svg>

When I use it to build the font, no errors are thrown, but when I try to see the icon it is show like fill-rule="evenodd" is ignored, resulting like this svg:

<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M2 6C2 4.89543 2.89543 4 4 4H20C21.1046 4 22 4.89543 22 6V18C22 19.1046 21.1046 20 20 20H4C2.89543 20 2 19.1046 2 18V6ZM4 6H6V8H4V6ZM14 6H8V8H14V6ZM4 10H10V12H4V10ZM20 6H16V8H20V6Z" fill="black"/>
</svg>

Would it be nice if this can be fixed.

It seems to be an existing problem also for other libs: nfroidure/svgicons2svgfont#62

创建图标完成后promise的then没有执行

我记得上个版本是可以的,加了emptyDist这个字段的新版本不执行了

svgtofont({
    src: item,
    dist,
    fontName,
    css: true,
    startNumber: 20000,
    emptyDist: false
  }).then(() => {
    console.log('done没有执行')
  }).catch((err) => {
    // console.log(err)
  })

path

Moudle 'path' dose not exist in the Haste moudle map

Wrong absolute paths

Im using cmake to generate font in build steps, cmake fills the input and output directories.
There is no problem with cmake commands, This program (svgtofont) goes wrong with absolute paths.

cmake definitions:

set(SVG_ICONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources/svgFont/svg)
set(FONTICONS_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated_font)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/svgFont/package.json.in ${CMAKE_CURRENT_BINARY_DIR}/package.json)

package.json.in file:

//  /home/.../project/fonts/package.json.in
"scripts": {
    "font": "svgtofont --sources @SVG_ICONS_DIR@ --output @FONTICONS_OUTPUT_DIR@"
  }

generated package.json file:

//   /home/.../project_build/fonts/package.json
"scripts": {
    "font": "svgtofont --sources  /home/.../project/fonts/svg --output  /home/.../project_build/generated_font"
  }

error:

The directory does not exist! /home/.../project_build/home/.../project/fonts/svg

It appends input path to running path ( the result is someting like this /home/.../project_build/home/.../project/fonts/svg)

A real example:

[user1@fedora GUI]$ npm run font

> font
> svgtofont --sources /home/user1/projects/MainApp/plugins/GUI/resources/svgFont/svg --output /home/user1/builds/build-MainApp-Desktop_Qt_5_15_2_GCC_64bit-Debug/plugins/GUI/generated_font

The directory does not exist! /home/user1/builds/build-MainApp-Desktop_Qt_5_15_2_GCC_64bit-Debug/plugins/GUI/home/user1/projects/MainApp/plugins/GUI/resources/svgFont/svg

I even tested it without cmake and it still had this problem.

Heroicons SVGs with stroke lines...

Excellent tool!!!... I've created my first font from a bunch of SVGs on the first try!!!

But I have a problem with Heroicons.

The resulting fonts ( at least the .ttf versions ) were not converted correctly because most of the designs contain stroke lines instead of outlines.

Is there a way to auto-convert them to outlines before creating the font file ???

Thanks!!

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

直接打开symbol.html 图标展示不出来

有两个问题:

  1. 需要启动服务器
  2. symbol.svg 文件和html 文件需要放到同一个域名下,否则use 引用有跨域问题

解决:可以生成对应的symbol.js 文件,将symbol.svg 文件的svg append 放到html里面,更改use xlink:href 直接写对应的id,就可以展示出来了
js 文件大概结构:
var symbols = '<svg style="width:0; height:0; visibility:hidden;position:absolute;z-index:-1"><symbol viewBox="0 0 24 24" id="heart"><path fill="#E86C60" d="M17,0c-1.9,0-3.7,0.8-5,2.1C10.7,0.8,8.9,0,7,0C3.1,0,0,3.1,0,7c0,6.4,10.9,15.4,11.4,15.8 c0.2,0.2,0.4,0.2,0.6,0.2s0.4-0.1,0.6-0.2C13.1,22.4,24,13.4,24,7C24,3.1,20.9,0,17,0z"></path></symbol></svg>'; document.body.insertAdjacentHTML("afterBegin",symbols)
需要去掉svg 标签里面的换行,不然会报错

Release frequency

I'm using renovate bot in my projects to keep dependencies up-to-date, and I'm wondering if it is really expected to have ~ 10 releases during the last 5 hours while every release just contains 1-2 commits/changes? I can handle this in my dependency update process if this release frequency was intended.

SVG conversion broken for mirrored paths with opposite winding order

Here is the original icon, likely created by mirroring the left eye to create the right eye.
Download "bad.svg": https://user-images.githubusercontent.com/39946030/172930821-ec22550d-76d9-41e7-898c-22f7310df846.svg
Godot_icon_bad_winding

Here is the same icon, fixed by hand to have matching vertex order in the right eye as left:
Download "fixed.svg": https://user-images.githubusercontent.com/39946030/172931900-d648e8c6-ce69-4373-bda7-cced07a34974.svg
Godot_icon_fixed

You can see the result here: The first icon is the "fixed" one. The second with missing eye is the "bad" original icon:
godot_icon_fontdrop_winding
The same bug is present on Glyphter. It is possible their backend uses some code from svgtofont.

To test, save the "fixed" icon as svg/a.svg and the "bad" icon as svg/b.svg. Then, run this command:

svgtofont --sources ./svg --output ./font --fontName godot-icon

This command successfully creates .ttf. Please ignore the exception: it happens after the .ttf is generated, so there is no problem for me.

Here are the specific paths which I changed by hand between the "bad" and "fixed" SVG documents.

Original "bad":

<svg><g><path fill="#ffffff" d="
M-247.2-10.7c0,50.1-40.6,90.7-90.8,90.7c-50.1,0-90.7-40.6-90.7-90.7c0-50.1,40.6-90.7,90.7-90.7C-287.8-101.5-247.2-60.9-247.2-10.7
M-1.6-10.7c0,50.1,40.6,90.7,90.8,90.7c50.1,0,90.7-40.6,90.7-90.7c0-50.1-40.6-90.7-90.7-90.7C38.9-101.5-1.6-60.9-1.6-10.7"/>
<path fill="#414042" d="
M-269-5.3c0,33.2-26.9,60.2-60.2,60.2c-33.2,0-60.2-26.9-60.2-60.2c0-33.2,26.9-60.2,60.2-60.2C-296-65.6-269-38.6-269-5.3
M 20-5.3c0,33.2,26.9,60.2,60.2,60.2c33.3,0,60.2-26.9,60.2-60.2c0-33.2-26.9-60.2-60.2-60.2C47-65.6,20-38.6,20-5.3"/></g></svg>

"fixed" version:

<svg><g><path fill="#ffffff" d="
M-247.2-10.7c0,50.1-40.6,90.7-90.8,90.7c-50.1,0-90.7-40.6-90.7-90.7c0-50.1,40.6-90.7,90.7-90.7C-287.8-101.5-247.2-60.9-247.2-10.7
M176-10.7c0,50.1-40.6,90.7-90.8,90.7c-50.1,0-90.7-40.6-90.7-90.7c0-50.1,40.6-90.7,90.7-90.7C135-101.5,176-60.9,176-10.7"/>
<path fill="#414042" d="
M-269-5.3c0,33.2-26.9,60.2-60.2,60.2c-33.2,0-60.2-26.9-60.2-60.2c0-33.2,26.9-60.2,60.2-60.2C-296-65.6-269-38.6-269-5.3
M 140-5.3c0,33.2-26.9,60.2-60.2,60.2c-33.2,0-60.2-26.9-60.2-60.2c0-33.2,26.9-60.2,60.2-60.2C113-65.6,140-38.6,140-5.3"/></g></svg>

Rounded corners not being shown properly

Here is the svg icon and attached is the font. Does anyone know why it is not being shown properly?

<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24pt" height="24pt" viewBox="0 0 24 24" version="1.1"> <g id="surface1"> <path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 11.464844 4.851562 C 9.957031 4.976562 8.546875 5.566406 7.378906 6.554688 C 7.269531 6.648438 7.03125 6.875 6.851562 7.0625 L 6.523438 7.40625 L 6.460938 7.132812 C 6.425781 6.980469 6.371094 6.75 6.335938 6.621094 C 6.292969 6.433594 6.183594 5.960938 6.035156 5.304688 C 6.027344 5.261719 6.015625 5.257812 5.949219 5.273438 C 5.90625 5.28125 5.632812 5.347656 5.34375 5.414062 C 5.054688 5.480469 4.8125 5.539062 4.808594 5.542969 C 4.800781 5.550781 4.933594 6.132812 5.320312 7.78125 C 5.359375 7.941406 5.476562 8.441406 5.578125 8.894531 C 5.683594 9.34375 5.773438 9.71875 5.777344 9.722656 C 5.789062 9.734375 6.003906 9.6875 6.878906 9.480469 C 7.238281 9.394531 8.078125 9.203125 8.738281 9.046875 C 9.402344 8.890625 9.949219 8.761719 9.957031 8.757812 C 9.960938 8.75 9.921875 8.550781 9.867188 8.316406 C 9.8125 8.078125 9.75 7.808594 9.730469 7.714844 C 9.710938 7.625 9.683594 7.546875 9.667969 7.546875 C 9.65625 7.546875 9.214844 7.648438 8.6875 7.769531 C 8.160156 7.894531 7.726562 7.988281 7.71875 7.988281 C 7.707031 7.972656 7.859375 7.816406 8.0625 7.632812 C 8.910156 6.851562 10.003906 6.332031 11.179688 6.148438 C 11.5625 6.089844 12.488281 6.089844 12.867188 6.148438 C 14.480469 6.402344 15.800781 7.1875 16.761719 8.453125 C 18.097656 10.226562 18.320312 12.601562 17.332031 14.613281 C 17.035156 15.214844 16.671875 15.71875 16.183594 16.210938 C 15.226562 17.160156 13.949219 17.757812 12.601562 17.886719 C 12.230469 17.917969 11.496094 17.902344 11.167969 17.847656 C 9.792969 17.632812 8.574219 16.984375 7.664062 15.980469 C 7.539062 15.84375 7.371094 15.636719 7.285156 15.519531 C 7.203125 15.402344 7.128906 15.308594 7.117188 15.304688 C 7.09375 15.304688 6.125 15.957031 6.105469 15.988281 C 6.097656 16 6.144531 16.085938 6.214844 16.179688 C 6.933594 17.167969 7.777344 17.886719 8.847656 18.410156 C 9.328125 18.648438 9.597656 18.753906 10.03125 18.878906 C 12.5625 19.609375 15.242188 18.921875 17.097656 17.074219 C 18.214844 15.960938 18.910156 14.546875 19.140625 12.9375 C 19.203125 12.492188 19.199219 11.425781 19.132812 10.992188 C 18.882812 9.40625 18.207031 8.046875 17.117188 6.953125 C 16.527344 6.355469 15.980469 5.960938 15.222656 5.589844 C 14.597656 5.28125 14.097656 5.105469 13.464844 4.980469 C 12.851562 4.855469 12.03125 4.804688 11.464844 4.851562 Z M 11.464844 4.851562 "/> <path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 11.320312 8.347656 C 11.019531 8.402344 10.765625 8.445312 10.761719 8.449219 C 10.757812 8.453125 10.792969 8.667969 10.835938 8.933594 C 10.882812 9.191406 10.917969 9.40625 10.914062 9.40625 C 10.835938 9.429688 10.421875 9.664062 10.296875 9.757812 L 10.132812 9.882812 L 9.742188 9.605469 L 9.355469 9.332031 L 9.042969 9.769531 C 8.875 10.011719 8.710938 10.238281 8.679688 10.28125 L 8.625 10.351562 L 8.980469 10.605469 C 9.179688 10.746094 9.347656 10.867188 9.359375 10.875 C 9.367188 10.882812 9.347656 10.953125 9.316406 11.03125 C 9.246094 11.210938 9.167969 11.5 9.144531 11.683594 L 9.128906 11.820312 L 8.695312 11.898438 C 8.457031 11.9375 8.261719 11.972656 8.257812 11.972656 C 8.253906 11.980469 8.46875 13.1875 8.476562 13.195312 C 8.480469 13.199219 8.664062 13.175781 8.878906 13.140625 C 9.332031 13.066406 9.304688 13.070312 9.304688 13.109375 C 9.304688 13.175781 9.535156 13.609375 9.664062 13.789062 C 9.742188 13.894531 9.789062 13.984375 9.78125 14 C 9.769531 14.015625 9.675781 14.148438 9.570312 14.300781 C 9.464844 14.449219 9.375 14.582031 9.371094 14.59375 C 9.359375 14.632812 10.363281 15.332031 10.390625 15.308594 C 10.40625 15.296875 10.503906 15.160156 10.605469 15.011719 C 10.757812 14.792969 10.800781 14.742188 10.839844 14.75 C 10.867188 14.757812 10.976562 14.792969 11.089844 14.832031 C 11.269531 14.898438 11.589844 14.960938 11.800781 14.980469 L 11.871094 14.988281 L 11.929688 15.332031 C 11.960938 15.519531 11.996094 15.683594 12.003906 15.6875 C 12.015625 15.703125 13.191406 15.507812 13.210938 15.484375 C 13.21875 15.476562 13.199219 15.320312 13.171875 15.136719 C 13.140625 14.949219 13.117188 14.796875 13.117188 14.789062 C 13.121094 14.785156 13.203125 14.734375 13.304688 14.683594 C 13.519531 14.570312 13.746094 14.421875 13.910156 14.28125 L 14.027344 14.183594 L 14.320312 14.394531 C 14.480469 14.503906 14.621094 14.597656 14.628906 14.601562 C 14.65625 14.601562 15.355469 13.589844 15.335938 13.574219 C 15.324219 13.5625 15.183594 13.460938 15.023438 13.347656 C 14.863281 13.234375 14.726562 13.140625 14.726562 13.140625 C 14.722656 13.136719 14.746094 13.050781 14.777344 12.953125 C 14.84375 12.746094 14.90625 12.394531 14.90625 12.230469 C 14.90625 12.101562 14.867188 12.117188 15.351562 12.035156 C 15.550781 12 15.71875 11.96875 15.71875 11.96875 C 15.730469 11.960938 15.519531 10.753906 15.507812 10.742188 C 15.503906 10.738281 15.3125 10.765625 15.082031 10.808594 C 14.730469 10.867188 14.65625 10.875 14.644531 10.847656 C 14.433594 10.492188 14.359375 10.375 14.242188 10.238281 L 14.109375 10.078125 L 14.234375 9.894531 C 14.304688 9.796875 14.421875 9.628906 14.492188 9.527344 C 14.621094 9.351562 14.625 9.339844 14.585938 9.300781 C 14.523438 9.242188 13.636719 8.625 13.613281 8.625 C 13.605469 8.625 13.476562 8.792969 13.332031 9 C 13.109375 9.3125 13.058594 9.371094 13.019531 9.363281 C 12.71875 9.277344 12.496094 9.230469 12.359375 9.21875 C 12.265625 9.210938 12.179688 9.191406 12.167969 9.179688 C 12.152344 9.15625 12 8.328125 12 8.265625 C 12 8.238281 11.886719 8.253906 11.320312 8.347656 Z M 12.414062 10.5 C 13 10.648438 13.457031 11.105469 13.609375 11.695312 C 13.660156 11.898438 13.660156 12.289062 13.609375 12.484375 C 13.457031 13.054688 13.058594 13.472656 12.496094 13.660156 C 12.339844 13.710938 12.277344 13.71875 12.011719 13.71875 C 11.746094 13.71875 11.683594 13.710938 11.527344 13.660156 C 10.890625 13.449219 10.472656 12.945312 10.378906 12.273438 C 10.300781 11.683594 10.609375 11.042969 11.136719 10.703125 C 11.503906 10.46875 11.984375 10.390625 12.414062 10.5 Z M 12.414062 10.5 "/> </g> </svg>

image

只生成了 svg ttf eot 文件 其他文件创建失败

node:v10.8.0
svgtofont: v1.3.0

A fontHeight of at least than 1000 is recommended, otherwise further steps (rounding in svg2ttf) could lead to ugly results. Use the fontHeight option to scale icons.
Font created
SUCCESS SVG font successfully created! /Users/zhuweipeng/qtshe-project/qts-admin/fonts1571797765738/font1571797765738.svg
SUCCESS TTF font successfully created! /Users/zhuweipeng/qtshe-project/qts-admin/fonts1571797765738/font1571797765738.ttf
SUCCESS EOT font successfully created! /Users/zhuweipeng/qtshe-project/qts-admin/fonts1571797765738/font1571797765738.eot
Checksum error in glyf

Errors when installing locally: Namespace '"fs"' has no exported member...

Thanks for this useful tool!
Generating a font from svg icons works fine, also the web app builds fine with webpack.
BUT when I install it locally, I get these errors:

✖ 「atl」: Checking finished with 10 errors
[at-loader] ./node_modules/@types/fs-extra/index.d.ts:188:87 
    TS2694: Namespace '"fs"' has no exported member 'Dir'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:191:17 
    TS2694: Namespace '"fs"' has no exported member 'OpenDirOptions'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:192:53 
    TS2694: Namespace '"fs"' has no exported member 'Dir'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:194:52 
    TS2694: Namespace '"fs"' has no exported member 'OpenDirOptions'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:194:80 
    TS2694: Namespace '"fs"' has no exported member 'Dir'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:265:52 
    TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:265:167 
    TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:266:52 
    TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:266:149 
    TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'. 

[at-loader] ./node_modules/@types/fs-extra/index.d.ts:267:52 
    TS2694: Namespace 'NodeJS' has no exported member 'ArrayBufferView'. 

If I check in yarn.lock, it contains different versions of fs-extra:

"@types/[email protected]":
[email protected]:
fs-extra@^4.0.3:
fs-extra@^7.0.1:
fs-extra@^8.1.0:

Btw, in node_modules/fs-extra/package.json it shows "version": "7.0.1".
My guess is that these version aren't compatible or that it tries to use the types from v9.0.1 for v7.0.1.
Any idea what I can do to eliminate these errors? :)

生成多余的css icon-class

我想一个页面或者是组件用一个font-family,这样不会污染全局的icon-class
第一个svgtofont执行目录的css:

.w-playback-icon-pause:before { content: "\ea01"; }
.w-playback-icon-start:before { content: "\ea02"; }

第二个svgtofont执行目录的css:

.w-page-icon-pause:before { content: "\ea01"; }
.w-page-icon-start:before { content: "\ea05"; }
.w-page-icon-back-example:before { content: "\ea03"; }
.w-page-icon-option:before { content: "\ea04"; }
.w-page-icon-top:before { content: "\ea06"; }

第二个目录的css的 .w-page-icon-pause:before { content: "\ea01"; } 其实是上一个执行目录的

在生成fonts文件中,我已经用 async/await 语法隔离了执行顺序,保证一个 svgtofont 执行完成下个svgtofont才会执行,事实上,生成的svg文件是正确的
第一个svgtofont执行目录的svg:

<glyph glyph-name="pause">
<glyph glyph-name="start">

第二个svgtofont执行目录的svg:

<glyph glyph-name="back-example">
<glyph glyph-name="option">
 <glyph glyph-name="start">
<glyph glyph-name="top">

所以定位到是svgtofont的问题,不是我写的生成脚本有问题
脚本地址: https://github.com/kallsaver/my-learn/blob/master/vue-anime-learn/build/svgtofont.js
项目地址: https://github.com/kallsaver/my-learn/blob/master/vue-anime-learn

SVG's with mask tags are rendering wrong

SVG's containing mask tags are rendering wrong.

Airplane Icon:
image

After svgtofont:
image

SVG Code:
<svg width="24" height="25" fill="none" xmlns="http://www.w3.org/2000/svg"><mask id="a" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="2" y="2" width="20" height="21"><path d="M21.5 14.925c0-.36-.19-.69-.49-.89l-7.51-4.69v-5.5c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v5.5l-7.51 4.69a1.05 1.05 0 0 0 .87 1.89l6.64-2.08v5.5l-1.8 1.35a.48.48 0 0 0-.2.4v.59c0 .33.32.57.64.48l2.86-.82 2.86.82c.32.09.64-.15.64-.48v-.59a.48.48 0 0 0-.2-.4l-1.8-1.35v-5.5l6.64 2.08c.68.21 1.36-.3 1.36-1Z" fill="#000"/></mask><g mask="url(#a)"><path fill="currentColor" d="M0 .265h24v24H0z"/></g></svg>

SVGO is also not supporting flattening (or converting mask to path): svg/svgo#680

For some simple icons (1 path icons), I can simply remove mask tag to make them render like they supposed to be, but more complex (2 or more paths and multiple mask overlays) are not rendering correctly.

What can I do to make them render 1:1 to it's original?

可以生成无需添加class或者unicode就能使用的字体吗

我有 0-9 这 10 个数字的 svg, 想把这 10 个 svg 转成一个字体文件,供页面上的阿拉伯数字使用。

重点就是不要像使用 iconfont 那样,还得加 class 或者写 unicode,就是 2 步到位:

  • 页面加载这个字体文件
  • 给需要的元素指定 font-family

就像使用系统字体差不多的形式,请问可以吗😅

生成后一部分图标显示有问题

例子:
原来的svg
app
生成后使用效果
app2

原来的svg
archive
生成后使用效果
archive2

主要是outline风格的svg会出现类似问题
个别filled风格的svg也有这样的问题
例子
原来的svg
simfill
生成后使用效果
simfill2

请问是我哪里操作不对还是一些别的问题

IE8 error:CSS3111: @font-face

error:
CSS3111: @font-face 遇到了未知错误。
image
image

CSS:
`
@font-face {
font-family: "iconfont";
src: url('iconfont.eot?t=1639564699070'); /* IE9*/
src: url('iconfont.eot?t=1639564699070#iefix') format('embedded-opentype'), /* IE6-IE8 /
url("iconfont.woff2?t=1639564699070") format("woff2"),
url("iconfont.woff?t=1639564699070") format("woff"),
url('iconfont.ttf?t=1639564699070') format('truetype'), /
chrome, firefox, opera, Safari, Android, iOS 4.2+/
url('iconfont.svg?t=1639564699070#iconfont') format('svg'); /
iOS 4.1- */
}

[class^="iconfont-"], [class*=" iconfont-"] {
font-family: 'iconfont' !important;
font-size:16px;
font-style:normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.iconfont-adobe:before { content: "\ea01"; }
.iconfont-demo:before { content: "\ea02"; }
.iconfont-git:before { content: "\ea03"; }
.iconfont-left:before { content: "\ea04"; }
.iconfont-stylelint:before { content: "\ea05"; }

`

HTML:

<title>Document</title>

The preview file is not created in the .HTML format !

I use this command to execute

"svg-icon": "svgtofont --sources \"src/svg-raw\" --output \"src/svg-ico\"",

But the preview file is not created in HTML format, only two html empty files are created in which nothing is displayed

What is the problem? why is the .html preview file not created? Why are the files .html empty?

2022-07-21_202719

downloadable font: rejected by sanitizer

Hi

I'm generating with the following config:

const svgtofont = require('svgtofont');
const path = require('path');
 
svgtofont({
  src: path.resolve(__dirname, './icons'), // svg path
  dist: path.resolve(__dirname, './font'), // output path
  fontName: 'PIcon',
  classNamePrefix: 'PIcon-',
  css: true,
  emptyDist: true,
  styleTemplates: path.resolve(__dirname, './style-templates')
}).then(() => {
  console.log('PIcon font generated!');
});

Then I'm getting following errors in browser:

11:52:36.509 downloadable font: head: unitsPerEm on in the range [16, 16384]: 12 (font-family: "PIcon" style:normal weight:400 stretch:100 src index:1) source: http://localhost:6006/static/media/PIcon.a04f8760.woff2
11:52:36.509 downloadable font: head: Failed to parse table (font-family: "PIcon" style:normal weight:400 stretch:100 src index:1) source: http://localhost:6006/static/media/PIcon.a04f8760.woff2
11:52:36.509 downloadable font: rejected by sanitizer (font-family: "PIcon" style:normal weight:400 stretch:100 src index:1) source: http://localhost:6006/static/media/PIcon.a04f8760.woff2
11:52:36.561 downloadable font: head: unitsPerEm on in the range [16, 16384]: 12 (font-family: "PIcon" style:normal weight:400 stretch:100 src index:2) source: http://localhost:6006/static/media/PIcon.435b5d56.woff
11:52:36.561 downloadable font: head: Failed to parse table (font-family: "PIcon" style:normal weight:400 stretch:100 src index:2) source: http://localhost:6006/static/media/PIcon.435b5d56.woff
11:52:36.561 downloadable font: rejected by sanitizer (font-family: "PIcon" style:normal weight:400 stretch:100 src index:2) source: http://localhost:6006/static/media/PIcon.435b5d56.woff
11:52:36.642 downloadable font: head: unitsPerEm on in the range [16, 16384]: 12 (font-family: "PIcon" style:normal weight:400 stretch:100 src index:3) source: http://localhost:6006/static/media/PIcon.d6a54511.ttf
11:52:36.642 downloadable font: head: Failed to parse table (font-family: "PIcon" style:normal weight:400 stretch:100 src index:3) source: http://localhost:6006/static/media/PIcon.d6a54511.ttf
11:52:36.642 downloadable font: rejected by sanitizer (font-family: "PIcon" style:normal weight:400 stretch:100 src index:3) source: http://localhost:6006/static/media/PIcon.d6a54511.ttf

my only template

// src\libs\ui-lib\components\PIcon\style-templates\_{{filename}}.scss.template

@font-face {font-family: "{{fontname}}";
  src: url('{{cssPath}}{{fontname}}.eot?t={{timestamp}}'); /* IE9*/
  src: url('{{cssPath}}{{fontname}}.eot?t={{timestamp}}#iefix') format('embedded-opentype'), /* IE6-IE8 */
  url("{{cssPath}}{{fontname}}.woff2?t={{timestamp}}") format("woff2"),
  url("{{cssPath}}{{fontname}}.woff?t={{timestamp}}") format("woff"),
  url('{{cssPath}}{{fontname}}.ttf?t={{timestamp}}') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
  url('{{cssPath}}{{fontname}}.svg?t={{timestamp}}#{{fontname}}') format('svg'); /* iOS 4.1- */
}

[class^="{{prefix}}-"], [class*=" {{prefix}}-"] {
  font-family: '{{fontname}}' !important;
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  @apply relative text-center inline-block;
  @apply min-w-max;
}

{{cssString}}
{{cssToVars}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.