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

write-glyphs-file

v1.0.2

Published

Stringify and write a .glyphs font file

Downloads

31

Readme

write-glyphs-file Build Status Coverage Status

Stringify and write a .glyphs font file atomically

Converts a Javascript object into a string for use with the .glyphs font format and writes it to disk. Creates directories for you as needed.

Install

npm install --save write-glyphs-file

Usage

const WRITE_GLYPHS = require('write-glyphs-file')

WRITE_GLYPHS('my-font.glyphs', { familyName: 'My Font' /* ... */ })
	.then(() => {
		console.log('done writing')
	})

API

writeGlyphsFile(filepath, data, [options])

Returns a Promise that resolves once the file has finished writing.

writeGlyphsFile.sync(filepath, data, [options])

Write the file synchronously, blocking further execution until it’s done.

const WRITE_GLYPHS = require('write-glyphs-file')

WRITE_GLYPHS.sync('my-font.glyphs', { familyName: 'My Font' /* ... */ })
console.log('done writing')

options

Type: Object

mode

Type: number Default: 0o666

Mode used when writing the file.

Implementation Details

The Glyphs font editing software saves fonts to files using the .glyphs extension. The format closely follows the NeXTSTEP “plain text” property list format, an old format that vaguely resembles JSON. For example:

{ "array" = ( "string", "string" ); }

However, the formatting of a .glyphs file is a little more specific than the generic NeXTSTEP specfication. For example, a .glyphs file will contain a familyName key with the name of your font family as its value:

{ familyName = "My Font"; }

Which is equivalent to this Javascript object:

{ familyName: "My Font" }

A standard way of safely stringifying this object to a valid NeXTSTEP property list would be to wrap all keys in quotes:

{ "familyName" = "My Font"; }

However, Glyphs will not find your familyName if its key is quoted like that. To try to output files as close as possible to the original .glyphs files, this package will not quote strings as long as they only contain “word” characters (A-Za-z0-9_).

Similarly, a one-line file can be a valid NeXTSTEP property list as the parsing relies on commas, semicolons, parentheses, and braces. However, Glyphs’ parser seems to break down if a .glyphs file doesn’t also use new lines to break up the text.

write-glyphs-file will write the following as opposed to compressing it on one line:

{
familyName = "My Font";
}

See also

  • load-nextstep-plist - Read and parse NeXTSTEP property list files, including the .glyphs font format

Acknowledgements

Stringification is modelled on Chee’s nextstep-plist.

The file writing logic is modelled on Sindre Sorhus’s write-json-file.

License

This software is free to use, modify, and redistribute under a GNU General Public License.