The Hershey Fonts

Looking for some decent free vector fonts that are not truetype / freetype based, I stumbled upon this little gem. I could rephrase what they are about, but I'll just quote the original text file that accompanied the fonts:

USE RESTRICTION:
  This distribution of the Hershey Fonts may be used by anyone for
  any purpose, commercial or otherwise, providing that:
    1. The following acknowledgements must be distributed with
      the font data:
      - The Hershey Fonts were originally created by Dr.
        A. V. Hershey while working at the U. S.
        National Bureau of Standards.
      - The format of the Font data in this distribution
        was originally created by
          James Hurt
          Cognition, Inc.
          900 Technology Park Drive
          Billerica, MA 01821
          (mit-eddie!ci-dandelion!hurt)
    2. The font data in this distribution may be converted into
      any other format *EXCEPT* the format distributed by
      the U.S. NTIS (which organization holds the rights
      to the distribution and use of the font data in that
      particular format). Not that anybody would really
      *want* to use their format... each point is described
      in eight bytes as "xxx yyy:", where xxx and yyy are
      the coordinate values as ASCII numbers.

*PLEASE* be reassured: The legal implications of NTIS' attempt to control
a particular form of the Hershey Fonts *are* troubling. HOWEVER: We have
been endlessly and repeatedly assured by NTIS that they do not care what
we do with our version of the font data, they do not want to know about it,
they understand that we are distributing this information all over the world,
etc etc etc... but because it isn't in their *exact* distribution format, they
just don't care!!! So go ahead and use the data with a clear conscience! (If
you feel bad about it, take a smaller deduction for something on your taxes
next week...)

The Hershey Fonts:
  - are a set of more than 2000 glyph (symbol) descriptions in vector 
    ( <x,y> point-to-point ) format
  - can be grouped as almost 20 'occidental' (english, greek,
    cyrillic) fonts, 3 or more 'oriental' (Kanji, Hiragana,
    and Katakana) fonts, and a few hundred miscellaneous
    symbols (mathematical, musical, cartographic, etc etc)
  - are suitable for typographic quality output on a vector device
    (such as a plotter) when used at an appropriate scale.
  - were digitized by Dr. A. V. Hershey while working for the U.S.
    Government National Bureau of Standards (NBS).
  - are in the public domain, with a few caveats:
    - They are available from NTIS (National Technical Info.
      Service) in a computer-readable from which is *not*
      in the public domain. This format is described in
      a hardcopy publication "Tables of Coordinates for
      Hershey's Repertory of Occidental Type Fonts and
      Graphic Symbols" available from NTIS for less than
      $20 US (phone number +1 703 487 4763).
    - NTIS does not care about and doesn't want to know about
      what happens to Hershey Font data that is not
      distributed in their exact format.
    - This distribution is not in the NTIS format, and thus is
      only subject to the simple restriction described
      at the top of this file.

Hard Copy samples of the Hershey Fonts are best obtained by purchasing the
book described above from NTIS. It contains a sample of all of the Occidental
symbols (but none of the Oriental symbols).

So the fonts are:

  • Free
  • Simple
  • Vector (ie, not bitmap)

They are also limited (no umlauts or anything), but hey, beggars aint choosers.

Now, the problem with the Hershey fonts is that they are in a rather cryptic format. Here's one glyph:

12345 62E_YNZO[O\N RXOYP[P RXPYQZQ[P\N RYNST RRUL[HVNP ROOSKOFJLPRTXVZX[
Z[[Z\X RLZIV RRKOG RKLPQTWVYXZ[Z RMZIU RRLNG RKKQQUWVXXY[Y\X

Thanks to Paul Bourke (is there nothing in computer graphics the man hasn't touched?) I could easily decipher the format. He also provides partial parsed data, but I wanted something that's easy to feed to OpenGL, so I wrote my own decoder. I don't claim that the decoder is perfect, and I'm releasing its sources if someone wants to improve on it.

hershey.cpp

Hershey font to vertex buffer converter, should be relatively portable, but I've only used it in windows.

Along with the decoder, here's shots of each of the font set, the original data and my parsed data. I hope my evening's worth of work is useful for someone. For my part, everything is released under WTFPL, but the original data restriction (as mentioned in above quote) still applies.

The parsed data is in line list format, meaning all glyphs consist of 2d coordinate pairs, and you're just supposed to connect the dots (GL_LINES). Doesn't get much simpler than that.

All of the parsed fonts follow the following format:

/* legalese */

// Glyph SOME_NUMBER
static const int FONT_1_width = [WIDTH_IN_FONT_UNITS];
static const int FONT_1_size = [ARRAY_SIZE];
static const int FONT_1[ARRAY_SIZE] = {
   ...
};

// Glyph SOME_NUMBER
static const int FONT_2_width = [WIDTH_IN_FONT_UNITS];
static const int FONT_2_size = [ARRAY_SIZE];
static const int FONT_2[ARRAY_SIZE] = {
   ...
};

...

// Number of glyphs
const int FONT_count = NUMBER_OF_GLYPHS;
// Height of the font
const char FONT_height = MAX_HEIGHT_OF_GLYPHS;
// Widths of the glyphs
const char FONT_width[NUMBER_OF_GLYPHS] = {FONT_1_width, FONT_2_width, ...
// Real widths of the glyphs (calculated from data)
const char FONT_realwidth[NUMBER_OF_GLYPHS] = {FONT_1_width, FONT_2_width, ...
// Number of ints in each glyph
const int FONT_size[NUMBER_OF_GLYPHS] = {FONT_1_size, FONT_2_size, ...
// Pointers to glyph data
const char *FONT[NUMBER_OF_GLYPHS] = {&FONT_1[0], &FONT_2[0],...

Where FONT (and OTHER_THINGS_IN_CAPS) are replaced with relevant info. So basically all you need to access are the arrays in the end - count, width, size and the actual font data.

For convenience, you can grab everything in a single zip here:

hershey.zip

All the fonts in both formats and thumbnails, with the converter source as well.

In order to balance the load on this page, I've moved font previews and separate downloads to a second page.