How to use svgicons2svgfont - 6 common examples

To help you get started, we’ve selected a few svgicons2svgfont examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / algoliasearch-client-css / scripts / demo / generate-font.js View on Github external
]).then(results => {
      const baseGlyphsDirectory = results[0];
      const boldGlyphsDirectory = results[1];
      const characters = results[2];

      const outputPath = './demo/public/fonts/Raleway.svg';
      const deferred = Promise.pending();
      const fontStream = svg2font({
        fontName: 'Raleway',
        normalize: true,
      });
      fontStream.pipe(fs.createWriteStream(outputPath))
                .on('finish', () => { deferred.resolve(outputPath); })
                .on('error', err => { deferred.reject(err); });

      const privateSpaceStart = 58880; // \e6XX private space
      _.each(characters, char => {
        const baseCodePoint = char.charCodeAt(0);
        const baseUnicodeCodePoint = baseCodePoint.toString(16);
        const baseGlyphPath = `${baseGlyphsDirectory}svg/uni${baseUnicodeCodePoint}.svg`;
        if (!fs.existsSync(baseGlyphPath)) {
          console.info(`⚠ No glyph for ${char} (${baseGlyphPath})`);
          return;
        }
github itgalaxy / webfont / src / standalone.js View on Github external
return new Promise((resolve, reject) => {
    const fontStream = new SVGIcons2SVGFontStream({
      ascent: options.ascent,
      centerHorizontally: options.centerHorizontally,
      descent: options.descent,
      fixedWidth: options.fixedWidth,
      fontHeight: options.fontHeight,
      fontId: options.fontId,
      fontName: options.fontName,
      fontStyle: options.fontStyle,
      fontWeight: options.fontWeight,
      // eslint-disable-next-line no-console, no-empty-function
      log: options.verbose ? console.log.bind(console) : () => {},
      metadata: options.metadata,
      normalize: options.normalize,
      round: options.round
    })
      .on("finish", () => resolve(result))
github itgalaxy / webfont / src / standalone.js View on Github external
function getGlyphsData(files, options) {
  const metadataProvider =
    options.metadataProvider ||
    defaultMetadataProvider({
      prependUnicode: options.prependUnicode,
      startUnicode: options.startUnicode
    });

  const xmlParser = new xml2js.Parser();
  const throttle = pLimit(options.maxConcurrency);

  return Promise.all(
    files.map(srcPath =>
      throttle(
        () =>
          new Promise((resolve, reject) => {
            const glyph = fs.createReadStream(srcPath);
            let glyphContents = "";

            return glyph
github entria / font-generator / src / generateSVGFont.js View on Github external
descent,
    normalize,
    round,
  } = options;

  const svgOptions = {
    fontName,
    fontHeight,
    descent,
    normalize,
    round,
  };

  //svgOptions.log = () => {};

  const fontStream = svgicons2svgfont(svgOptions)
    .on('data', (data) => {
      font = Buffer.concat([font, data])
    })
    .on('end', () => {
      done(null, font.toString());
    });

  options.files.map((file, idx) => {
    const glyph = fs.createReadStream(file);
    const name = options.names[idx];
    const unicode = String.fromCharCode(options.codepoints[name]);
    glyph.metadata = {
      name: name,
      unicode: [unicode]
    };
    fontStream.write(glyph)
github kiwicom / orbit-components / config / createSVGFont.js View on Github external
new Promise((resolve, reject) => {
    if (!fs.existsSync(ORBIT_ICONS_DIR)) {
      fs.mkdirSync(ORBIT_ICONS_DIR);
    }

    const fontStream = new SVGIcons2SVGFontStream({
      fontName: "orbit-icons",
      fontHeight: 1000,
      normalize: true,
    });

    fontStream
      .pipe(fs.createWriteStream(path.join(ORBIT_ICONS_DIR, "orbit-icons.svg")))
      .on("finish", () => {
        resolve();
      })
      .on("error", err => {
        reject(err);
      });

    Object.keys(iconList).forEach(iconName => {
      const iconPath =
github itgalaxy / webfont / src / standalone.js View on Github external
? glyphsData.sort((fileA, fileB) =>
          fileSorter(fileA.srcPath, fileB.srcPath)
        )

svgicons2svgfont

Read a set of SVG icons and output a SVG font

MIT
Latest version published 1 month ago

Package Health Score

89 / 100
Full package analysis