Socket
Socket
Sign inDemoInstall

fontname

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fontname

🅰️ Parse font file (TTF, OTF) metadata like font family name.


Version published
Maintainers
1
Created
Source

fontname

🅰️ Parse font file (TTF, OTF) metadata like font family name.

Demo

Upload a font and see the results at: https://danbovey.uk/fontname

Install

npm install fontname

yarn add fontname

Usage

FontName.parse(ArrayBuffer)

Parses an ArrayBuffer (binary data of the font from a FileReader) and returns an object with font meta. Throws on failure.

Example (browser)

import FontName from 'fontname';

const fontFile = e.target.files[0]; // File
const reader = new FileReader();
reader.onload = e => {
  const buffer = e.target.result; // ArrayBuffer
  try {
    const fontMeta = FontName.parse(e.target.result)[0];
    console.log(fontMeta);
  } catch (e) {
    // FontName may throw an Error
  }
};
reader.readAsArrayBuffer(fontFile);

Example (node)

const fs = require('fs');
const FontName = require('fontname');

try {
  const fontMeta = FontName.parse(fs.readFileSync('font.tff'))[0];
  console.log(fontMeta);
} catch (e) {
  // FontName may throw an Error
}

Returns

{
  "copyright": "Copyright 2011 Google Inc. All Rights Reserved.",
  "_lang": 0,
  "fontFamily": "Roboto",
  "fontSubfamily": "Regular",
  "ID": "Roboto",
  "fullName": "Roboto",
  "version": "Version 2.137; 2017",
  "postScriptName": "Roboto-Regular",
  "trademark": "Roboto is a trademark of Google.",
  "designer": "Google",
  "urlVendor": "Google.com",
  "urlDesigner": "Christian Robertson",
  "licence": "Licensed under the Apache License, Version 2.0",
  "licenceURL": "http://www.apache.org/licenses/LICENSE-2.0"
}

License

File parsing logic from Typr.js.

Keywords

FAQs

Package last updated on 20 Oct 2022

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