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

font-problems

v1.7.1

Published

command-line tools for font formats

Downloads

24

Readme

font-problems

font-problems is a command-line tool for reading and writing console bitmap fonts. These are fonts described by a rectangular pixel matrix, used for small hardware projects like light-up signs or low-resolution terminals.

In particular, it can convert between "standard" formats like PSF and BDF, as well as import and export BMP images (for easy editing), GFX headers, or compact C or rust source files.

Building

Building and running requires node.js.

$ npm install
$ ./bin/font-problems --help

Formats

Supported formats are:

.bmp    grid of glyphs
.psf    portable screen font (used by Linux and PC DOS)
.bdf    bitmap distribution format (popular in the 1990s)
.h      C header ("raw" and GFX)
.rs     Rust header ("raw" only)

BMP files

A font in BMP format is a regular grid of glyphs. You can specify the glyph dimensions manually, though it can usually detect the borders automatically by noticing the empty pixels between letters. The glyphs are assumed to be drawn in a dark color (like black) on a light color (like white), though they can be read from a white-on-black file using --reversed.

Glyphs that aren't as wide as the cell should be pushed up against the left edge. For proportional fonts, font-problems will detect the whitespace on the right edge, and remove it.

Header files

"Raw header file" output format is a C or Rust header file with one constant each for the glyph width (monospace only) and height, and an array of cell data. You can use these to directly include a bitmap font in the source for your project.

For proportional fonts, there's also an array of offsets for indexing. The cell data for character n starts at offset[n] (inclusive) and goes through offset[n + 1] (exclusive).

Each int is a single row or column of pixels, in LSB or MSB order. LSB (the default) means the left or top pixel is in the least-significant bit.

Some "raw" header files can be imported, as well, if you provide the cell width and height on the command line. You may have to massage the file a bit to remove extra lines that confuse the parser.

GFX files

GFX is just a variant of a C header file, described here: https://glenviewsoftware.com/projects/products/adafonteditor/adafruit-gfx-font-format/

GFX fonts may be monospace or proportional, and usually cover just the ASCII range.

PSF files

PSF file format is described here: http://www.win.tue.nl/~aeb/linux/kbd/font-formats-1.html

Each glyph must be the same width and height in a PSF file (monospace), and exactly 256 or 512 characters must be defined. BIOS only supports a glyph width of 8, so only framebuffers can use other widths.

Font-problems will generate a simple unicode mapping table for PSF files, which you can specify with "--map". This is a text file in a particular format, described here: PSF map files

BDF files

BDF file format is documented by Adobe and X11, and is still in popular use because it's really just a text file with a simple format. Font-problems should be able to read and write these files, though it hasn't had as much testing as the other formats.

Sample fonts

Three sample fonts are included, in the fonts/ folder:

  • "Tom Thumb" is from my blog, with some line-drawing and block characters added, for console tools like Midnight Commander. Each cell is 4x6, which I believe is the smallest a bitmap font can be while still having any legibility.

  • "Lola" is a simple proportional font, ranging from 4x8 to 6x8, in ASCII only. It was designed to work on LED matrix displays like this one.

  • "Oranj" is a 6x8 monospace font inspired by the Apple II, with support for most Latin glyphs.

  • "Bizcat" is an 8x16 monospace font suitable for 1980s home computers and 640x480 displays, with support for most Latin glyphs, inspired by wanting to replace the stuffy IBM PC default console font.

All of these fonts are licensed as Creative Commons "share & adapt": http://creativecommons.org/licenses/by/4.0/

License

Apache 2 (open-source) license, included in LICENSE.txt.

Authors

@robey - Robey Pointer [email protected]