├── LICENSE.md ├── README.md ├── Resources ├── vmtx.AC17 ├── vmtx.AG15 ├── vmtx.AJ16 ├── vmtx.AK12 └── vmtx.AKR9 ├── cmap-tool.pl ├── fdarray-check.pl ├── fix-fontbbox.pl ├── glyph-list.pl ├── hintcidfont.pl ├── mkicf.pl ├── mklocl.pl ├── mkrange.pl ├── mkvmtx.pl ├── proof.pl ├── setsnap.pl ├── sfnt-collection-check.pl ├── subr-check.pl ├── unicode-list.pl ├── unicode-rows.pl └── unrange.pl /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2014-2019 Adobe. All rights reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Perl Scripts 2 | 3 | This project includes an assortment of command-line Perl scripts that are useful for font development, and run in terminal apps, such as *Terminal* on macOS, and *Command Prompt* on Windows. 4 | 5 | ## Descriptions 6 | 7 | ### `cmap-tool.pl` 8 | 9 | Run `cmap-tool.pl < STDIN > STDOUT` to compile (default) or decompile a CMap resource. The input file must already follow CMap resource syntax, and output is to STDOUT. Compiling means to efficiently use the `begincidchar`/`endcidchar` and `begincidrange`/`endcidrange` operators whereby the latter is used to efficiently represent contiguous code points whose CIDs are also contiguous, and to include in each declared `begincidchar`/`endcidchar` and `begincidrange`/`endcidrange` section no more than 100 records. The mappings are validated against the `begincodespacerange`/`endcodespacerange` section, and are also sorted according to it. When compiling a UTF-32 CMap resource, which is determined by the string "UTF32" being included in the CMap resource's name, corresponding UTF-8 and UTF-16 CMap resources are automatically generated. 10 | 11 | `-e`: This option decompiles the `begincidchar`/`endcidchar` and `begincidrange`/`endcidrange` sections into a single `begincidchar`/`endcidchar` section. If a UTF-32 CMap resource is being decompiled, corresponding UTF-8 and UTF-16 CMap resources are not generated. 12 | 13 | --- 14 | 15 | ### `fdarray-check.pl` 16 | 17 | Run `fdarray-check.pl > STDOUT` to report to STDOUT the FDArray structure of a CID-keyed font—instantiated as a CIDFont resource, CFF resource, or OpenType/CFF font—that shows the ROS (/Registry, /Ordering, and /Supplement) and the name of each FDArray element, along with its index in parentheses, the CIDs and CID ranges that are assigned to it, and the total number of CIDs in parentheses. The CIDs are prefixed with a slash to explicitly indicate CIDs, as opposed to GIDs, which is useful when using the `-g` or `-gx` command-line options for many AFDKO tools, especially when GIDs do not equal CIDs in a particular font. 18 | 19 | The following output example is from [*Ten Mincho Regular*](https://typekit.com/fonts/ten-mincho): 20 | 21 | Detected ROS: Adobe-Identity-0 22 | TenMincho-Regular-Alphabetic (0): /7434-/7444,/7452-/7477,/7484-/7509 (63) 23 | TenMincho-Regular-Dingbats (1): /0,/103,/112-/113,/118,/151,/183,/388-/389,/549,/554-/555,/562-/563,/565-/569,/572,/610-/612,/625-/629,/632,/636-/637,/640-/642,/645-/661,/663-/672,/675-/686,/688-/725,/813-/816,/911,/7391-/7433,/7445-/7451,/7478-/7483,/7510-/7520,/7921-/7944,/8197-/8206,/8236-/8242,/8270-/8279 (234) 24 | TenMincho-Regular-Emoji (2): /8193-/8196,/8280-/8283 (8) 25 | TenMincho-Regular-HWidth (3): /7911-/7920 (10) 26 | TenMincho-Regular-Italic (4): /8284-/9116 (833) 27 | TenMincho-Regular-Kana (5): /726-/812,/817-/910,/912-/915,/8207-/8235 (214) 28 | TenMincho-Regular-Kanji (6): /916-/7325,/7328-/7384,/7521-/7522 (6469) 29 | TenMincho-Regular-Proportional (7): /1-/102,/104-/111,/114-/117,/119-/150,/152-/182,/184-/387,/390-/548,/550-/553,/556-/561,/564,/570-/571,/573-/609,/613-/624,/630-/631,/633-/635,/638-/639,/643-/644,/662,/673-/674,/687,/7326-/7327,/7385-/7390,/7523-/7724,/7945-/7983,/7992-/8192 (1065) 30 | TenMincho-Regular-ProportionalJapanese (8): /7984-/7991 (8) 31 | TenMincho-Regular-Ruby (9): /7725-/7910,/8243-/8269 (213) 32 | 33 | `-g`: This option suppresses the slash prefix for CIDs and CID ranges. 34 | 35 | Tool Dependencies: `tx` 36 | 37 | --- 38 | 39 | ### `fix-fontbbox.pl` 40 | 41 | Run `fix-fontbbox.pl > STDOUT` to check and correct the /FontBBox array of a CIDFont resource. The original and corrected /FontBBox array values are reported to STDERR. 42 | 43 | Tool Dependencies: `tx` 44 | 45 | --- 46 | 47 | ### `glyph-list.pl` 48 | 49 | Run `glyph-list.pl > STDOUT` to list the glyphs in the specified font, which can be a CIDFont resource, a name-keyed Type 1 font (aka PFA), UFO, or an 'sfnt' (TrueType or OpenType) font. Glyphs are listed as CIDs or glyph names, depending on whether the font is CID- or name-keyed. CIDs are prefixed with a slash. 50 | 51 | `-g`: This option lists GIDs instead of CIDs or glyph names. 52 | `-r`: This option outputs the list of CIDs as ranges, or as a single GID range if the `-g` command-line option is also specified. 53 | `-s`: This option outputs a single line that uses a comma as a separator so that it can be repurposed, such as to be used as the argument of the `-g` or `-gx` command-line options that are supported by many AFDKO tools. 54 | 55 | Tool Dependencies: `tx` 56 | 57 | --- 58 | 59 | ### `hintcidfont.pl` 60 | 61 | Run `hintcidfont.pl < STDIN > STDOUT` to apply hinting parameters to a CIDFont resource. A hinting parameter file (a sample hinting parameter file is provided at the end of the script, after the `__END__` declaration) serves as its only argument, and uses it to apply hinting parameters, such as alignment zones and stem values, to the header of a CIDFont resource that is specified as STDIN. A new CIDFont resource is written to STDOUT, which subsequently needs to be processed by the AFDKO `autohint` tool to apply the hinting parameters to the glyphs. 62 | 63 | Special Note: The /FontName of each FDArray element as specified in the CIDFont resource header must be in a form that includes the /CIDFontName plus a unique identifier, such as `Dingbats`. For *Source Han Sans ExtraLight*, the /FontName would be `SourceHanSans-ExtraLight-Dingbats`. The hinting parameter file specifies only the unique identifier, such as `Dingbats` in the example. 64 | 65 | --- 66 | 67 | ### `mkicf.pl` 68 | 69 | Run `mkicf.pl < STDIN > STDOUT` to output to STDOUT a ready-to-use '[BASE](https://docs.microsoft.com/en-us/typography/opentype/spec/base)' table override declaration that can be included in a "features" file that is used as input to the AFDKO `makeotf` tool as an argument of its `-ff` command-line option. A CIDFont resource serves as the only argument, a UTF-32 CMap resource is specified as STDIN, and these are used to calculate appropriate ICF (*Ideographic Character Face*) values. The output may look like the following: 70 | 71 | table BASE { 72 | HorizAxis.BaseTagList icfb icft ideo romn; 73 | HorizAxis.BaseScriptList DFLT ideo -78 838 -120 0, 74 | hani ideo -78 838 -120 0, 75 | kana ideo -78 838 -120 0, 76 | latn romn -78 838 -120 0, 77 | cyrl romn -78 838 -120 0, 78 | grek romn -78 838 -120 0; 79 | 80 | VertAxis.BaseTagList icfb icft ideo romn; 81 | VertAxis.BaseScriptList DFLT ideo 42 958 0 120, 82 | hani ideo 42 958 0 120, 83 | kana ideo 42 958 0 120, 84 | latn romn 42 958 0 120, 85 | cyrl romn 42 958 0 120, 86 | grek romn 42 958 0 120; 87 | } BASE; 88 | 89 | `-k`: This option adds the 'hang' (hangul) script tag to the 'BASE' table override declaration. 90 | 91 | Tool Dependencies: `tx` 92 | 93 | --- 94 | 95 | ### `mklocl.pl` 96 | 97 | Run `mklocl.pl -i -o > STDOUT` to synthesizes a lookup for the '[locl](https://docs.microsoft.com/en-us/typography/opentype/spec/features_ko#a-namelocl-idloclatag-39locl39)' (_Localized Forms_) GSUB feature by specifying two region or language identifiers, whereby the input one is considered the default region or language in terms of which glyphs are encoded by default, and the output one represents a non-default region or language. Only those code points whose CIDs are different for the two specified regions or languages are included in the lookup declaration that is output to STDOUT. The input and output files, whose lines individually map eight-digit UTF-32 character codes to CIDs, and whose names must follow the pattern `utf32-.map`, serve as the arguments of the `-i` and `-o` command-line options, respectively, and the region or language identifiers in their names are used for synthesizing the names of the lookup declarations. The input and output files must also be present in the current working directory. 98 | 99 | This script must be run one time less than the number of supported regions or languages of the font. If a font supports the CN, TW, HK, JP, and KR regions, and if the default region is JP, then this script would be run four times as follows: 100 | 101 | % mklocl.pl -i utf32-jp.map -o utf32-cn.map > STDOUT 102 | % mklocl.pl -i utf32-jp.map -o utf32-tw.map >> STDOUT 103 | % mklocl.pl -i utf32-jp.map -o utf32-hk.map >> STDOUT 104 | % mklocl.pl -i utf32-jp.map -o utf32-kr.map >> STDOUT 105 | 106 | This script was used for [_Source Han Sans_](https://github.com/adobe-fonts/source-han-sans/) and [_Source Han Serif_](https://github.com/adobe-fonts/source-han-serif/) development, and is therefore generally useful for Pan-CJK font development. 107 | 108 | `-i`: This option specifies the file name that includes the UTF-32 to CID mappings of the input (default) region or language whose name must follow the pattern `utf32-.map`. 109 | `-o`: This option specifies the file name that includes the UTF-32 to CID mappings of the output (non-default) region or language whose name must also follow the pattern `utf32-.map`. 110 | 111 | --- 112 | 113 | ### `mkrange.pl` 114 | 115 | Run `mkrange.pl < STDIN > STDOUT` to output a list of integer (default) or hexadecimal values as ranges of contiguous values using a hyphen as a separator. No sorting is performed, and integer values can be prefixed with a slash (the use of a slash prefix explicitly specifies CID values, as opposed to GID values, which is useful for CID-keyed font development). 116 | 117 | `-h`: This option must be specified if the list is of hexadecimal values. 118 | `-s`: This option outputs a single line that uses a comma as a separator so that it can be repurposed, such as to be used as the argument of the `-g` or `-gx` command-line options that are supported by many AFDKO tools. 119 | 120 | --- 121 | 122 | ### `mkvmtx.pl` 123 | 124 | Run `mkvmtx.pl < STDIN > STDOUT` to output to STDOUT a ready-to-use '[vmtx](https://docs.microsoft.com/en-us/typography/opentype/spec/vmtx)' table override declaration that can be included in a "features" file that is used as input to the AFDKO `makeotf` tool as an argument of its `-ff` command-line option. A CIDFont resource serves as the only argument, and STDIN is a list of CIDs and CID ranges that correspond to full-width glyphs that rest on the Western baseline, such as Latin, Greek, Cyrillic, currency symbols, and other characters. The specified CIDs are mechanically centered along the Y-axis by using the top and bottom of the em-box as reference points, along with the top and bottom of their bounding boxes. If a CID does not require adjustment, meaning that its glyph is already centered along the Y-axis, it is omitted from the output. Below is example output that uses CIDs 710 through 720: 125 | 126 | table vmtx { 127 | VertOriginY \710 889; 128 | VertOriginY \711 860; 129 | VertOriginY \712 847; 130 | VertOriginY \713 860; 131 | VertOriginY \714 860; 132 | VertOriginY \715 860; 133 | VertOriginY \716 860; 134 | VertOriginY \717 844; 135 | VertOriginY \719 871; 136 | VertOriginY \720 818; 137 | } vmtx; 138 | 139 | Please see the [Resources](Resources) directory for the following pre-made lists of CIDs and CID ranges for Adobe's public ROSes: *vmtx.AC17* (Adobe-CNS1-7), *vmtx.AG15* (Adobe-GB1-5), *vmtx.AJ16* (Adobe-Japan1-6), *vmtx.AK12* (Adobe-Korea1-2), and *vmtx.AKR9* (Adobe-KR-9). 140 | 141 | Tool Dependencies: `tx` 142 | 143 | --- 144 | 145 | ### `proof.pl` 146 | 147 | Run `proof.pl