npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

opentype.features.js

v1.0.17

Published

Library to list opentype fonts optional features.

Downloads

21

Readme

OpenType.Features.js

Library to list opentype fonts optional features

Font table reading code from opentype.js

license builds.sr.ht status

Installation

npm install --save opentype.features.js

This assumes you are using npm as your package manager.

Works with ttf, woff and woff2 fonts.

Doesn't currently support woff2 font collections. ('ttcf')

Usage


// Example : running on node.

import Features from 'opentype.features.js';

const f = async () =>
{
    let features = await Features.getFeaturesFromFile('C:\\Windows\\Fonts\\CharisSIL-R.ttf');
    console.log(JSON.stringify(features));
}

f();

// Example : running in browser

import Features from 'opentype.features.js';

Features.getFeaturesFromUrl("http://localhost:3000/Andika-Regular.ttf").then((value) => {
  console.log(JSON.stringify(value));
});

// Example Outputs

[{"tag":"cv13","description":"Cap B-hook alt","options":["Lowercase style"],"alternateCharacters":["Ɓ"]},{"tag":"cv17","description":"Cap D-hook alt","options":["Lowercase style"],"alternateCharacters":["Ɗ"]},{"tag":"cv19","description":"Sm ezh-curl alt","options":["Large bowl"],"alternateCharacters":["ʓ"]},{"tag":"cv20","description":"Cap Ezh alts","options":["Reversed sigma"],"alternateCharacters":["Ʒ","Ӡ"]},{"tag":"cv25","description":"Rams horn alts","options":["Large Bowl","Small gamma"],"alternateCharacters":["ɤ"]},{"tag":"cv28","description":"Cap H-stroke alt","options":["Vertical-stroke"],"alternateCharacters":["Ħ"]},{"tag":"cv37","description":"J-strok alt","options":["Top serif"],"alternateCharacters":["ʄ"]},{"tag":"cv43","description":"Uppercase Eng alts","options":["Large eng on baseline","Capital N with tail","Large eng with short stem"],"alternateCharacters":["Ŋ"]},{"tag":"cv44","description":"Cap N-left-hook alt","options":["Lowercase style"],"alternateCharacters":["Ɲ"]},{"tag":"cv46","description":"Open-O alts","options":["Top serif"],"alternateCharacters":["ɔ","ᵓ","ᶗ","Ɔ","ᴐ"]},{"tag":"cv47","description":"OU alts","options":["Open"],"alternateCharacters":["ȣ","Ȣ","ᴽ","ᴕ"]},{"tag":"cv49","description":"Sm p-hook alt","options":["Right hook"],"alternateCharacters":["ƥ"]},{"tag":"cv55","description":"Cap R-tail alt","options":["Lowercase style"],"alternateCharacters":["Ɽ"]},{"tag":"cv57","description":"Cap T-hook alt","options":["Right Hook"],"alternateCharacters":["Ƭ"]},{"tag":"cv62","description":"V-hook alts","options":["Straight with low hook","Straight with high hook"],"alternateCharacters":["ʋ","ᶹ","Ʋ"]},{"tag":"cv68","description":"Cap Y-hook alt","options":["Left hook"],"alternateCharacters":["Ƴ"]},{"tag":"cv70","description":"Mod apostrophe alt","options":["Large"],"alternateCharacters":["Ꞌ","ꞌ","ʼ"]},{"tag":"cv71","description":"Mod colon alt","options":["Expanded"],"alternateCharacters":["꞉"]},{"tag":"cv75","description":"Viet diacritics","options":["Vietnamese-style"],"alternateCharacters":[]},{"tag":"cv76","description":"Ogonek alt","options":["Straight"],"alternateCharacters":["˛","ą","Ą","ę","Ę","į","Į","ǫ","ǭ","Ǫ","Ǭ","ų","Ų","̨"]},{"tag":"cv77","description":"Non-Eur caron alts","options":["Non-European style"],"alternateCharacters":["ď","ľ","Ľ","ť"]},{"tag":"cv80","description":"Mongol-style Cyr E","options":["Mongolian-style"],"alternateCharacters":["э","Э"]},{"tag":"cv81","description":"Cyr shha alt","options":["Uppercase style"],"alternateCharacters":["һ"]},{"tag":"cv82","description":"Breve Cyr form","options":["Cyrillic-style"],"alternateCharacters":["̆"]},{"tag":"cv90","description":"Chinantec tones","options":["Chinantec-style"],"alternateCharacters":["ˈ","ˊ","ˋ","ˉ"]},{"tag":"cv91","description":"Tone numbers","options":["Numbers"]},{"tag":"cv98","description":"Empty set alt","options":["Zero"],"alternateCharacters":["∅"]},{"tag":"ss01","description":"Style Set 1","options":[],"alternateCharacters":[],"type":16},{"tag":"ss04","description":"Style Set 4","options":[],"alternateCharacters":[],"type":16},{"tag":"ss05","description":"Style Set 5","options":[],"alternateCharacters":[],"type":16},{"tag":"ss06","description":"Style Set 6","options":[],"alternateCharacters":[],"type":16}]


// Example : typescript

import Features, {Feature} from 'opentype.features.js';

const f = async () =>
{
  let features: Feature[] = await Features.getFeaturesFromFile('C:\\Windows\\Fonts\\CharisSIL-R.ttf');
  return this.state.features.map((f: Feature) => f.description);
}

f();


// Example : Using local fonts (Chrome 103+)

  const f = async () =>
  {
    // Assuming - local-font permission already granted.
    //  await navigator.permissions.request({
    //    name: 'local-fonts',
    //  }

    const pickedFonts = await window.queryLocalFonts({
       postscriptNames: ['CharisSIL'],
    });

    const fontData = pickedFonts[0];
    let blob = await fontData.blob();
    let buffer = await blob.arrayBuffer();

    const features = await Features.getFeaturesFromArrayBuffer(buffer.buffer);
    console.log(JSON.stringify(features));
  }

  f();


Feature Module

getFeaturesFromFile(filename : string) Node ONLY

  • filename - supported font file.

returns Feature[]

getFeaturesFromUrl(url : string) Browser or Node

  • url - url to supported font file.

returns Feature[]

getFeaturesFromArrayBuffer(buffer : ArrayBuffer)

  • buffer - binary data of supported font file.

returns Feature[]


interface Feature
{
    tag: string;
    description: string;
    options: string[];
    // unicode characters that this feature modifies.
    alternateCharacters: string[]
    type?: FeatureType;
}

Font Module

getMetaDataFromFile(filename)

  • filename {string} - ttf or woff file.

returns MetaData

getMetaDataFromUrl(url)

  • url {string} - url to ttf or woff file.

returns MetaData


interface MetaData
{
    fontFamily: string;
}

Troubleshooting

  1. Failing to import 'fs' via brotli dependency.

If you are using a bundle builder like webpack it is likely configured to exclude 'fs' polyfills. Install path-browserify (or something equivalent) to provide 'fs'.

The brotli dependency is needed for WOFF2 support.