Skip to content
forked from FontStruct/fonthx

fonthx changes specific to my pixel font creator tool ( https://yal.cc/pixelfont/ )

License

Notifications You must be signed in to change notification settings

YAL-Forks/fonthx

 
 

Repository files navigation

fonthx: Simple TrueType Generation for Haxe

  • 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!

Example

https://fontstruct.github.io/fonthx/

Installation

  1. Clone this repo with git to a folder on your machine

     git clone git@github.com:FontStruct/fonthx.git
    
  2. Install Haxe, e.g. from https://haxe.org/download/

  3. Install Haxe dependencies (anyone installing with haxelib should check this issue first)

     haxelib install haxelib.json
    
  4. 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.

Try it for node

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

Try the same thing for Java

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

Try the same thing for native C++

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

And C# !?!

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

And in the browser with a simple GUI

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

And even with WASM!

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)

Developing and Testing

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

Build a font generation tool

Look at the Pixelfonter example for guidance, in particular PixelFonter

You need to:

  1. create a font class implementing IFont (optionally extending AbstractFont)
  2. create a glyph class implementing IContourGlyph (optionally extending AbstractContourGlyph)
  3. instantiate your font class, add some glyphs to it, then
  4. get your TrueType bytes using TrueTypeBuilder

About

fonthx changes specific to my pixel font creator tool ( https://yal.cc/pixelfont/ )

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Haxe 96.2%
  • JavaScript 2.3%
  • HTML 1.3%
  • CSS 0.2%