W3C home > Mailing lists > Public > www-font@w3.org > July to September 2009

Font optimizer tool

From: Philip Taylor <excors@gmail.com>
Date: Sat, 1 Aug 2009 17:36:12 +0100
Message-ID: <ea09c0d10908010936s6a74ddc8r863ed13e0c121c8f@mail.gmail.com>
To: www-font@w3.org
Since it's possibly relevant to some past discussions here (around
EOT, compression, etc) and I don't think it's been mentioned before, I
thought it might be useful to point out my code at
http://bitbucket.org/philip/font-optimizer/ (open source, written in
Perl).

The main feature is subsetting TTFs based on a list of characters. It
tries to remove all unnecessary data - in particular, it rewrites the
GSUB and GPOS tables to remove anything that is no longer needed by
the included glyphs. (In one font I've tested, GSUB+GPOS is 130KB and
can be substantially reduced by subsetting, so this seems worth
doing). It's also careful to not remove any glyphs that could be
needed for the input characters (e.g. if you ask for the characters
'i' and 'f', it will look in GSUB and find and include the 'fi' and
'ffi' ligature glyphs, and similarly it should work fine with complex
scripts that rely heavily on substitution).

It can also remove unwanted GSUB/GPOS features, e.g. one particular
1MB font (with lots of optional glyph variants) is reduced to 213KB by
including only ASCII characters, and reduced further to 47KB by
including only the 'kern' and 'liga' features.

There's also some simple uncompressed EOT<->TTF conversion code
(easily tweaked for EOT-Lite), a tool for mangling the 'name' and
'post' tables (making the font invalid so it's harder to use outside
of a web browser; I don't have an opinion on whether this is a good
idea or not), and some other bits and pieces.

It's quite possible there are bugs (the GSUB/GPOS code is somewhat
hairy and full of special cases, and I ought to add some verification
checks on the output), but I've tested with a range of fonts on all
browsers and OSes and it seems to be reasonably robust and hopefully
useful.

-- 
Philip Taylor
excors@gmail.com
Received on Saturday, 1 August 2009 16:45:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 11 June 2011 00:14:03 GMT