node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


SVG Font 2 glyph map

Takes an SVG font file and outputs a glyph map json file

The input file must be an SVG font file. This package is used from the Command line only.

The output glyph map is a json object where the keys are the glyph names (glyph-name) and the values are character codes of the gliphs unicode (unicode) values.

CLI interface

Usage: svgfont2glyphmap <fontFile> <outputFile>


$ svgfont2glyphmap ./myIcons.svg ./myIcons-map.json

Example input


<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "" >
<svg xmlns="">
  <font id="myIcons" horiz-adv-x="32">
    <font-face font-family="myIcons"
      units-per-em="32" ascent="32"
      descent="0" />
    <missing-glyph horiz-adv-x="0" />
    <glyph glyph-name="triangle-down"
      horiz-adv-x="32" d=" M0 24L32 24L16 8L0 24z" />
    <glyph glyph-name="triangle-up"
      horiz-adv-x="32" d=" M16 16L32 0L0 0z" />

Example output


  "triangle-up": 59940,
  "triangle-down": 59939