@chr33s/pdf-standard-fonts
v5.0.11
Published
Metrics for the Standard 14 PDF fonts and their encodings
Downloads
174
Readme
@chr33s/pdf-standard-fonts
Collection of metrics and encodings for the standard 14 PDF fonts
This project is a fork of afm and was created for use in @chr33s/pdf. This forks exists for two primary reasons:
- The original project did not include mappings from Unicode to WinAnsi/ZapfDingbats/Symbol encodings.
- The font metrics included in the original project were uncompressed (not ideal for usage in
pdf).
Usage
import { Font, FontNames, Encodings } from '@chr33s/pdf-standard-fonts';
const codePoint = '∑'.charCodeAt(0);
const glyph = Encodings.Symbol.encodeUnicodeCodePoint(codePoint);
glyph // => { code: 229, name: 'summation' }
const font = Font.load(FontNames.Symbol);
const width = font.getWidthOfGlyph(glyph.name);
width // => 713Installation
NPM Module
To install the latest stable version:
npm install --save @chr33s/pdf-standard-fontsThis assumes you're using npm as your package manager.
ESM Build
@chr33s/pdf-standard-fonts now ships only native ES modules compiled from the TypeScript sources. The published entry point is dist/index.js, which also ships bundled type declarations in dist/index.d.ts. Use Node 18+ or a modern bundler (Vite, Rollup, Webpack, etc.) to consume the package, and bundle it for browsers as needed.
License
Original Repo's License
Copyright 2015–2018 Christopher Brown. MIT Licensed.
