One of the most powerful font-development tools available today is tx (Type eXchange), which is included in AFDKO (Adobe Font Development Kit for OpenType) and whose sources are also available on GitHub. Despite its two-letter name, this command-line utility is packed with an enormous amount of features and functionality.
Four years ago I wrote a similar article, but it seems like a good time to revisit tx and the useful things that it can do. I still recommend that its “-u” and -h” command-line options be used to explore its vast capabilities.
When working with CID-keyed fonts, my current recommendation is that slashes be used to explicitly specify CIDs (Character IDs) when using the “-g” or “-gx” command-line options, otherwise if CIDs do not equal GIDs in a particular font, the arguments to those command-line options will be interpreted as GIDs (Glyph IDs). At least in the context of CID-keyed fonts, CIDs are more explicit that GIDs, hence the recommendation.
Also when working with CID-keyed fonts, which can have more than one hint dictionary (aka FDArray element), it is possible to specify or exclude glyphs on an FDArray-element basis. The “-fd” and “-fdx” command-line options, respectively, are used for this purpose, and their arguments are one or more FDArray element indices that are separated by commas or expressed as ranges. (It would be advised to first use the fdarray-check.pl tool to determine what glyphs are included in each FDArray element and their indices before using these tx command-line options.)
In addition, the output of tx is easily parsed and repurposed, and can thus serve as the input to other tools. Several of the font-related Perl scripts that I developed use tx output as their input:
fdarray-check.pl
open(FILE,"tx -1 $file |") or die "Cannot open $file input file!\n";
fix-fontbbox.pl
open(AFM,"tx -afm $file |") or die "Cannot open $file input file!\n";
glyph-list.pl
open(FILE,"tx -1 $file |") or die "Cannot open $file input file!\n";
subr-check.pl
open(FILE,"tx -dcf -1 -T gl $file |") or die "Cannot open $file input file!\n";
open(FILE,"tx -dcf -0 -T gl $file |") or die "Cannot open $file input file!\n";
In that 2012 article I mentioned that the “-decid” command-line option can be used to convert a CID-keyed font into a name-keyed one, which can be done to the entire font or a subset by using the “-g,” “-gx,” “-fd,” or “-fdx” command-line options, but what I neglected to mention was that the mergefonts tool and its “-cid” command-line option, which requires a “cidfontinfo” file to be specified as its argument, is necessary to do the reverse. See Adobe Tech Note #5900, AFDKO Version 2.0 Tutorial: mergeFonts, rotateFont & autohint, for more details, or search for “mergefonts” on this blog.
The “-n” command-line option can be used to remove hints when also specifying the “-cff” or “-t1” command-line options, and it can be used by itself or with the “-dump” command-line option (the default mode if none is specified) to suppress hints in the output. The following shows the result when dumping CID+1200 (一) from Kozuka Mincho Pr6N L (Adobe-Japan1-6), without and with the “-n” command-line option:
% tx -6 -g /1200 KozMinPr6N-Light.otf
## glyph[tag] {cid,iFD,LanguageGroup,path}
glyph[1200] {1200,11,1,
1000 width
378 407 hstem
42 959 vstem
50 378 move
904 378 line
934 378 949 384 959 404 curve
847 482 line
788 407 line
42 407 line
endchar}
% tx -n -6 -g /1200 KozMinPr6N-Light.otf
## glyph[tag] {cid,iFD,LanguageGroup,path}
glyph[1200] {1200,11,1,
1000 width
50 378 move
904 378 line
934 378 949 384 959 404 curve
847 482 line
788 407 line
42 407 line
endchar}
So, to sort of repeat what I wrote in the article from four years ago, if you have some spare time and are intrigued by font development, I encourage you to explore the capabilities of the tx tool.