t1tidy - tidy up your type 1 font programs May 1993 version Purpose This program was intended and is capable to reduce the size of many amateur font programs (type 1 fonts) significantly, i.e. by 20-35% (this also applies to many of the clone fonts bundled with Coreldraw and some of those bundled with Micrografx Designer). Of course, no loss of information will occur. The reduction is achieved by 3 different operations: - Find common subpaths in the character descriptions and put them into subroutines (Subrs entry). Apparently, many font generating programs (e.g. FontMonger) are not clever enough to do this. - If an explicit encoding vector is present in a text font, this should be replaced by the simple entry /Encoding StandardEncoding def The explicit vector is stupid anyway since automatic adjustment to the operating system specific (or otherwise environment specific) encoding scheme will often be disabled. And it's also a waste of storage (more than 4 KB!). - Many amateur fonts around were apparently generated by font software (e.g. ZSoft's SoftType) which is so stupid as to include a large bunch of PostScript code for hint replacement and curve flexing although the font does not use these features at all. t1tidy detects if no use of that code occurs and in that case removes that junk code (5 KB, after all!). Further functions of t1tidy are: - Insert dummy zero-move commands where subpaths start with a drawing command. Their omission, although alright according to the type 1 format specifications, appeared to cause display problems with ATM 1.3 which would display inappropriate junk lines (I have not checked this with ATM 2). - t1tidy can attempt to generate some missing characters from others, namely quote marks. - t1tidy can generate composite characters from their base characters and accents if external composition information if given. This can either be supplied by the CC lines of an afm file or can be generated separately by a PostScript script attached to this package, 'compose.bat' and 'compose.ps'. - Empty character descriptions are removed to make them free for automatically generated characters (and to save some space). Some font generation programs seem to store entries for all character names of their favourite encoding even if the designer of the font was too lazy to design that character. - If an afm file is present, it is copied along with the transformation. All metrics entries are checked and corrected if necessary and missing entries and entries for generated characters are supplemented. - Optionally, t1tidy can also expand (instead of factor out) existing Subrs into full character path descriptions. This is useful to take characters from one font into another. Why is there a need to reduce storage at all? Smaller font files do not only reduce the amount of disk storage used which might be of less interest to some people. They also reduce virtual memory use in the PostScript printer which may already be less available. And, of course, downloading time (there are still a lot of PostScript printers connected by serial lines). Liability None. Don't delete the original font file before you have verified that the tidied font works. Copyright 1. Private users without commercial advantage from using fonts may apply t1tidy freely to any font file not created by themselves (cf. 3.) for private, non-commercial use. 2. Commercial users send 15 ECU / 20 US$ to me. Remember that you may save downloading time with t1tidy and time is money! 3. Font designers who lack appropriate font software and wish to use t1tidy to keep their font small or to generate additional characters, are permitted to use it with the following restrictions: - I request that a free copy of your font is granted and sent to me. - If you make a text font based on the Latin alphabet (i.e. not a Chinese, Cyrillic, etc. or an ornamental font), I only allow to use t1tidy on it if character set completeness is respected: Your font should contain all characters of AdobeStandardEncoding, and also all commonly used combinations of letters and accent marks as included, e.g., in the Windows 3.1 character set (a superset of ISO-Latin-1) or the Macintosh character set. If you only make a stub font without these characters, using t1tidy on it is a violation of my copyright. Sorry, but I'm really fed up with all these useless junk fonts I've wasted downloading time for. Requirements MSDOS, (Turbo-Pascal to compile). Type 1 font disassembling and assembling software. I recommend t1utils which is freely available on ftp servers. A future version of t1tidy may perform this step itself. Syntax t1tidy [options] infont.ps outfont.ps or, with batch file: t1t [options] infont outfont t1t [options] infont outdir The font name(s) for t1t must be given without any suffix. (The primitive MSDOS command interpreter does not allow for such things as stripping suffixes for more comfortable command processing.) Also unfortunately, the stupid MSDOS command interpreter does not allow us to recognize if the first argument start with a '-', so we can only have a small number of specific option strings here. Option strings recognized by t1t are: -g, -e, -ge, -eg, -s, +c, +x . Within t1t, add recognizable option sets to your needs or the -v option according to your taste. For convenience, the second argument to the scripts can be the name of a directory which the tidied fonts are then collected in. This simplifies working on a bunch of fonts. In t1t, modify the paths of t1tidy.exe and the type 1 font assembly/disassembly programs according to your installation. Actions The transformation will be performed on the (disassembled type 1) font file infont.ps and written to outfont.ps. If infont.afm is present, it will be copied to outfont.afm and modifications accordingly applied, including renumbering of the entries if the -e option is given. Incomplete afm files will be completed with respect to some basic entries (e.g. CapHeight which is needed by Adobe's makepfm) and adding missing bounding boxes from default assumptions (also required for some metrics transformation software). Options Except for +c, all options are selected by default! Options can be selected with + or deselected with -. s split Perform path splitting and subroutine extraction. t1tidy cannot currently generate new Subrs for fonts which do not already have a Subrs entry. In that case, insert one manually in the disassembled version of the font: /Subrs 4 array dup 0 {} put dup 1 {} put dup 2 {} put dup 3 {} put def into the font directory, typically called /FontDirectory, typically before the lines end NP dup /CharString ... dict dup begin (details may vary). The size of the font directory might have to be increased by 1. This option should be disabled, e.g., if some aspect of the font is too large to handle it but another function of t1tidy (e.g. character generation) shall be applied. e encoding Replace encoding vector with StandardEncoding. This option should and should only be deselected for use on ornamental or foreign letter-type fonts if they use their own character naming scheme. o OtherSubrs Enable removal of OtherSubrs unless they are used in the font. This saves 5 KB of wasted storage in many amateur fonts (e.g. generated by SoftType). g generate Try to generate missing quote marks from others. The following generations are implemented: halfchar ('/quotedbl', '/quotesingle'); downchar ('/quotedblright', '/quotedblbase'); halfchar ('/quotedblbase', '/quotesinglbase'); halfchar ('/quotedblleft', '/quoteleft'); halfchar ('/quotedblright', '/quoteright'); downchar ('/quoteright', '/quotesinglbase'); halfchar ('/guillemotleft', '/guilsinglleft'); halfchar ('/guillemotright', '/guilsinglright'); copychar ('/less', '/guilsinglleft'); copychar ('/greater', '/guilsinglright'); either copychar ('/endash', '/minus') or copychar ('/hyphen', '/minus'); copychar ('/slash', '/fraction'); copychar ('/bar', '/brokenbar'); copychar ('/asciitilde', '/tilde'); copychar ('/asciicircum', '/circumflex'); copychar ('/degree', '/ring'); halfchar generates the second from the first by taking the first closed part of its path description. downchar generates the second from the first by setting its vertical offset to zero. Hints are adjusted. copychar copies the first into the second. Every generation is only performed if the affected character does not already exist. Deselect this option if the font is not a Latin letter font (i.e., e.g., Greek, or ornaments) but contains its foreign letters or symbols under Latin letter names (as is often the case). x expand Reexpands existing Subrs into full character path descriptions. This is useful to take characters from one font into another. a afmcheck Enables checking of afm entries for all characters. c corelfix Apply 3 fixes for problems encountered with wfn font files (those transformed with WFNBOSS from CorelDraw 2 fonts - I don't know if the same problems occur with CorelDraw 3 fonts). Exchange wrongly encoded characters, derive some missing characters from others (i.e., -g is implied), solve the UniqueID problem by assigning increasing UniqueID values using a configuration file uniqueid.int. As long as you tidy wfn font files, you should keep the file uniqueid.int (generated on first use) always in the working directory. (The zero-move command insertion also primarily serves wfn fonts, but not exclusively.) t ttfix Rename characters from PostScript-embedded fonts which Windows generated from TrueType fonts (manual adjustments still to be done). v verbose Tell user about every major step. Procedure: 1. Display or print a sample of the font to be tidied to determine if any characters are misplaced (i.e. are not registered with their correct name) or any junk characters take positions which need to be used for automatic character generation. You may use my "pcs.bat" and "pcs.ps" for character set display, or "pfbshow.bat" and "pfshow.ps" for style and character samples. Manually change the names of misplaced characters or delete the descriptions of useless characters. Some fonts contain a character showing a copyright notice. This tends to comsume up to 5KB of memory due to an extraordinarily long character path which also exceeds t1tidy's path length limit. 2. Apply t1tidy to perform path length reduction and generation of characters, e.g. single from double quotemarks, circumflex from asciicircum (sometimes not nice) etc. If important accent marks are still missing: if the font conatains not all but some accented characters, try to extract accents from characters by manually removing parts of their character description (after copying the path and giving the copy the right name), else design new accent marks or take them from another font fitting to the font style. 3. If accented character are to be generated, generate an .afm or .cc file containing appropriate "CC ..." entries for them. You can use my "compose.bat" and "compose.ps" for this task. Then apply t1tidy again to incorporate the compositions into the font. Precautions to be observed: 1. t1tidy should not be applied to professional quality fonts. It should be expected from professional fonts anyway that optimizations like those performed by t1tidy should not be necessary. (However, this need not always be the case. I have seen commercially sold text fonts which included explicit encoding vectors and few Subrs.) 2. t1tidy will crash and leave incomplete output on fonts which are too large or contain too large character paths. This is basically due to the old 640KB restriction and will probably change when compiled with Turbo-Pascal 7 (I don't have it yet). For the path length restriction, also constant maxpathlen in pathunit.pas and some code would have to be changed because I did not implement path description storage with a dynamic data structure since this would have caused even more memory problems in the 640KB limited version. Future improvements - Repeated applications of t1tidy would currently not find common subpaths between already existing Subrs and newly extracted subpaths. This should really be smoothed. Moreover, more than a single level of common subpath extraction might be desirable. - An initial Subrs entry should be generated automatically if no one is present. - When trying to generate a half or doubled character description, subpath determination should consider Subrs called. Also stems should be adjusted. - More automization on extracting embedded fonts generated from printing TrueType fonts might be useful. - More information in the afm file should be checked and corrected, like FontName, EncodingScheme, etc. Availability by ftp from ftp.fu-berlin.de: pub/postscript/t1tidy.zip Author Thomas Wolff Hebbelstra$e 3 D-10585 Berlin wolff@inf.fu-berlin.de