Search code examples
fontsthree.jstruetype

How to convert TTF font for use in three.js


I am looking for a library that will convert a ttf or otf font to a js font.

I am aware of this converter tool http://typeface.neocracy.org/fonts.html

However I would like to know how this site is making the conversion. So I can implement the conversions of the font files myself.

Ideally I am looking for a JS or PHP library to accomplish this.


Solution

  • The converter from typeface.js uses server-side perl scripts and the sources are on Launchpad.

    Here is an extract from its README:

     use TypefaceJS;
    
     my $typeface = TypefaceJS::new->( input_filename => "truetype_font.ttf",
     unicode_range_names => ['Basic Latin', 'Latin-1 Supplement'], );
    
     $typeface->write_file( output_filename => 'font.typeface.js' );