How to use svg2ttf - 9 common examples

To help you get started, we’ve selected a few svg2ttf 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
svg2ttf(filepath) {
    const output = filepath.replace('.svg', '.ttf');

    const svg = fs.readFileSync(filepath, 'utf-8');
    fs.writeFileSync(output, new Buffer(svg2ttf(svg).buffer));
    return Promise.resolve(output);
  },
github itgalaxy / webfont / src / standalone.js View on Github external
function toTtf(buffer, options) {
  return Buffer.from(svg2ttf(buffer, options).buffer);
}
github entria / font-generator / src / svgToTTF.js View on Github external
const generateTTFfromSVGFont = (svgFont: string, options: Object) => {
  const font = svg2ttf(svgFont, options.formatOptions.ttf);

  return new Buffer(font.buffer);
};
github kiwicom / orbit-components / config / createSVGFont.js View on Github external
createSVG().then(() => {
  const TTF_PATH = path.join(ORBIT_ICONS_DIR, "orbit-icons.ttf");

  const TTF = svg2ttf(fs.readFileSync(path.join(ORBIT_ICONS_DIR, "orbit-icons.svg"), "utf8"), {});
  fs.writeFileSync(TTF_PATH, Buffer.from(TTF.buffer));

  fs.writeFileSync(
    path.join(ORBIT_ICONS_DIR, "orbit-icons.woff2"),
    ttf2woff2(fs.readFileSync(TTF_PATH)),
  );
});
github eugene1g / font-blast / src / verify.js View on Github external
function generateVerifyFile(svgFont: string, iconSet, withPng, toFolder) {
  //Convert the SVG file into a TTF file so that more browsers can parse and show it
  const ttf = svg2ttf(svgFont, {});
  fs.writeFileSync(
    path.join(toFolder, "source-font.ttf"),
    new Buffer(ttf.buffer)
  );

  //load the template for the verification file which contains some generic HTML
  let htmlTemplate = fs.readFileSync(
    path.join(__dirname, "..", "/resources/verify.html"),
    "utf-8"
  );
  let iconContent = [];
  let cssRules = [];

  //Add a header to to the table
  iconContent.push(
    `<div class="row"></div>
github noppa / text-security / build.js View on Github external
function svgToContours({width, height, d}) {
	const accuracy = Math.max(width, height) * 0.0006
	const svgPath = new SvgPath(d)
		.abs()
		.unshort()
		.unarc()
		.iterate((segment, index, x, y) => svg.cubicToQuad(segment, index, x, y, accuracy))

	const sfntContours = svg.toSfntCoutours(svgPath)

	return sfntContours.map(sfntContour => {
		const contour = new sfnt.Contour()

		contour.points = sfntContour.map(sfntPoint => {
			const point = new sfnt.Point()

			point.x = sfntPoint.x
			point.y = sfntPoint.y
			point.onCurve = sfntPoint.onCurve
			return point
		})

		return contour
	})
}
github noppa / text-security / build.js View on Github external
return sfntContours.map(sfntContour => {
		const contour = new sfnt.Contour()

		contour.points = sfntContour.map(sfntPoint => {
			const point = new sfnt.Point()

			point.x = sfntPoint.x
			point.y = sfntPoint.y
			point.onCurve = sfntPoint.onCurve
			return point
		})

		return contour
	})
}
github noppa / text-security / build.js View on Github external
contour.points = sfntContour.map(sfntPoint => {
			const point = new sfnt.Point()

			point.x = sfntPoint.x
			point.y = sfntPoint.y
			point.onCurve = sfntPoint.onCurve
			return point
		})
github noppa / text-security / build.js View on Github external
		.iterate((segment, index, x, y) => svg.cubicToQuad(segment, index, x, y, accuracy))

svg2ttf

Converts SVG font to TTF font

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis