|
| 1 | +pyftsubset -- OpenType font subsetter and optimizer |
| 2 | + |
| 3 | + pyftsubset is an OpenType font subsetter and optimizer, based on fontTools. |
| 4 | + It accepts any TT- or CFF-flavored OpenType (.otf or .ttf) or WOFF (.woff) |
| 5 | + font file. The subsetted glyph set is based on the specified glyphs |
| 6 | + or characters, and specified OpenType layout features. |
| 7 | + |
| 8 | + The tool also performs some size-reducing optimizations, aimed for using |
| 9 | + subset fonts as webfonts. Individual optimizations can be enabled or |
| 10 | + disabled, and are enabled by default when they are safe. |
| 11 | + |
| 12 | +Usage: |
| 13 | + pyftsubset font-file [glyph...] [--option=value]... |
| 14 | + |
| 15 | + At least one glyph or one of --gids, --gids-file, --glyphs, --glyphs-file, |
| 16 | + --text, --text-file, --unicodes, or --unicodes-file, must be specified. |
| 17 | + |
| 18 | +Arguments: |
| 19 | + font-file |
| 20 | + The input font file. |
| 21 | + glyph |
| 22 | + Specify one or more glyph identifiers to include in the subset. Must be |
| 23 | + PS glyph names, or the special string '*' to keep the entire glyph set. |
| 24 | + |
| 25 | +Initial glyph set specification: |
| 26 | + These options populate the initial glyph set. Same option can appear |
| 27 | + multiple times, and the results are accummulated. |
| 28 | + --gids=<NNN>[,<NNN>...] |
| 29 | + Specify comma/whitespace-separated list of glyph IDs or ranges as |
| 30 | + decimal numbers. For example, --gids=10-12,14 adds glyphs with |
| 31 | + numbers 10, 11, 12, and 14. |
| 32 | + --gids-file=<path> |
| 33 | + Like --gids but reads from a file. Anything after a '#' on any line |
| 34 | + is ignored as comments. |
| 35 | + --glyphs=<glyphname>[,<glyphname>...] |
| 36 | + Specify comma/whitespace-separated PS glyph names to add to the subset. |
| 37 | + Note that only PS glyph names are accepted, not gidNNN, U+XXXX, etc |
| 38 | + that are accepted on the command line. The special string '*' wil keep |
| 39 | + the entire glyph set. |
| 40 | + --glyphs-file=<path> |
| 41 | + Like --glyphs but reads from a file. Anything after a '#' on any line |
| 42 | + is ignored as comments. |
| 43 | + --text=<text> |
| 44 | + Specify characters to include in the subset, as UTF-8 string. |
| 45 | + --text-file=<path> |
| 46 | + Like --text but reads from a file. Newline character are not added to |
| 47 | + the subset. |
| 48 | + --unicodes=<XXXX>[,<XXXX>...] |
| 49 | + Specify comma/whitespace-separated list of Unicode codepoints or |
| 50 | + ranges as hex numbers, optionally prefixed with 'U+', 'u', etc. |
| 51 | + For example, --unicodes=41-5a,61-7a adds ASCII letters, so does |
| 52 | + the more verbose --unicodes=U+0041-005A,U+0061-007A. |
| 53 | + The special strings '*' will choose all Unicode characters mapped |
| 54 | + by the font. |
| 55 | + --unicodes-file=<path> |
| 56 | + Like --unicodes, but reads from a file. Anything after a '#' on any |
| 57 | + line in the file is ignored as comments. |
| 58 | + --ignore-missing-glyphs |
| 59 | + Do not fail if some requested glyphs or gids are not available in |
| 60 | + the font. |
| 61 | + --no-ignore-missing-glyphs |
| 62 | + Stop and fail if some requested glyphs or gids are not available |
| 63 | + in the font. [default] |
| 64 | + --ignore-missing-unicodes [default] |
| 65 | + Do not fail if some requested Unicode characters (including those |
| 66 | + indirectly specified using --text or --text-file) are not available |
| 67 | + in the font. |
| 68 | + --no-ignore-missing-unicodes |
| 69 | + Stop and fail if some requested Unicode characters are not available |
| 70 | + in the font. |
| 71 | + Note the default discrepancy between ignoring missing glyphs versus |
| 72 | + unicodes. This is for historical reasons and in the future |
| 73 | + --no-ignore-missing-unicodes might become default. |
| 74 | + |
| 75 | +Other options: |
| 76 | + For the other options listed below, to see the current value of the option, |
| 77 | + pass a value of '?' to it, with or without a '='. |
| 78 | + Examples: |
| 79 | + $ pyftsubset --glyph-names? |
| 80 | + Current setting for 'glyph-names' is: False |
| 81 | + $ ./pyftsubset --name-IDs=? |
| 82 | + Current setting for 'name-IDs' is: [1, 2] |
| 83 | + $ ./pyftsubset --hinting? --no-hinting --hinting? |
| 84 | + Current setting for 'hinting' is: True |
| 85 | + Current setting for 'hinting' is: False |
| 86 | + |
| 87 | +Output options: |
| 88 | + --output-file=<path> |
| 89 | + The output font file. If not specified, the subsetted font |
| 90 | + will be saved in as font-file.subset. |
| 91 | + --flavor=<type> |
| 92 | + Specify flavor of output font file. May be 'woff' or 'woff2'. |
| 93 | + Note that WOFF2 requires the Brotli Python extension, available |
| 94 | + at https://github.com/google/brotli |
| 95 | + --with-zopfli |
| 96 | + Use the Google Zopfli algorithm to compress WOFF. The output is 3-8 % |
| 97 | + smaller than pure zlib, but the compression speed is much slower. |
| 98 | + The Zopfli Python bindings are available at: |
| 99 | + https://github.com/anthrotype/py-zopfli |
| 100 | + |
| 101 | +Glyph set expansion: |
| 102 | + These options control how additional glyphs are added to the subset. |
| 103 | + --notdef-glyph |
| 104 | + Add the '.notdef' glyph to the subset (ie, keep it). [default] |
| 105 | + --no-notdef-glyph |
| 106 | + Drop the '.notdef' glyph unless specified in the glyph set. This |
| 107 | + saves a few bytes, but is not possible for Postscript-flavored |
| 108 | + fonts, as those require '.notdef'. For TrueType-flavored fonts, |
| 109 | + this works fine as long as no unsupported glyphs are requested |
| 110 | + from the font. |
| 111 | + --notdef-outline |
| 112 | + Keep the outline of '.notdef' glyph. The '.notdef' glyph outline is |
| 113 | + used when glyphs not supported by the font are to be shown. It is not |
| 114 | + needed otherwise. |
| 115 | + --no-notdef-outline |
| 116 | + When including a '.notdef' glyph, remove its outline. This saves |
| 117 | + a few bytes. [default] |
| 118 | + --recommended-glyphs |
| 119 | + Add glyphs 0, 1, 2, and 3 to the subset, as recommended for |
| 120 | + TrueType-flavored fonts: '.notdef', 'NULL' or '.null', 'CR', 'space'. |
| 121 | + Some legacy software might require this, but no modern system does. |
| 122 | + --no-recommended-glyphs |
| 123 | + Do not add glyphs 0, 1, 2, and 3 to the subset, unless specified in |
| 124 | + glyph set. [default] |
| 125 | + --layout-features[+|-]=<feature>[,<feature>...] |
| 126 | + Specify (=), add to (+=) or exclude from (-=) the comma-separated |
| 127 | + set of OpenType layout feature tags that will be preserved. |
| 128 | + Glyph variants used by the preserved features are added to the |
| 129 | + specified subset glyph set. By default, 'calt', 'ccmp', 'clig', 'curs', |
| 130 | + 'kern', 'liga', 'locl', 'mark', 'mkmk', 'rclt', 'rlig' and all features |
| 131 | + required for script shaping are preserved. To see the full list, try |
| 132 | + '--layout-features=?'. Use '*' to keep all features. |
| 133 | + Multiple --layout-features options can be provided if necessary. |
| 134 | + Examples: |
| 135 | + --layout-features+=onum,pnum,ss01 |
| 136 | + * Keep the default set of features and 'onum', 'pnum', 'ss01'. |
| 137 | + --layout-features-='mark','mkmk' |
| 138 | + * Keep the default set of features but drop 'mark' and 'mkmk'. |
| 139 | + --layout-features='kern' |
| 140 | + * Only keep the 'kern' feature, drop all others. |
| 141 | + --layout-features='' |
| 142 | + * Drop all features. |
| 143 | + --layout-features='*' |
| 144 | + * Keep all features. |
| 145 | + --layout-features+=aalt --layout-features-=vrt2 |
| 146 | + * Keep default set of features plus 'aalt', but drop 'vrt2'. |
| 147 | + |
| 148 | +Hinting options: |
| 149 | + --hinting |
| 150 | + Keep hinting [default] |
| 151 | + --no-hinting |
| 152 | + Drop glyph-specific hinting and font-wide hinting tables, as well |
| 153 | + as remove hinting-related bits and pieces from other tables (eg. GPOS). |
| 154 | + See --hinting-tables for list of tables that are dropped by default. |
| 155 | + Instructions and hints are stripped from 'glyf' and 'CFF ' tables |
| 156 | + respectively. This produces (sometimes up to 30%) smaller fonts that |
| 157 | + are suitable for extremely high-resolution systems, like high-end |
| 158 | + mobile devices and retina displays. |
| 159 | + XXX Note: Currently there is a known bug in 'CFF ' hint stripping that |
| 160 | + might make the font unusable as a webfont as they will be rejected by |
| 161 | + OpenType Sanitizer used in common browsers. For more information see: |
| 162 | + https://github.com/behdad/fonttools/issues/144 |
| 163 | + The --desubroutinize options works around that bug. |
| 164 | + |
| 165 | +Optimization options: |
| 166 | + --desubroutinize |
| 167 | + Remove CFF use of subroutinizes. Subroutinization is a way to make CFF |
| 168 | + fonts smaller. For small subsets however, desubroutinizing might make |
| 169 | + the font smaller. It has even been reported that desubroutinized CFF |
| 170 | + fonts compress better (produce smaller output) WOFF and WOFF2 fonts. |
| 171 | + Also see note under --no-hinting. |
| 172 | + --no-desubroutinize [default] |
| 173 | + Leave CFF subroutinizes as is, only throw away unused subroutinizes. |
| 174 | + |
| 175 | +Font table options: |
| 176 | + --drop-tables[+|-]=<table>[,<table>...] |
| 177 | + Specify (=), add to (+=) or exclude from (-=) the comma-separated |
| 178 | + set of tables that will be be dropped. |
| 179 | + By default, the following tables are dropped: |
| 180 | + 'BASE', 'JSTF', 'DSIG', 'EBDT', 'EBLC', 'EBSC', 'SVG ', 'PCLT', 'LTSH' |
| 181 | + and Graphite tables: 'Feat', 'Glat', 'Gloc', 'Silf', 'Sill' |
| 182 | + and color tables: 'CBLC', 'CBDT', 'sbix'. |
| 183 | + The tool will attempt to subset the remaining tables. |
| 184 | + Examples: |
| 185 | + --drop-tables-='SVG ' |
| 186 | + * Drop the default set of tables but keep 'SVG '. |
| 187 | + --drop-tables+=GSUB |
| 188 | + * Drop the default set of tables and 'GSUB'. |
| 189 | + --drop-tables=DSIG |
| 190 | + * Only drop the 'DSIG' table, keep all others. |
| 191 | + --drop-tables= |
| 192 | + * Keep all tables. |
| 193 | + --no-subset-tables+=<table>[,<table>...] |
| 194 | + Add to the set of tables that will not be subsetted. |
| 195 | + By default, the following tables are included in this list, as |
| 196 | + they do not need subsetting (ignore the fact that 'loca' is listed |
| 197 | + here): 'gasp', 'head', 'hhea', 'maxp', 'vhea', 'OS/2', 'loca', |
| 198 | + 'name', 'cvt ', 'fpgm', 'prep', 'VMDX', 'DSIG' and 'CPAL'. |
| 199 | + By default, tables that the tool does not know how to subset and are not |
| 200 | + specified here will be dropped from the font, unless --passthrough-tables |
| 201 | + option is passed. |
| 202 | + Example: |
| 203 | + --no-subset-tables+=FFTM |
| 204 | + * Keep 'FFTM' table in the font by preventing subsetting. |
| 205 | + --passthrough-tables |
| 206 | + Do not drop tables that the tool does not know how to subset. |
| 207 | + --no-passthrough-tables |
| 208 | + Tables that the tool does not know how to subset and are not specified |
| 209 | + in --no-subset-tables will be dropped from the font. [default] |
| 210 | + --hinting-tables[-]=<table>[,<table>...] |
| 211 | + Specify (=), add to (+=) or exclude from (-=) the list of font-wide |
| 212 | + hinting tables that will be dropped if --no-hinting is specified, |
| 213 | + Examples: |
| 214 | + --hinting-tables-='VDMX' |
| 215 | + * Drop font-wide hinting tables except 'VDMX'. |
| 216 | + --hinting-tables='' |
| 217 | + * Keep all font-wide hinting tables (but strip hints from glyphs). |
| 218 | + --legacy-kern |
| 219 | + Keep TrueType 'kern' table even when OpenType 'GPOS' is available. |
| 220 | + --no-legacy-kern |
| 221 | + Drop TrueType 'kern' table if OpenType 'GPOS' is available. [default] |
| 222 | + |
| 223 | +Font naming options: |
| 224 | + These options control what is retained in the 'name' table. For numerical |
| 225 | + codes, see: http://www.microsoft.com/typography/otspec/name.htm |
| 226 | + --name-IDs[+|-]=<nameID>[,<nameID>...] |
| 227 | + Specify (=), add to (+=) or exclude from (-=) the set of 'name' table |
| 228 | + entry nameIDs that will be preserved. By default only nameID 1 (Family) |
| 229 | + and nameID 2 (Style) are preserved. Use '*' to keep all entries. |
| 230 | + Examples: |
| 231 | + --name-IDs+=0,4,6 |
| 232 | + * Also keep Copyright, Full name and PostScript name entry. |
| 233 | + --name-IDs='' |
| 234 | + * Drop all 'name' table entries. |
| 235 | + --name-IDs='*' |
| 236 | + * keep all 'name' table entries |
| 237 | + --name-legacy |
| 238 | + Keep legacy (non-Unicode) 'name' table entries (0.x, 1.x etc.). |
| 239 | + XXX Note: This might be needed for some fonts that have no Unicode name |
| 240 | + entires for English. See: https://github.com/behdad/fonttools/issues/146 |
| 241 | + --no-name-legacy |
| 242 | + Drop legacy (non-Unicode) 'name' table entries [default] |
| 243 | + --name-languages[+|-]=<langID>[,<langID>] |
| 244 | + Specify (=), add to (+=) or exclude from (-=) the set of 'name' table |
| 245 | + langIDs that will be preserved. By default only records with langID |
| 246 | + 0x0409 (English) are preserved. Use '*' to keep all langIDs. |
| 247 | + --obfuscate-names |
| 248 | + Make the font unusable as a system font by replacing name IDs 1, 2, 3, 4, |
| 249 | + and 6 with dummy strings (it is still fully functional as webfont). |
| 250 | + |
| 251 | +Glyph naming and encoding options: |
| 252 | + --glyph-names |
| 253 | + Keep PS glyph names in TT-flavored fonts. In general glyph names are |
| 254 | + not needed for correct use of the font. However, some PDF generators |
| 255 | + and PDF viewers might rely on glyph names to extract Unicode text |
| 256 | + from PDF documents. |
| 257 | + --no-glyph-names |
| 258 | + Drop PS glyph names in TT-flavored fonts, by using 'post' table |
| 259 | + version 3.0. [default] |
| 260 | + --legacy-cmap |
| 261 | + Keep the legacy 'cmap' subtables (0.x, 1.x, 4.x etc.). |
| 262 | + --no-legacy-cmap |
| 263 | + Drop the legacy 'cmap' subtables. [default] |
| 264 | + --symbol-cmap |
| 265 | + Keep the 3.0 symbol 'cmap'. |
| 266 | + --no-symbol-cmap |
| 267 | + Drop the 3.0 symbol 'cmap'. [default] |
| 268 | + |
| 269 | +Other font-specific options: |
| 270 | + --recalc-bounds |
| 271 | + Recalculate font bounding boxes. |
| 272 | + --no-recalc-bounds |
| 273 | + Keep original font bounding boxes. This is faster and still safe |
| 274 | + for all practical purposes. [default] |
| 275 | + --recalc-timestamp |
| 276 | + Set font 'modified' timestamp to current time. |
| 277 | + --no-recalc-timestamp |
| 278 | + Do not modify font 'modified' timestamp. [default] |
| 279 | + --canonical-order |
| 280 | + Order tables as recommended in the OpenType standard. This is not |
| 281 | + required by the standard, nor by any known implementation. |
| 282 | + --no-canonical-order |
| 283 | + Keep original order of font tables. This is faster. [default] |
| 284 | + --prune-unicode-ranges |
| 285 | + Update the 'OS/2 ulUnicodeRange*' bits after subsetting. The Unicode |
| 286 | + ranges defined in the OpenType specification v1.7 are intersected with |
| 287 | + the Unicode codepoints specified in the font's Unicode 'cmap' subtables: |
| 288 | + when no overlap is found, the bit will be switched off. However, it will |
| 289 | + *not* be switched on if an intersection is found. [default] |
| 290 | + --no-prune-unicode-ranges |
| 291 | + Don't change the 'OS/2 ulUnicodeRange*' bits. |
| 292 | + --recalc-average-width |
| 293 | + Update the 'OS/2 xAvgCharWidth' field after subsetting. |
| 294 | + --no-recalc-average-width |
| 295 | + Don't change the 'OS/2 xAvgCharWidth' field. [default] |
| 296 | + |
| 297 | +Application options: |
| 298 | + --verbose |
| 299 | + Display verbose information of the subsetting process. |
| 300 | + --timing |
| 301 | + Display detailed timing information of the subsetting process. |
| 302 | + --xml |
| 303 | + Display the TTX XML representation of subsetted font. |
| 304 | + |
| 305 | +Example: |
| 306 | + Produce a subset containing the characters ' !"#$%' without performing |
| 307 | + size-reducing optimizations: |
| 308 | + |
| 309 | + $ pyftsubset font.ttf --unicodes="U+0020-0025" \ |
| 310 | + --layout-features='*' --glyph-names --symbol-cmap --legacy-cmap \ |
| 311 | + --notdef-glyph --notdef-outline --recommended-glyphs \ |
| 312 | + --name-IDs='*' --name-legacy --name-languages='*' |
| 313 | + |
0 commit comments