Tweeter button

TTF/Ruby, first release!

I am pleased to announce the first release (version 0.1) of TTF/Ruby, under the terms of the GNU GPL.

TTF/Ruby is a pure Ruby library to read and write TrueType fonts.

Tables supported are :

- Cmap *
- Cvt *
- Fpgm *
- Gasp
- Glyf
- Head
- Hhea
- Hmtx
- Kern *
- OS/2
- Post *
- Prep *
- Vhea
- Vmtx

(Tables marked with an * are only partially supported)

API documentation is written directly in the source code and may be generated with the following command-line:

$ rdoc –main “Font::TTF::File”

As you noticed, this release is marked 0.1 so do not expect API compatibility for the next releases.

The tarball also ships some useful tools (and proofs of concept) based on TTF/Ruby.

ttfdump: a command-line tool to extract informations about a font.

ttfsubset: a tool which from a font and an input file generates a subset from this font containing only characters in the input file. Maybe useful to embed a lighter version of a font in a document or in an embedded system.

ttfcairoglyphviewer: renders a selected glyph using Ruby/GTK, Rcairo and TTF/Ruby. It also displays markers for corner points, curve control points, and implicit points.

ttfglyph2svg: prints to stdout a selected glyph in SVG format.

Comments are of course welcome. And there is a large TODO list for the braves ;-)

I would like to thank Evermore Software, China, where I am currently an intern, for giving me the permission to release this project (which started as a prototype for a Java program).

Download: http://www.mblondel.org/files/ttf-ruby/ttf-ruby-0.1.tar.gz


The 愛 japanese Kanji rendered thanks to Ruby/GTK, RCairo and TTF/Ruby (i.e. without FreeType).

3 Responses to “TTF/Ruby, first release!”

  1. Jeremy Green Says:

    This looks great. I’ve been looking for something to be able to read some of the info embedded in a ttf file. I just downloaded your code and I’m hoping it will do the trick. Is there any newer update of this? A git/svn repository perhaps?

    Thanks for sharing.

  2. Jeremy Green Says:

    I’ve gotten this working to read some basic info from ttf files and it works great. Just what I needed.

    However, I’m now starting to see a strange error in my application that goes away if I comment out my require ‘ttf’ line. Here’s the error:

    IOError (Couldn’t load the unicode tables for UTF8Handler (wrong number of arguments (0 for 1)), handler is unusable):

    From the stack trace I get I can’t find anywhere that it goes through your code, but there’s definitely something strange going on. Do you have any ideas what that could be?

    Thanks again,
    Jeremy

  3. Mathieu Says:

    @Jeremy: The project has a page on Rubyforge (http://rubyforge.org/projects/ttf-ruby/) but I haven’t done anything for the project since 2006.

    Regarding your problem, I may have an idea. In the file datatypes.rb, I define helper methods directly in built-in classes such as IO, String and Array. Most of them are new method names, so there’s no conflict. However, you need to check if some of them are not conflicting.

    One I saw is IO#read. Redefining this method was a terrible idea! To fix this, you need to rename it to say _read() and then you need to replace places in the library that use read(). This includes all the read_ methods in datatypes.rb (read_ushort, read_ulong etc).

    If you’re able to fix the bug, I can give you access to the Rubyforge project so that you can commit the fix in SVN if you like.

Leave a Reply