1.0.9 • Published 10 months ago

webfont-generator-cli v1.0.9

Weekly downloads
-
License
-
Repository
github
Last release
10 months ago

webfont-generator-cli

Convenient CLI to generate webfonts and css helper classes from SVGs.

Uses fontello API.

Preview

image

Installation

Install with NPM

npm i webfont-generator-cli --save-dev

Remove

npm remove webfont-generator-cli

Usage

Generate the webfont and css files

  • FROM: SVGs located in the icons folder | Path can be changed with --icons option
  • TO: webfont | Path can be changed with --out option

npx webfont-generator

Help

Get a list of the available options

npx webfont-generator-cli --help

Icons

Set the path to the SVGs folder (DEFAULT icons)

npx webfont-generator-cli --icons path_to_your_svgs

Out

Set the path of the output directory containing the font and CSS files (DEFAULT webfont)

npx webfont-generator-cli --out path_to_the_output_folder

Use the webfont

There are two different ways to use it

Import the webfont directly in your CSS

The font can be found to the following format on the output directory (DEFAULT webfont) inside the font subdirectory.

  • .eot
  • .svg
  • .ttf
  • .woff
  • .woff2

Import premade CSS file including a helper class for every icon

Premade CSS file can be found on the output directory (DEFAULT webfont) inside the css subdirectory.

webfont.css includes the required helpers class for all of your icons.

After importing the stylesheet, you can use the icon-{svg-file-name} class pattern to automatically render your icon inside a ::before pseudo-element

Styling

You can use the [class^="icon-"]:before, [class*=" icon-"]:before CSS selector to override any predefined styles as needed.

Example

npm i webfont-generator-cli --save-dev

my-icons
    - close.svg
    - profile.svg
index.html

Every SVG must have a viewBox attribute.

npx webfont-generator --icons my-icons --out my-webfont

index.html

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="./my-webfont/css/webfont.css">
  </head>
  <body>
        <i class="icon-profile"></i>
        <i class="icon-close"></i>
    </body>
</html>

image

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago