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.
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.
There are two tools available to convert TTF to WOFF.
sfnt2woff - found here: http://people.mozilla.com/~jkew/woff/ - This is a command line tool that you should be able to call from Ruby
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.
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
© 2022 - 2024 — McMap. All rights reserved.