0.4.2 • Published 5 months ago

@itsib/icon-font v0.4.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Simple utilities for icon-font generation, automation and presentation. Includes preview web server.

Version Release


Features

  • Formatting of svg icons. The contour will be adjusted to the size of 512px and placed in the center.
  • Tune icon size and position if necessary.
  • Optimization. Extra points that do not affect the contour curves will be removed.
  • Configuration support as in package.json, and in a separate file. It can also be transmitted via the command line interface.
  • The input file format is svg.
  • The output file format is TTF, EOT, SVG, WOFF, WOFF2
  • A web server to demonstrate the result. The server will watch the changes in the input files and instantly display the result.

Demo Interface


Usage

Install:

npm install --save-dev @itsib/icon-font

Or global installation:

npm install -g @itsib/icon-font

Show help:

icon-font --help

Run demo server:

icon-font demo --input icons/dir

Generate fonts files:

icon-font generate --input icons/dir --output fonts/dir

Configuration

You need to create an icon-font.json file with json format in the root of your project. Or add field icon-font in package.json file.

{
  "input": "svg-icons",
  "output": "dist/fonts",
  "name": "IconFont",
  "prefix": "icon",
  "types": [ "woff2", "woff", "ttf", "eot"],
  "port": 9000,
  "fontUrl": "./",
  "fontUrlHash": false,
  "iconsTune": {}
}

Options description

Configuration parameters passed through the CLI have a higher priority than the configuration file.

OptionTypeRequiredDescription
inputstringThe directory containing the SVG icon files that will be included in the font being created
outputstringThe directory where the generated files will be placed, if it does not exist, it will be created.
namestringThe name of the new font, by default IconFont
prefixstringClass name prefix. Default icon
typesstring[]Output font types, to be generated. Default: [ "woff2", "woff", "ttf", "eot"]
portnumberDemo server port. Default 9000 (http://localhost:9000).
fontUrlstringThe URL where the font files will be available. Used in the css file @font-fase. Default /
fontUrlHashstring | false | "random"Adds the GET parameter 'hash=${HASH}' at the end of the URL to reset the browser cache. Set to 'random' for random number. Or use yur own value. False is disabled.
iconsTune{[name: string]: IconTune}Adjust the positioning and size for each icon. See below. Default {}

Icons Tune

The icon is sized and aligned automatically. But you can also configure each individual icon. To do this, use the iconsTune field, which contains an object whose keys are the names of icon files without an extension. For example:

{
  "iconsTune": {
    "helicopter": {
      "x": 0.2,
      "y": -0.5,
      "size": 1.5
    }
  }
}

This means that the icon with the file name helicopter.svg will be shifted to the right by 20%, down by 50%, and enlarged by one and a half times.

Icon Tune demo

Do not forget that for screens, the Y-axis begins (point 0) at the top, but in the OpenType and TrueType specifications, Y has a beginning at the bottom.

OptionTypeDescription
xnumberThe x-axis displacement of the icon. In basis point (percent / 100)
ynumberThe y-axis displacement of the icon. In basis point (percent / 100)
sizenumber | 'cover' | 'contain'Tune the icon size. If a number is passed, the size will be multiplied by it. For example, the icon is 300x500, size = 1.2, then the result will be 360x600. If cover is passed, the icon will fill the entire 512x512 square. If contain is passed, the icon will be inscribed in a 512x512 square. This is default behavior.

References

  • ots-sanitize - is a program which validates and/or transcodes a font file using the OTS library. Installation:

    sudo apt install opentype-sanitizer

    Usage:

    ots-sanitize dist/fonts/icon-font.ttf
  • ttfdump - dumps the contents of a TrueType font file in ASCII form. A TrueType font file is consist of various tables. Installation:

    sudo apt install texlive-binaries

    Usage

    ttfdump -t head dist/fonts/icon-font.ttf
    ttfdump -t OS/2 dist/fonts/icon-font.ttf
  • TrueFont spec - documentation for the TrueFont tables.

0.4.2

5 months ago

0.4.1

5 months ago

0.4.0

5 months ago

0.3.17

5 months ago

0.3.16

5 months ago

0.3.15

5 months ago

0.3.14

5 months ago

0.3.13

5 months ago

0.3.12

5 months ago

0.3.11

5 months ago

0.3.10

5 months ago

0.3.9

5 months ago

0.3.8

8 months ago

0.3.7

9 months ago

0.3.6

9 months ago

0.3.5

10 months ago

0.3.4

10 months ago

0.3.3

10 months ago

0.3.2

10 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.18

11 months ago

0.2.17

11 months ago

0.2.16

11 months ago

0.2.15

11 months ago

0.2.14

11 months ago

0.2.13

11 months ago

0.2.12

11 months ago

0.2.11

11 months ago

0.2.10

11 months ago

0.2.9

11 months ago

0.2.8

11 months ago

0.2.7

11 months ago

0.2.6

11 months ago

0.2.5

11 months ago

0.2.4

11 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.1.0

11 months ago

0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.8

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago