Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fontkit

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fontkit

An advanced font engine for Node and the browser

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
increased by3.59%
Maintainers
1
Weekly downloads
 
Created

What is fontkit?

Fontkit is a comprehensive library for working with fonts in Node.js and the browser. It supports various font formats and provides a wide range of functionalities for font manipulation, including glyph rendering, font subsetting, and text layout.

What are fontkit's main functionalities?

Loading Fonts

This feature allows you to load a font from a file. The `openSync` method synchronously loads the font, making it ready for further operations.

const fontkit = require('fontkit');
const font = fontkit.openSync('path/to/font-file.ttf');

Glyph Rendering

This feature allows you to render glyphs from the font. You can get the glyph for a specific character and then convert it to an SVG path for rendering.

const glyph = font.glyphForCodePoint(65); // Get the glyph for the character 'A'
const path = glyph.path.toSVG(); // Get the SVG path data for the glyph

Font Subsetting

This feature allows you to create a subset of the font, including only the glyphs you need. This can be useful for reducing the size of the font file.

const subset = font.createSubset();
subset.includeGlyph(font.glyphForCodePoint(65)); // Include the glyph for 'A'
const subsetFont = subset.encode();

Text Layout

This feature allows you to layout text using the font. The `layout` method returns a run of glyphs, which you can then iterate over to get information about each glyph.

const run = font.layout('Hello, world!');
run.glyphs.forEach(glyph => {
  console.log(glyph.id, glyph.advanceWidth);
});

Other packages similar to fontkit

Keywords

FAQs

Package last updated on 18 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc