TTF (truetype) to WOFF(webfont) conversion using ruby
Asked Answered
M

2

5

How do you convert a .ttf file to .woff file (webfont) using ruby?

We want to allow users to upload a ttf file, convert it and embed the woff file.

Martyr answered 13/7, 2012 at 18:31 Comment(1)
I don't know how to do this, but maybe you can check out how fontsquirrel does it.Hester
K
6

There are two tools available to convert TTF to WOFF.

  1. sfnt2woff - found here: http://people.mozilla.com/~jkew/woff/ - This is a command line tool that you should be able to call from Ruby

  2. sfntly - found here: http://code.google.com/p/sfntly/ - This is a command-line Java suite developed by Google to do a bunch of font tasks, including WOFF generation.

Kamal answered 18/7, 2012 at 12:59 Comment(0)
F
2

For anyone that might be interested today, there is a small Ruby gem that I released today. It is using a Haskell binary that I tested on Ubuntu 12TLS, Debian 7 Wheezy and Mac OSX 10.7.5

https://github.com/dachi-gh/webify_ruby

You get WebifyRuby module by requiring webify_ruby and a Convert class on it which is used primarily.

require 'webify_ruby'
@convert = WebifyRuby::Convert.new(
  'public/fonts/my_font.ttf',
  dir:'my_dir_fonts/converted',
  css: 'my_dir_css/stylesheets',
  link_to: 'http://example.com/my_dir_fonts'
)

Only first parameter is required. without link_to for example, generated stylesheet's url's would be relative from .css file to webfont files.

p.s. Currently it works good with ttf files but you can still use it with otf

Finance answered 11/2, 2014 at 5:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.