ftcli fix
Fix font errors.
Usage
ftcli fix [OPTIONS] COMMAND [ARGS]...
duplicate-components
Remove duplicate components.
fontbakery check id: com.google.fonts/check/glyf_non_transformed_duplicate_components
Rationale:
There have been cases in which fonts had faulty double quote marks, with each of them containing two single quote marks as components with the same x, y coordinates which makes them visually look like single quote marks.
This check ensures that glyphs do not contain duplicate components which have the same x, y coordinates.
Fixing procedure:
Remove duplicate components which have the same x,y coordinates.
Usage
ftcli fix duplicate-components [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
empty-notdef
Fixes the empty .notdef glyph by drawing a simple rectangle.
Glyph 0 must be assigned to a .notdef glyph. The .notdef glyph is very important for providing the user feedback that a glyph is not found in the font. This glyph should not be left without an outline as the user will only see what looks like a space if a glyph is missing and not be aware of the active font’s limitation.
Usage
ftcli fix empty-notdef [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
fs-selection
Fixes the style flags (Regular, Italic, Bold) in the OS/2.fsSelection field and in the
head.macStyle field.
fontbakery check id: com.google.fonts/check/fsselection>
The OS/2.fsSelection field is a bit field used to specify the stylistic qualities of the
font - in particular, it specifies to some operating systems whether the font is italic (bit 0),
bold (bit 5) or regular (bit 6).
This fix verifies that the fsSelection field is set correctly for the font style. If the
font is not bold or italic, the regular bit is set. If the font is bold or italic, the regular
bit is cleared.
Usage
ftcli fix fs-selection [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
integer-ppem-if-hinted
Sets the head.flags bit 3 to force integer ppem for hinted fonts.
fontbakery check id: com.google.fonts/check/integer_ppem_if_hinted
Rationale:
Hinted fonts must have head table flag bit 3 set.
Per https://docs.microsoft.com/en-us/typography/opentype/spec/head, bit 3 of Head::flags decides whether PPEM should be rounded. This bit should always be set for hinted fonts.
Note: Bit 3 = Force ppem to integer values for all internal scaler math;
Fixing procedure:
Check if the font is hinted by looking for the presence of the
fpgmtable.Set the
head.flagsbit 3 to force integer ppem for hinted fonts.
Usage
ftcli fix integer-ppem-if-hinted [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
italic-angle
Fixes the italic angle and related attributes in the font.
The italic angle is recalculated as first step.
The italic and oblique bits are then set based on the calculated italic angle and the provided mode.
Usage
ftcli fix italic-angle [OPTIONS] INPUT_PATH
Options
- --min-slant <min_slant>
The minimum slant to consider a font italic.
- Default:
2.0
- --mode <mode>
Which attributes to set when the calculated italic angle is not 0.
1: Only set the italic bits.2: Only set the oblique bit.3: Set the italic and oblique bits.- Default:
1
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
kern-table
Fix the kern table by removing pairs that contain unmapped glyphs.
fontbakery check id: com.google.fonts/check/kern_table
Rationale:
Even though all fonts should have their kerning implemented in the GPOS table, there may
be kerning info at the kern table as well.
Some applications such as MS PowerPoint require kerning info on the kern table. More
specifically, they require a format 0 kern subtable from a kern table version 0 with only
glyphs defined in the cmap table, which is the only one that Windows understands (and
which is also the simplest and more limited of all the kern subtables).
Google Fonts ingests fonts made for download and use on desktops, and does all web font optimizations in the serving pipeline (using libre libraries that anyone can replicate.)
Ideally, TTFs intended for desktop users (and thus the ones intended for Google Fonts) should
have both kern and GPOS tables.
Given all of the above, we currently treat kerning on a v0 kern table as a good-to-have (
but optional) feature.
Fixing procedure:
Remove glyphs that are not defined in the
cmaptable from thekerntable.
Usage
ftcli fix kern-table [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
legacy-accents
Check that legacy accents aren’t used in composite glyphs.
fontbakery check id: com.google.fonts/check/legacy_accents
Rationale:
Legacy accents should not have anchors and should have positive width. They are often used independently of a letter, either as a placeholder for an expected combined mark+letter combination in macOS, or separately. For instance, U+00B4 (ACUTE ACCENT) is often mistakenly used as an apostrophe, U+0060 (GRAVE ACCENT) is used in Markdown to notify code blocks, and ^ is used as an exponential operator in maths.
More info: https://github.com/googlefonts/fontbakery/issues/4310
Usage
ftcli fix legacy-accents [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
monospace
Fix metadata in monospaced fonts
fontbakery check id: com.google.fonts/check/monospace
Rationale:
- There are various metadata in the OpenType spec to specify if a font is monospaced or not. If
the font is not truly monospaced, then no monospaced metadata should be set (as sometimes they mistakenly are…)
Requirements for monospace fonts:
post.isFixedPitch- “Set to 0 if the font is proportionally spaced, non-zero if the fontis not proportionally paced (monospaced)” (https://www.microsoft.com/typography/otspec/post.htm)
hhea.advanceWidthMaxmust be correct, meaning no glyph’s width value is greater.
OS/2.panose.bProportionmust be set to 9 (monospace) on latin text fonts.OS/2.panose.bSpacingmust be set to 3 (monospace) on latin handwritten or latin symbolfonts.
- Spec says: “The PANOSE definition contains ten digits each of which currently describes up to
sixteen variations. Windows uses
bFamilyType,bSerifStyleandbProportionin the font mapper to determine family type. It also usesbProportionto determine if the font is monospaced.” (https://www.microsoft.com/typography/otspec/os2.htm#pan, https://monotypecom-test.monotype.de/services/pan2)
OS/2.xAvgCharWidthmust be set accurately. “OS/2.xAvgCharWidth is used when renderingmonospaced fonts, at least by Windows GDI” (https://typedrawers.com/discussion/comment/15397/#Comment_15397)
CFF.cff.TopDictIndex[0].isFixedPitchmust be set toTruefor CFF fonts.
Fixing procedure:
If the font is monospaced, then:
Set
post.isFixedPitchtoTrue(1)Correct the
hhea.advanceWidthMaxvalue- Set the
OS/2.panose.bProportionvalue to 9 or 3, according to the OS/2.panose.bFamilyTypevalue
- Set the
Set
CFF.cff.TopDictIndex[0].isFixedPitchtoTruefor CFF fonts
Usage
ftcli fix monospace [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
nbsp-missing
Fixes the missing non-breaking space glyph by double mapping the space glyph.
fontbakery check id: com.google.fonts/check/whitespace_glyphs
Rationale:
Font contains glyphs for whitespace characters?
Fixing procedure:
Add a glyph for the missing
nbspacecharacter by double mapping thespacecharacter
Usage
ftcli fix nbsp-missing [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
nbsp-width
Fixes the width of the non-breaking space glyph to be the same as the space glyph.
fontbakery check id: com.google.fonts/check/whitespace_widths
Rationale:
If the space and nbspace glyphs have different widths, then Google Workspace has
problems with the font.
The nbspace is used to replace the space character in multiple situations in documents;
such as the space before punctuation in languages that do that. It avoids the punctuation to
be separated from the last word and go to next line.
This is automatic substitution by the text editors, not by fonts. It’s also used by designers
in text composition practice to create nicely shaped paragraphs. If the space and the
nbspace are not the same width, it breaks the text composition of documents.
Fixing procedure:
- Check if
nbspaceand space glyphs have the same width. If not, correctnbspace width to match the
spacewidth.
- Check if
Usage
ftcli fix nbsp-width [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
transformed-components
Decompose glyphs with transformed components.
fontbakery check id: com.google.fonts/check/transformed_components
Rationale:
Some families have glyphs which have been constructed by using transformed components e.g. the ‘u’ being constructed from a flipped ‘n’.
From a designers point of view, this sounds like a win (less work). However, such approaches can lead to rasterization issues, such as having the ‘u’ not sitting on the baseline at certain sizes after running the font through ttfautohint.
Other issues are outlines that end up reversed when only one dimension is flipped while the other isn’t.
As of July 2019, Marc Foley observed that ttfautohint assigns cvt values to transformed glyphs as if they are not transformed and the result is they render very badly, and that vttLib does not support flipped components.
When building the font with fontmake, the problem can be fixed by adding this to the command line:
--filter DecomposeTransformedComponentsFilter
Fixing procedure:
Decompose composite glyphs that have transformed components.
Usage
ftcli fix transformed-components [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
unreachable-glyphs
Remove unreachable glyphs from the font.
fontbakery check id: com.google.fonts/check/unreachable_glyphs
Rationale:
Glyphs are either accessible directly through Unicode codepoints or through substitution rules.
In Color Fonts, glyphs are also referenced by the COLR table. And mathematical fonts also reference glyphs via the MATH table.
Any glyphs not accessible by these means are redundant and serve only to increase the font’s file size.
More info: https://github.com/fonttools/fontbakery/issues/3160
Fixing procedure:
Remove glyphs that are not reachable by subsetting the font.
Usage
ftcli fix unreachable-glyphs [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument
vertical-metrics
Ensures that the vertical metrics are consistent across the font family.
This task calculates the minimum y_min and maximum y_max values from the head table of all fonts in the family and sets the vertical metrics accordingly.
Usage
ftcli fix vertical-metrics [OPTIONS] INPUT_PATH
Options
- -r, --recursive
Recursively find font files both in input directory and its subdirectories.
Only applicable if
INPUT_PATHis a directory.
- -out, --output-dir <output_dir>
The directory where output files are to be saved.
If not specified, files will be saved to the same folder.
If the output directory doesn’t exist, it will be created, as well as any missing parent directories.
- -ow, --overwrite, -no-ow, --no-overwrite
Do not overwrite existing files on save.
If a file with the same name as the output file already exists, the command will suffix the filename with a number (
#1,#2, etc.).By default, existing files are overwritten.
- -rbb, --recalc-bboxes, -no-rbb, --no-recalc-bboxes
Do not recalculate the font’s bounding boxes on save.
By default,
glyf,CFF ``, ``headbounding box values andhhea/vheamin/max values are recalculated on save. Also, the glyphs are compiled on importing, which saves memory consumption and time.
- -rtb, --reorder-tables
Reorder the font’s tables on save.
When this option is active, tables are sorted by tag on save (recommended by the OpenType specification).
- -rts, --recalc-timestamp
Set the
modifiedtimestamp in theheadtable on save.By default, the original
modifiedtimestamp is kept.
Arguments
- INPUT_PATH
Required argument