- A very basic font generation library (currently TrueType only) written in Haxe
- The core of the font generation module used by FontStruct
- Aimed at Haxe (or other) developers who wish to create font generation tools
- Should work with nodejs, js, cpp, c# and java targets. WASM too if you’re lucky.
- Does not and will not do overlap removal!
https://fontstruct.github.io/fonthx/
-
Clone this repo with git to a folder on your machine
git clone git@github.com:FontStruct/fonthx.git
-
Install Haxe, e.g. from https://haxe.org/download/
-
Install Haxe dependencies (anyone installing with haxelib should check this issue first)
haxelib install haxelib.json
-
To compile for node, you will need to have nodejs installed. To compile for java, you will need to have a java JDK installed. Other requirements listed below. If on Windows, you may need to adjust some of the paths below.
Build:
haxe build/examples/pixelfonter/pixelfonter-node.hxml
This will build the pixelfonter example, which will create a TrueType font from a PNG image.
Now run:
node dist/examples/pixelfonter/node/PixelFonterApp.js -i build/examples/pixelfonter/pixel-font-5x5.png -c65-91 -o tmp/pixelfont.ttf
Build:
haxe build/examples/pixelfonter/pixelfonter-java.hxml
Run:
java -jar dist/examples/pixelfonter/java/PixelFonterApp.jar -i build/examples/pixelfonter/pixel-font-5x5.png -c65-91 -o tmp/pixelfont.ttf
Build:
haxe build/examples/pixelfonter/pixelfonter-cpp.hxml
Run:
dist/examples/pixelfonter/cpp/PixelFonterApp -i build/examples/pixelfonter/pixel-font-5x5.png -c65-91 -o tmp/pixelfont.ttf
In order to build and run this example on OSX or Linux you will need to install mono, e.g. via brew install mono
Build:
haxe build/examples/pixelfonter/pixelfonter-cs.hxml
Run:
mono dist/examples/pixelfonter/cs/bin/PixelFonterApp.exe -i build/examples/pixelfonter/pixel-font-5x5.png -c65-91 -o tmp/pixelfont.ttf
haxe build/examples/pixelfonter/pixelfonter-js.hxml
– In order to view this example, you will need to point a web server at dist/examples/pixelfonter/js/index.html
HXCWD=`pwd` haxe build/examples/pixelfonter/pixelfonter-wasm.hxml
– You will need to setup emscripten in order to compile this one. You will also need to point a web server at dist/examples/pixelfonter/wasm/index.html. The easiest way is with emrun e.g.
emrun --no_emrun_detect --browser chrome dist/examples/pixelfonter/wasm/PixelFonterBrowserApp-debug.html
(May well take a while to initialise)
Set up the dev tools (gulp):
npm install gulp-cli -g
npm install
Run specs:
gulp specs
Or, develop and run specs:
gulp specs-watch
Develop using the pixelfonter example app (node target):
gulp pixelfonter-watch
Show all the available gulp tasks:
gulp --tasks
Look at the Pixelfonter example for guidance, in particular PixelFonter
You need to:
- create a font class implementing IFont (optionally extending AbstractFont)
- create a glyph class implementing IContourGlyph (optionally extending AbstractContourGlyph)
- instantiate your font class, add some glyphs to it, then
- get your TrueType bytes using TrueTypeBuilder