Package Exports
- fontname
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fontname) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
fontname
🅰️ Parse font file (TTF, OTF) metadata like font family name.
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 Use
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);
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.