Options

TTF Diet, by Karsten Lücke and Adam Twardoch, reduces Latin TTF fonts by ~10%

The tool applies a 'diet' to a .ttf font. The diet consists of two steps:

- It 'blanks' all glyphs that, in the 'cmap' table, represent precomposed Unicode characters (such as U+00E1, LATIN SMALL LETTER A WITH ACUTE), i.e. it removes all contours and components for those glyphs from the 'glyf' table (note: the tool cannot process the 'CFF' table).

- It adds a 'GSUB' lookup that substitutes every glyph that represents a precomposed Unicode character with a sequence of glyphs that represent the Unicode canonical decomposition of that precomposed character, and adds the lookup to the 'ccmp' feature.

The typical size reduction of a multilingual font is 5–10%.

- https://github.com/twardoch/ttfdiet

The processed fonts don't work with many OT processors, but they should :)

Comments

  • Options
    The processed fonts don't work with many OT processors, but they should :)
    If they did wouldn’t we be able to just build fonts with mark positioning and not put all the precomposed characters in fonts to begin with?
  • Options
    did you do some tests where these fonts do work? And did you find rendered where it didn't?
  • Options
    Kent LewKent Lew Posts: 905
    edited December 2014
    I’m curious: How does it then handle any subsequent kerning lookups in the GPOS that applied to the now-replaced precomposed glyphs? Or does it, yet?

    Is it able to replace a standard pair with a contextual lookup? For example, replacing
        pos T agrave -70;
    with
        pos T' -70 a gravecmb;
    Or, actually, since there is likely already a T a pair and the contextual lookup will be cumulative, does it know to calculate the difference?:
        pos T a -110;
    pos T' 40 a gravecmb;
    [Obviously, at the level of TTF, the script is working directly with the compiled tables, not .fea syntax as I have represented.]

  • Options
    Question: What happens to kerning exceptions like eg. Tä &c in dieted fonts?

    Karsten's Answer: Kerning pairs that involve a glyph whose outline got deleted will be removed too. Caveat: Only PairPos Format 1 subtables (those that usually hold "exception kerning") are processed by the tool while PairPos Format 2 subtables ("class kerning") are not, yet.
  • Options
    Adam TwardochAdam Twardoch Posts: 507
    edited December 2014
    I've just added some clarification about the kerning (and a few other issues) to the README on https://github.com/twardoch/ttfdiet
  • Options
    We'd appreciate if anyone tests the undieted vs. dieted fonts (even the fonts from the examples folder) in a variety of environments and posts the results here. I'll incorporate the results into the tool's README.

    Environments may include:

    * Adobe InDesign CC 2014, Paragraph Composer
    * Adobe InDesign CC 2014, World-Ready Paragraph Composer
    * Adobe Illustrator CC 2014, Paragraph Composer
    * Adobe Illustrator CC 2014, World-Ready Paragraph Composer
    * Adobe Photoshop CC 2014
    * TextEdit, Pages, Keynote on Mac OS X 10.10
    * Notepad, WordPad on Windows 8.1
    * Google Chrome
    * Mozilla Firefox
    * Internet Explorer 11 on Windows 8.1
    * Safari on Mac OS X 10.10
    * Microsoft Word, PowerPoint 2013 on Windows 8.1
    * Microsoft Word, PowerPoint 2011 on Mac OS X 10.10
    * CorelDRAW! X6 on Windows 8.1
    * Affinity Designer on Mac OS X 10.10
    * OpenOffice, LibreOffice
    * Mellel
    * QuarkXPress

    as well as these apps on older OSes, older versions of the above apps, and other apps that use OpenType Layout.
  • Options
    OK, well, I've done some testing myself and published the results at the end of the README on https://github.com/twardoch/ttfdiet
  • Options
    John HudsonJohn Hudson Posts: 2,977
    Adam, since you've set up the test, can you also run it for fonts that contain only the decomposed characters and do not have the blank mapped glyphs for the precomposed characters? I'd like to see how much current advantage is gained with your diet hack vs. building smarter fonts.
  • Options
    Kent LewKent Lew Posts: 905
    that contain only the decomposed characters and do not have the blank mapped glyphs for the precomposed characters?

    John — I don’t quite understand this. Without leaving the blank mapped glyphs as targets, how can you have the {ccmp}? Won’t the tests just yield .notdefs?

    Or are you asking Adam to run tests to see which (if any) applications attempt to apply  Unicode normalization to the input when precomposed glyphs are absent from the font? 

  • Options
    edited January 2015
    Interesting. + In case someone did not know: Just TTX:ing the font (TTF > TTX > TTF) reduce the file size with 15% on a manually hinted webfont.
  • Options
    I recommend that this tool be used as part of the renewed pressure on Adobe, Microsoft and others to better support OpenType. 
Sign In or Register to comment.