CFF Subroutinization Improvements

Perhaps as a continuation of this article from almost a year ago with a clever image, I’d like to use this opportunity to mention that the AFDKO tx tool is about to get a new and improved CFF subroutinizer.

The tx tool has actually had a CFF subroutinizer for quite some time, since late 2008 or so, which is invoked by using the “+S” command-line option in combination with the “-cff” command-line option, and while it was noticeably faster than the AFDKO makeotf tool’s built-in subroutinizer, there were issues that prevented me from using it, such as recursion depth and the inability to limit the number of local and global subroutines.

Based on my testing thus far—using my trusty 2014 Apple MacBook Pro—the tx tool’s new subroutinizer is over three orders of magnitude faster that the makeotf tool’s built-in one. Yes, over one-thousand times faster! CIDFont resources that once took hours to subroutinize now take mere seconds, and with comparable results both in terms of number of subroutines and reduced CFF size. The 65,535-glyph Source Han Sans CIDFont resources take approximately 30 seconds to become subroutinized CFFs, and the 23,058-glyph Kozuka Gothic Pr6N (小塚ゴシック Pr6N) and Kozuka Mincho Pr6N (小塚明朝 Pr6N) ones take less than 10 seconds each.

Anyway, the next release of AFDKO will include a version of the tx tool that includes this new and improved subroutinizer. Of course, the primary beneficiaries of this new version are those who build OpenType/CFF fonts that include thousands or tens of thousands of glyphs, like me.

In closing, I’d like to draw attention to the open source otfcc project on GitHub, which apparently provides similar CFF subroutinization results, in terms of speed and the end result.

🐡

2 Responses to CFF Subroutinization Improvements

  1. Jimmy says:

    makeotf states in its help that, (it) uses the ‘tx’ tool to convert the input font into the Unix Type 1 format that is required by ‘makeotfexe’. It sounds to me that the subroutinezed cff is not used by makeotf at all and we still have to use the subroutinzer of makeotf. Am I right?
    Thanks.

    • The makeotf tool has its own subroutinizer, and we have not yet updated it to perform like the one in the latest tx tool. What I did for the Source Han Serif was to use the new version of tx to convert the CIDFont resources into subroutinized CFFs, then used the sfntedit tool to splice them into pre-built OpenType/CFF fonts with unsubroutinized ‘CFF ‘ tables. Here are the command lines for the language-specific Japanese OTFs (note the use of the “-nS” and “+S” command-line options):

      % makeotf -f cidfont.ps.OTC.J -omitMacNames -ff features.OTC.J -fi cidfontinfo.OTC.J -mf ../../FontMenuNameDB -r -nS -cs 1 -ch ../../UniSourceHanSerifJP-UTF32-H -ci ../../SourceHanSerif_JP_sequences.txt
      % tx -cff +S cidfont.ps.OTC.J CFF.OTC.J
      % sfntedit -a CFF=CFF.OTC.J SourceHanSerif-$dir.otf
      % sfntedit -f SourceHanSerif-$dir.otf