Skip to content

thot-experiment/fontdue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fontdue

A bunch of Hershey fonts melted together into big JSONs to make plotting text dead simple.

Quick start

Run node build_fonts.mjs to generate the compiled font files, or just use the prebuilt ones included here.

There are three base font files:

lite_font.json // contains roman, cyrillic, and greek characters
base_font.json // above + japanese hiragana, katakana, and kanji
ext_font.json  // above + every chinese character I could get my hands on

Each of these is just a big dictionary with the keys being the Unicode codepoints. As an example, here's the letter A:

{
  "65": {
    "codepoint": 65,
    "string": "A",
    "bounding_box": [ 
      [ -0.4286, -0.5714 ], 
      [ 0.4286, 0.4286 ]
    ],
    "strokes": [
      // left side (/)
      [
        [ 0, -0.5714 ], [ -0.381, 0.4286 ] 
      ],
      // right side (\)
      [
        [ 0, -0.5714 ], [ 0.381, 0.4286 ] 
      ], 
      // crossbar (-)
      [
        [ -0.2381, 0.0952 ], [ 0.2381, 0.0952 ]
      ]
    ]
  },
  "66" : { ... },
  ...
}

The strokes are a list of lists of points that make up the individual strokes to draw the character centered around [0,0]. The X-axis is inverted following the convention of the original Hershey fonts, glyphs are normalized to roughly 1u.

Glyph data isn't actually properly normalized in the X-axis, so bounding box data is included for proper kerning. The bounding box is formatted as [[min_x, min_y], [max_x, max_y]], and the X values specifically should be used to determine letter spacing and position.

Additionally, I've included typefaces.json, which is a dictionary of modified typefaces that can be overlaid to get a different font for the basic ASCII characters. To use these, look up your character in the desired typeface dictionary, and if it's not there, fall back to one of the base fonts.

Future Work

I'm releasing this because it's already pretty useful to me, and I don't know when I'll have time to polish it to a higher standard. I welcome bug reports about misplaced characters, bad kerning, etc.

My to-do list right now is:

  • Fix positioning so that all glyphs are actually centered on [0,0].
  • Build a mapping to Unicode for all remaining unrepresented Hershey glyphs.
    • Astrology/math symbols, dingbats, etc.
    • 𝔤𝔬𝔱𝔥𝔦𝔠, 𝒸𝓊𝓇𝓈𝒾𝓋ℯ.
  • Fix scaling so that X-height is consistent and Y-axis placement aligns to the baseline properly.
  • Add support for Hangul.
  • Add additional Cyrillic typeface extensions.

Changelog

  • 1.0 (9-10-25) 61cf893
    • initial commit
  • 1.1 (latest)
    • Added °, ±, א, –, ‖, †, ‡, ←, ↑, →, ↓, ∂, ∃, ∇, ∈, √, ∞, ∠, ∩, ∪, ∴, ≠, ≡, ≤, ≥, ⊂, ⊃, ⊕, ⊥, ⋅, ■, □, ▲, △, ▶, ▼, ▽, ◀, ◇, ○, ●, ◜, ◝, ◞, ◟, ★, ☆, ☉, ☊, ☋, ☌, ☘, ☾, ☿, ♀, ♂, ♃, ♄, ♆, ♇, ♈, ♉, ♊, ♋, ♌, ♍, ♏, ♐, ♑, ♒, ♠, ♡, ♢, ♣, ♭, ♮, ♯, ⚑, ⚒, ⚓, ⚹, ⛢, ✈, ✚, ✡, ✱, ff, fi, fl, ffi, ffl, 𝄞, 𝄡, 𝄢, 🌲, 🌳, 🌴, 🎈, 🔔

License

I release build_fonts.mjs as CC0.

I am not a lawyer, but if you build the fonts yourself, I'm pretty sure you're clear to typeset with them to your heart's content, both personally and commercially. Redistributing the compiled files is maybe not okay because of conflicting licenses? You definitely can't sell them.

I'm including them anyway until someone tells me definitively I shouldn't. All the source files are in raw/, and since those are adapted from a wide variety of sources, I assume they retain whatever license they originally had. All of that is detailed in LICENSES.md.

About

a bunch of hershey fonts melted together

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors