utils

exception fontbakery.utils.BadCertificateSetupException[source]
class fontbakery.utils.IndentedParagraph(renderable, left=4, right=0, first=None)[source]
class fontbakery.utils.PointsPen[source]
getPoints()[source]
highestPoint()[source]
lowestPoint()[source]
@fontbakery.utils.all_kerning[source]
@fontbakery.utils.apple_terminal_bg_is_white[source]

Returns a boolean indicating if the background color of Apple’s Terminal is white.

@fontbakery.utils.axis(ttFont, tag)[source]

Return the axis with the given tag.

@fontbakery.utils.bold_adjacent_styles_in_full_font_name[source]
@fontbakery.utils.bullet_list(config, items, bullet='-', indentation='\t')[source]
@fontbakery.utils.can_shape(ttFont, text, parameters=None)[source]

Returns true if the font can render a text string without any .notdef characters.

@fontbakery.utils.cff_glyph_has_ink(font: TTFont, glyph_name: str) bool[source]
@fontbakery.utils.chars_in_range(ttFont, bit)[source]
@fontbakery.utils.check_bit_entry(ttFont, table, attr, expected, bitmask, bitname)[source]
@fontbakery.utils.close_but_not_on(value_expected, value_true, tolerance)[source]
@fontbakery.utils.compute_unicoderange_bits[source]
@fontbakery.utils.download_file[source]
@fontbakery.utils.exit_with_install_instructions[source]
@fontbakery.utils.feature_tags[source]
@fontbakery.utils.filenames_ending_in(suffix, root)[source]

Returns a list of the filenames of all files in a given directory subtree that have the given filename suffix. Example: List all “.json” files.

@fontbakery.utils.filesize_formatting[source]
@fontbakery.utils.format_error[source]

Detail an error with name and stack trace for serialisation.

@fontbakery.utils.get_advance_width_for_char(ttFont, ch)[source]
@fontbakery.utils.get_apple_terminal_bg_color[source]

Runs an AppleScript snippet that returns the RGB values of the background color of the active Apple Terminal window.

@fontbakery.utils.get_bounding_box[source]

Returns max and min bbox of given truetype font

@fontbakery.utils.get_family_name[source]

Get the family name from the name table.

TODO: For now, this is just name ID 1. It should be expanded to at least check IDs 16 & 21, and ideally do the whole font differentiator heuristic.

@fontbakery.utils.get_font_glyph_data[source]

Return information for each glyph in a font

@fontbakery.utils.get_glyph_name(font: TTFont, codepoint: int) str | None[source]
@fontbakery.utils.get_mark_class_glyphnames[source]
@fontbakery.utils.get_name_entries(font, nameID, platformID=None, encodingID=None, langID=None)[source]
@fontbakery.utils.get_name_entry_strings(font, nameID, platformID=None, encodingID=None, langID=None)[source]
@fontbakery.utils.get_preferred_cmap[source]
@fontbakery.utils.get_regular[source]
@fontbakery.utils.get_resource_file_contents[source]

Return the full file path of a resource file inside the fontbakery directory.

Parameters:

sub_file_path (str) – The file path relative to the fontbakery directory.

Returns:

The full file path

Return type:

Path

@fontbakery.utils.get_subfamily_name[source]

Get the subfamily name from the name table.

TODO: For now, this is just name ID 2. It should be expanded to at least check IDs 17 & 22, and ideally do the whole font differentiator heuristic.

@fontbakery.utils.get_theme[source]
@fontbakery.utils.git_rootdir[source]
@fontbakery.utils.glyph_contour_count(font, name)[source]

Contour count for specified glyph. This implementation will also return contour count for composite glyphs.

@fontbakery.utils.glyph_has_ink(font: TTFont, glyph_name: str) bool[source]

Checks if specified glyph has any ink.

That is, that it has at least one defined contour associated. Composites are considered to have ink if any of their components have ink. :param font: the font :param glyph_name: The name of the glyph to check for ink.

Returns:

True if the font has at least one contour associated with it.

@fontbakery.utils.image_dimensions[source]
@fontbakery.utils.is_icon_font(ttFont, config)[source]
@fontbakery.utils.is_negated[source]
@fontbakery.utils.is_non_spacing_mark_char[source]
@fontbakery.utils.iterate_lookup_list_with_extensions(ttFont, table, callback, *args)[source]

Iterates over the lookup list of a font’s GSUB/GPOS table, calling the callback with the lookup and the provided arguments, but descending into Extension subtables.

@fontbakery.utils.keyword_in_full_font_name(ttFont, keyword)[source]
@fontbakery.utils.language_tags[source]
@fontbakery.utils.mark_glyphs[source]
@fontbakery.utils.markdown_table[source]

Format a list of dicts into a markdown table.

>>> markdown_table(
>>>    [{"name": "Sam", "age": 30}, {"name": "Ash", "age": 25}]
>>> )
...
| name | age  |
| :--- | :--- |
| Sam  | 30   |
| Ash  | 25   |
@fontbakery.utils.name_entry_id[source]
@fontbakery.utils.pretty_print_list(config, values, shorten=10, sep=', ', glue=' and ', quiet=False)[source]
@fontbakery.utils.remove_cmap_entry(font, cp)[source]

Helper method that removes a codepoint entry from all the tables in cmap.

@fontbakery.utils.remove_white_space[source]
@fontbakery.utils.script_tags[source]
@fontbakery.utils.show_inconsistencies(dictionary, config)[source]

Display an ‘inconsistencies dictionary’ as a bullet list. Turns:

{ “value1”: [“file1”, “file2”], “value2”: [“file3”] }

into

  • value1: file1 and file2

  • value2: file3

@fontbakery.utils.split_camel_case[source]
@fontbakery.utils.ttf_glyph_has_ink(font: TTFont, name: str) bool[source]
@fontbakery.utils.typo_metrics_enabled[source]
@fontbakery.utils.unicoderange[source]

Get an integer bitmap representing the UnicodeRange fields in the os/2 table.

@fontbakery.utils.unicoderange_bit_name[source]
@fontbakery.utils.unindent_and_unwrap_rationale(rationale, checkid=None)[source]

Takes the ‘rationale’ docstring of a check and removes indents and hard line breaks that were added to long lines.