Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

character-map

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

character-map

A simple command line tool for dumping a UTF-8 string of characters supported by a font file

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

character-map

npm version

A simple command line tool for dumping a UTF-8 string of characters supported by a font file.

Motivation

Unicode fonts are usually too large to be embedded as webfont: subsetting is necessary to get them into a reasonable size, especially for CJK fonts.

But which ones do you subset to ensure your design look consistent? There are 2 major approaches:

  • Dynamic subsetting: using javascript and server-side api to generate a dynamic subset of your font, covering all characters on your webpage.
  • Static subsetting: prepare a list common characters, subset them manually, and use such font only for certain elements on webpage.

I prefer the latter approach, because it's a lot easier to optimize and has less of an impact to performance.

And Apple agrees, their sites for China Mainland, Hong Kong and Japan all use this approach.

But I wonder what characters they pick for their CJK subsets?

character-map to the rescue!

Install

npm install character-map -g

Usage

TrueType, OpenType, WOFF v1 files are supported at the moment.

$ character-map -f my.ttf > map.txt

map.txt will contain a list of characters found in the font. Now you can use this result with a subsetting tool like fontmin.

$ fontmin -t `cat map.txt` other.ttf > subset.ttf

Of course you can verify the result with character-map again.

License

MIT

Acknowledgement

Inspired by CharacterMap and uses opentype.js.

Keywords

FAQs

Package last updated on 27 Oct 2016

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