A project oriented at converting Hershey's font encoding into a modern ttf format
  • C 93%
  • Python 3.7%
  • C++ 3.2%
Find a file
2023-04-18 12:56:21 -04:00
.vscode periodic upload 2023-04-01 14:47:00 -04:00
svg goodbye node if i need you very much oops 2023-04-18 07:38:15 -04:00
.gitignore goodbye node if i need you very much oops 2023-04-18 07:38:15 -04:00
CoordsToSVG.cpp Working HER2TTF! 2023-04-18 07:09:15 -04:00
HersheyToCoords.cpp Working HER2TTF! 2023-04-18 07:09:15 -04:00
LICENCE Create LICENCE 2022-12-13 07:34:02 -05:00
newstroke_font.h fixed write to file & changed src from .cpp to .h 2022-12-20 16:34:44 -05:00
README.md changes 2023-04-18 12:56:21 -04:00
SVGToTTF.py changes 2023-04-18 12:56:21 -04:00
test.py periodic upload 2023-04-01 14:47:00 -04:00

Hershey's font to TrueTypeFont

Overview

Welcome to my Hershey to TTF conversion project. After many minutes searching, I found absolutely no modern program to programmatically convert Hershey's font to TTF. So I made one.

Installation

(Beware this was only tested on Linux and I could not get it working on windows)

To install just run

git clone https://github.com/10f7c7/hershey2ttf

and install both fontforge and inkscape.

Usage

First you need to download a Hershey font and put it into a header file by default named newstroke_font.h and in an array named const char* const newstroke_font[]. The array must store the hershey encoding in unicode order starting at 0x20. Along with that, you need a bufsize var that contains the length of the array in the header file called const int newstroke_font_bufsize. Each Hershey line should include the left and right max/min before the actualy char because that is how it is read. Before you compile, you might want to adjust some offsets hidden it the code and some other things to make sure that if properly formats. The font that I used and based my offsets off of is NewStroke font [Vovanium].

Then to generate the svg coords run

g++ HersheyToCoords.cpp -o HersheyToCoord 
./HersheyToCoords

From that to generate the svgs

g++ CoordsToSVG.cpp -o CoordsToSVG
./CoordsToSVG

Then to fix the svgs, enter the svg folder and run

bash stroke2path.sh

Now you will have all the fixed svgs in the svg/_output folder in a format that fontforge can read. To generate the ttf, go back to the main dir and run

fontforge -script SVGToTTF.py

and now you should have a ttf file in the main dir!

License

This project is licensed under the MIT License - see the LICENSE file for details

Contributing

please (if you face any issues email me at 10f7c7@gmail.com)