a bunch of hershey fonts melted together into big JSONs to make plotting text dead simple
run node build_fonts.mjs to generate the compiled font files or just use the prebuilt ones in 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 oneach of these is just a big dictionary with the keys being the unicode codepoint. 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] with the X axis being 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 in [[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 you'd look up your character in the desired typeface dictionary, and if it's not there fall back to one of the base fonts
i'm releasing this because it's already pretty useful to me and i don't know when I'l have time to polish it to a higher standard, i welcome bug reports about misplaced characters, bad kerning etc
my todo 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 baseline properly
- add support for hangul
- add additional cyrillic typeface extensions
build_fonts.mjs I release 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 hearts content both personally and commercially but 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 think they just keep whatever license they originally had, all of that is detailed in LICENSES.md