idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
242,600 | def com_google_fonts_check_whitespace_ink ( ttFont ) : from fontbakery . utils import get_glyph_name , glyph_has_ink WHITESPACE_CHARACTERS = [ 0x0009 , 0x000A , 0x000B , 0x000C , 0x000D , 0x0020 , 0x0085 , 0x00A0 , 0x1680 , 0x2000 , 0x2001 , 0x2002 , 0x2003 , 0x2004 , 0x2005 , 0x2006 , 0x2007 , 0x2008 , 0x2009 , 0x200A... | Whitespace glyphs have ink? |
242,601 | def com_google_fonts_check_required_tables ( ttFont ) : from . shared_conditions import is_variable_font REQUIRED_TABLES = { "cmap" , "head" , "hhea" , "hmtx" , "maxp" , "name" , "OS/2" , "post" } OPTIONAL_TABLES = { "cvt " , "fpgm" , "loca" , "prep" , "VORG" , "EBDT" , "EBLC" , "EBSC" , "BASE" , "GPOS" , "GSUB" , "JST... | Font contains all required tables? |
242,602 | def com_google_fonts_check_unwanted_tables ( ttFont ) : UNWANTED_TABLES = { 'FFTM' : '(from FontForge)' , 'TTFA' : '(from TTFAutohint)' , 'TSI0' : '(from VTT)' , 'TSI1' : '(from VTT)' , 'TSI2' : '(from VTT)' , 'TSI3' : '(from VTT)' , 'TSI5' : '(from VTT)' , 'prop' : '' } unwanted_tables_found = [ ] for table in ttFont ... | Are there unwanted tables? |
242,603 | def com_google_fonts_check_valid_glyphnames ( ttFont ) : if ttFont . sfntVersion == b'\x00\x01\x00\x00' and ttFont . get ( "post" ) and ttFont [ "post" ] . formatType == 3.0 : yield SKIP , ( "TrueType fonts with a format 3.0 post table contain no" " glyph names." ) else : import re bad_names = [ ] for _ , glyphName in ... | Glyph names are all valid? |
242,604 | def com_google_fonts_check_unique_glyphnames ( ttFont ) : if ttFont . sfntVersion == b'\x00\x01\x00\x00' and ttFont . get ( "post" ) and ttFont [ "post" ] . formatType == 3.0 : yield SKIP , ( "TrueType fonts with a format 3.0 post table contain no" " glyph names." ) else : import re glyphs = [ ] duplicated_glyphIDs = [... | Font contains unique glyph names? |
242,605 | def com_google_fonts_check_glyphnames_max_length ( ttFont ) : if ttFont . sfntVersion == b'\x00\x01\x00\x00' and ttFont . get ( "post" ) and ttFont [ "post" ] . formatType == 3.0 : yield PASS , ( "TrueType fonts with a format 3.0 post table contain no " "glyph names." ) else : failed = False for name in ttFont . getGly... | Check that glyph names do not exceed max length . |
242,606 | def com_google_fonts_check_ttx_roundtrip ( font ) : from fontTools import ttx import sys ttFont = ttx . TTFont ( font ) failed = False class TTXLogger : msgs = [ ] def __init__ ( self ) : self . original_stderr = sys . stderr self . original_stdout = sys . stdout sys . stderr = self sys . stdout = self def write ( self... | Checking with fontTools . ttx |
242,607 | def com_google_fonts_check_family_vertical_metrics ( ttFonts ) : failed = [ ] vmetrics = { "sTypoAscender" : { } , "sTypoDescender" : { } , "sTypoLineGap" : { } , "usWinAscent" : { } , "usWinDescent" : { } , "ascent" : { } , "descent" : { } } for ttfont in ttFonts : full_font_name = ttfont [ 'name' ] . getName ( 4 , 3 ... | Each font in a family must have the same vertical metrics values . |
242,608 | def com_google_fonts_check_linegaps ( ttFont ) : if ttFont [ "hhea" ] . lineGap != 0 : yield WARN , Message ( "hhea" , "hhea lineGap is not equal to 0." ) elif ttFont [ "OS/2" ] . sTypoLineGap != 0 : yield WARN , Message ( "OS/2" , "OS/2 sTypoLineGap is not equal to 0." ) else : yield PASS , "OS/2 sTypoLineGap and hhea... | Checking Vertical Metric Linegaps . |
242,609 | def com_google_fonts_check_maxadvancewidth ( ttFont ) : hhea_advance_width_max = ttFont [ 'hhea' ] . advanceWidthMax hmtx_advance_width_max = None for g in ttFont [ 'hmtx' ] . metrics . values ( ) : if hmtx_advance_width_max is None : hmtx_advance_width_max = max ( 0 , g [ 0 ] ) else : hmtx_advance_width_max = max ( g ... | MaxAdvanceWidth is consistent with values in the Hmtx and Hhea tables? |
242,610 | def com_google_fonts_check_monospace_max_advancewidth ( ttFont , glyph_metrics_stats ) : from fontbakery . utils import pretty_print_list seems_monospaced = glyph_metrics_stats [ "seems_monospaced" ] if not seems_monospaced : yield SKIP , ( "Font is not monospaced." ) return max_advw = ttFont [ 'hhea' ] . advanceWidthM... | Monospace font has hhea . advanceWidthMax equal to each glyph s advanceWidth? |
242,611 | def glyph_metrics_stats ( ttFont ) : glyph_metrics = ttFont [ 'hmtx' ] . metrics ascii_glyph_names = [ ttFont . getBestCmap ( ) [ c ] for c in range ( 32 , 128 ) if c in ttFont . getBestCmap ( ) ] ascii_widths = [ adv for name , ( adv , lsb ) in glyph_metrics . items ( ) if name in ascii_glyph_names ] ascii_width_count... | Returns a dict containing whether the font seems_monospaced what s the maximum glyph width and what s the most common width . |
242,612 | def vtt_talk_sources ( ttFont ) -> List [ str ] : VTT_SOURCE_TABLES = { 'TSI0' , 'TSI1' , 'TSI2' , 'TSI3' , 'TSI5' } tables_found = [ tag for tag in ttFont . keys ( ) if tag in VTT_SOURCE_TABLES ] return tables_found | Return the tags of VTT source tables found in a font . |
242,613 | def write ( self , data ) : self . _buffer . append ( data ) self . _current_ticks += 1 flush = False if self . _last_flush_time is None or ( self . _holdback_time is None and self . _max_ticks == 0 ) : flush = True elif self . _max_ticks and self . _current_ticks >= self . _max_ticks or self . _holdback_time and time ... | only put to stdout every now and then |
242,614 | def flush ( self , draw_progress = True ) : reset_progressbar = None if self . _draw_progressbar and draw_progress : progressbar , reset_progressbar = self . _draw_progressbar ( ) self . _buffer . append ( progressbar ) for line in self . _buffer : self . _outFile . write ( line ) self . _buffer = [ ] if reset_progress... | call this at the very end so that we can output the rest |
242,615 | def _draw_progressbar ( self , columns = None , len_prefix = 0 , right_margin = 0 ) : if self . _order == None : total = len ( self . _results ) else : total = max ( len ( self . _order ) , len ( self . _results ) ) percent = int ( round ( len ( self . _results ) / total * 100 ) ) if total else 0 needs_break = lambda c... | if columns is None don t insert any extra line breaks |
242,616 | def download_file ( url , dst_path ) : request = requests . get ( url , stream = True ) with open ( dst_path , 'wb' ) as downloaded_file : request . raw . decode_content = True shutil . copyfileobj ( request . raw , downloaded_file ) | Download a file from a url |
242,617 | def download_fonts ( gh_url , dst ) : font_paths = [ ] r = requests . get ( gh_url ) for item in r . json ( ) : if item [ 'name' ] . endswith ( ".ttf" ) : f = item [ 'download_url' ] dl_path = os . path . join ( dst , os . path . basename ( f ) ) download_file ( f , dl_path ) font_paths . append ( dl_path ) return font... | Download fonts from a github dir |
242,618 | def com_google_fonts_check_family_equal_font_versions ( ttFonts ) : all_detected_versions = [ ] fontfile_versions = { } for ttFont in ttFonts : v = ttFont [ 'head' ] . fontRevision fontfile_versions [ ttFont ] = v if v not in all_detected_versions : all_detected_versions . append ( v ) if len ( all_detected_versions ) ... | Make sure all font files have the same version value . |
242,619 | def com_google_fonts_check_unitsperem ( ttFont ) : upem = ttFont [ 'head' ] . unitsPerEm target_upem = [ 2 ** i for i in range ( 4 , 15 ) ] target_upem . append ( 1000 ) target_upem . append ( 2000 ) if upem < 16 or upem > 16384 : yield FAIL , ( "The value of unitsPerEm at the head table" " must be a value between 16 a... | Checking unitsPerEm value is reasonable . |
242,620 | def cached_getter ( func ) : @ wraps ( func ) def wrapper ( self ) : attribute = f'_{func.__name__}' value = getattr ( self , attribute , None ) if value is None : value = func ( self ) setattr ( self , attribute , value ) return value return wrapper | Decorate a property by executing it at instatiation time and cache the result on the instance object . |
242,621 | def condition ( * args , ** kwds ) : if len ( args ) == 1 and len ( kwds ) == 0 and callable ( args [ 0 ] ) : func = args [ 0 ] return wraps ( func ) ( FontBakeryCondition ( func ) ) else : def wrapper ( func ) : return wraps ( func ) ( FontBakeryCondition ( func , * args , ** kwds ) ) return wrapper | Check wrapper a factory for FontBakeryCondition |
242,622 | def check ( * args , ** kwds ) : def wrapper ( checkfunc ) : return wraps ( checkfunc ) ( FontBakeryCheck ( checkfunc , * args , ** kwds ) ) return wrapper | Check wrapper a factory for FontBakeryCheck |
242,623 | def get_bounding_box ( font ) : ymin = 0 ymax = 0 if font . sfntVersion == 'OTTO' : ymin = font [ 'head' ] . yMin ymax = font [ 'head' ] . yMax else : for g in font [ 'glyf' ] . glyphs : char = font [ 'glyf' ] [ g ] if hasattr ( char , 'yMin' ) and ymin > char . yMin : ymin = char . yMin if hasattr ( char , 'yMax' ) an... | Returns max and min bbox of given truetype font |
242,624 | def glyph_contour_count ( font , name ) : contour_count = 0 items = [ font [ 'glyf' ] [ name ] ] while items : g = items . pop ( 0 ) if g . isComposite ( ) : for comp in g . components : if comp . glyphName != ".ttfautohint" : items . append ( font [ 'glyf' ] [ comp . glyphName ] ) if g . numberOfContours != - 1 : cont... | Contour count for specified glyph . This implementation will also return contour count for composite glyphs . |
242,625 | def get_font_glyph_data ( font ) : from fontbakery . constants import ( PlatformID , WindowsEncodingID ) font_data = [ ] try : subtable = font [ 'cmap' ] . getcmap ( PlatformID . WINDOWS , WindowsEncodingID . UNICODE_BMP ) if not subtable : subtable = font [ 'cmap' ] . tables [ 0 ] cmap = subtable . cmap except : retur... | Return information for each glyph in a font |
242,626 | def glyph_has_ink ( font : TTFont , name : Text ) -> bool : if 'glyf' in font : return ttf_glyph_has_ink ( font , name ) elif ( 'CFF ' in font ) or ( 'CFF2' in font ) : return cff_glyph_has_ink ( font , name ) else : raise Exception ( "Could not find 'glyf', 'CFF ', or 'CFF2' table." ) | Checks if specified glyph has any ink . |
242,627 | def assert_results_contain ( check_results , expected_status , expected_msgcode = None ) : found = False for status , message in check_results : if status == expected_status and message . code == expected_msgcode : found = True break assert ( found ) | This helper function is useful when we want to make sure that a certain log message is emited by a check but it can be in any order among other log messages . |
242,628 | def com_google_fonts_check_family_underline_thickness ( ttFonts ) : underTs = { } underlineThickness = None failed = False for ttfont in ttFonts : fontname = ttfont . reader . file . name ut = ttfont [ 'post' ] . underlineThickness underTs [ fontname ] = ut if underlineThickness is None : underlineThickness = ut if ut ... | Fonts have consistent underline thickness? |
242,629 | def summary_table ( errors : int , fails : int , warns : int , skips : int , infos : int , passes : int , total : int ) -> str : return f | Return summary table with statistics . |
242,630 | def get_html ( self ) -> str : data = self . getdoc ( ) num_checks = 0 body_elements = [ ] for section in data [ "sections" ] : section_name = html . escape ( section [ "key" ] [ 0 ] ) section_stati_of_note = ( e for e in section [ "result" ] . elements ( ) if e != "PASS" ) section_stati = "" . join ( EMOTICON [ s ] fo... | Return complete report as a HTML string . |
242,631 | def omit_loglevel ( self , msg ) -> bool : return self . loglevels and ( self . loglevels [ 0 ] > fontbakery . checkrunner . Status ( msg ) ) | Determine if message is below log level . |
242,632 | def html_for_check ( self , check ) -> str : check [ "logs" ] . sort ( key = lambda c : LOGLEVELS . index ( c [ "status" ] ) ) logs = "<ul>" + "" . join ( [ self . log_html ( log ) for log in check [ "logs" ] ] ) + "</ul>" return logs | Return HTML string for complete single check . |
242,633 | def log_html ( self , log ) -> str : if not self . omit_loglevel ( log [ "status" ] ) : emoticon = EMOTICON [ log [ "status" ] ] status = log [ "status" ] message = html . escape ( log [ "message" ] ) . replace ( "\n" , "<br/>" ) return ( "<li class='details_item'>" f"<span class='details_indicator'>{emoticon} {status}... | Return single check sub - result string as HTML or not if below log level . |
242,634 | def style ( font ) : from fontbakery . constants import STATIC_STYLE_NAMES filename = os . path . basename ( font ) if '-' in filename : stylename = os . path . splitext ( filename ) [ 0 ] . split ( '-' ) [ 1 ] if stylename in [ name . replace ( ' ' , '' ) for name in STATIC_STYLE_NAMES ] : return stylename return None | Determine font style from canonical filename . |
242,635 | def canonical_stylename ( font ) : from fontbakery . constants import ( STATIC_STYLE_NAMES , VARFONT_SUFFIXES ) from fontbakery . profiles . shared_conditions import is_variable_font from fontTools . ttLib import TTFont valid_style_suffixes = [ name . replace ( ' ' , '' ) for name in STATIC_STYLE_NAMES ] filename = os ... | Returns the canonical stylename of a given font . |
242,636 | def com_google_fonts_check_canonical_filename ( font ) : from fontTools . ttLib import TTFont from fontbakery . profiles . shared_conditions import is_variable_font from fontbakery . constants import ( STATIC_STYLE_NAMES , VARFONT_SUFFIXES ) if canonical_stylename ( font ) : yield PASS , f"{font} is named canonically."... | Checking file is named canonically . |
242,637 | def family_directory ( fonts ) : if fonts : dirname = os . path . dirname ( fonts [ 0 ] ) if dirname == '' : dirname = '.' return dirname | Get the path of font project directory . |
242,638 | def descfile ( family_directory ) : if family_directory : descfilepath = os . path . join ( family_directory , "DESCRIPTION.en_us.html" ) if os . path . exists ( descfilepath ) : return descfilepath | Get the path of the DESCRIPTION file of a given font project . |
242,639 | def com_google_fonts_check_description_broken_links ( description ) : from lxml . html import HTMLParser import defusedxml . lxml import requests doc = defusedxml . lxml . fromstring ( description , parser = HTMLParser ( ) ) broken_links = [ ] for link in doc . xpath ( '//a/@href' ) : if link . startswith ( "mailto:" )... | Does DESCRIPTION file contain broken links? |
242,640 | def com_google_fonts_check_metadata_parses ( family_directory ) : from google . protobuf import text_format from fontbakery . utils import get_FamilyProto_Message try : pb_file = os . path . join ( family_directory , "METADATA.pb" ) get_FamilyProto_Message ( pb_file ) yield PASS , "METADATA.pb parsed successfuly." exce... | Check METADATA . pb parse correctly . |
242,641 | def com_google_fonts_check_family_equal_numbers_of_glyphs ( ttFonts ) : the_ttFonts = list ( ttFonts ) failed = False max_stylename = None max_count = 0 max_glyphs = None for ttFont in the_ttFonts : fontname = ttFont . reader . file . name stylename = canonical_stylename ( fontname ) this_count = len ( ttFont [ 'glyf' ... | Fonts have equal numbers of glyphs? |
242,642 | def com_google_fonts_check_family_equal_glyph_names ( ttFonts ) : fonts = list ( ttFonts ) all_glyphnames = set ( ) for ttFont in fonts : all_glyphnames |= set ( ttFont [ "glyf" ] . glyphs . keys ( ) ) missing = { } available = { } for glyphname in all_glyphnames : missing [ glyphname ] = [ ] available [ glyphname ] = ... | Fonts have equal glyph names? |
242,643 | def registered_vendor_ids ( ) : from bs4 import BeautifulSoup from pkg_resources import resource_filename registered_vendor_ids = { } CACHED = resource_filename ( 'fontbakery' , 'data/fontbakery-microsoft-vendorlist.cache' ) content = open ( CACHED , encoding = 'utf-8' ) . read ( ) soup = BeautifulSoup ( content , 'htm... | Get a list of vendor IDs from Microsoft s website . |
242,644 | def com_google_fonts_check_name_unwanted_chars ( ttFont ) : failed = False replacement_map = [ ( "\u00a9" , '(c)' ) , ( "\u00ae" , '(r)' ) , ( "\u2122" , '(tm)' ) ] for name in ttFont [ 'name' ] . names : string = str ( name . string , encoding = name . getEncoding ( ) ) for mark , ascii_repl in replacement_map : new_s... | Substitute copyright registered and trademark symbols in name table entries . |
242,645 | def licenses ( family_directory ) : found = [ ] search_paths = [ family_directory ] gitroot = git_rootdir ( family_directory ) if gitroot and gitroot not in search_paths : search_paths . append ( gitroot ) for directory in search_paths : if directory : for license in [ 'OFL.txt' , 'LICENSE.txt' ] : license_path = os . ... | Get a list of paths for every license file found in a font project . |
242,646 | def com_google_fonts_check_family_has_license ( licenses ) : if len ( licenses ) > 1 : yield FAIL , Message ( "multiple" , ( "More than a single license file found." " Please review." ) ) elif not licenses : yield FAIL , Message ( "no-license" , ( "No license file was found." " Please add an OFL.txt or a LICENSE.txt fi... | Check font has a license . |
242,647 | def com_google_fonts_check_name_license ( ttFont , license ) : from fontbakery . constants import PLACEHOLDER_LICENSING_TEXT failed = False placeholder = PLACEHOLDER_LICENSING_TEXT [ license ] entry_found = False for i , nameRecord in enumerate ( ttFont [ "name" ] . names ) : if nameRecord . nameID == NameID . LICENSE_... | Check copyright namerecords match license file . |
242,648 | def com_google_fonts_check_name_license_url ( ttFont , familyname ) : from fontbakery . constants import PLACEHOLDER_LICENSING_TEXT LEGACY_UFL_FAMILIES = [ "Ubuntu" , "UbuntuCondensed" , "UbuntuMono" ] LICENSE_URL = { 'OFL.txt' : 'http://scripts.sil.org/OFL' , 'LICENSE.txt' : 'http://www.apache.org/licenses/LICENSE-2.0... | License URL matches License text on name table? |
242,649 | def com_google_fonts_check_name_description_max_length ( ttFont ) : failed = False for name in ttFont [ 'name' ] . names : if ( name . nameID == NameID . DESCRIPTION and len ( name . string . decode ( name . getEncoding ( ) ) ) > 200 ) : failed = True break if failed : yield WARN , ( "A few name table entries with ID={... | Description strings in the name table must not exceed 200 characters . |
242,650 | def com_google_fonts_check_hinting_impact ( font , ttfautohint_stats ) : hinted = ttfautohint_stats [ "hinted_size" ] dehinted = ttfautohint_stats [ "dehinted_size" ] increase = hinted - dehinted change = ( float ( hinted ) / dehinted - 1 ) * 100 def filesize_formatting ( s ) : if s < 1024 : return f"{s} bytes" elif s ... | Show hinting filesize impact . |
242,651 | def com_google_fonts_check_name_version_format ( ttFont ) : from fontbakery . utils import get_name_entry_strings import re def is_valid_version_format ( value ) : return re . match ( r'Version\s0*[1-9]+\.\d+' , value ) failed = False version_entries = get_name_entry_strings ( ttFont , NameID . VERSION_STRING ) if len ... | Version format is correct in name table? |
242,652 | def com_google_fonts_check_has_ttfautohint_params ( ttFont ) : from fontbakery . utils import get_name_entry_strings def ttfautohint_version ( value ) : import re results = re . search ( r'ttfautohint \(v(.*)\) ([^;]*)' , value ) if results : return results . group ( 1 ) , results . group ( 2 ) version_strings = get_na... | Font has ttfautohint params? |
242,653 | def com_google_fonts_check_old_ttfautohint ( ttFont , ttfautohint_stats ) : from fontbakery . utils import get_name_entry_strings def ttfautohint_version ( values ) : import re for value in values : results = re . search ( r'ttfautohint \(v(.*)\)' , value ) if results : return results . group ( 1 ) def installed_versio... | Font has old ttfautohint applied? |
242,654 | def com_google_fonts_check_gasp ( ttFont ) : if "gasp" not in ttFont . keys ( ) : yield FAIL , ( "Font is missing the 'gasp' table." " Try exporting the font with autohinting enabled." ) else : if not isinstance ( ttFont [ "gasp" ] . gaspRange , dict ) : yield FAIL , "'gasp' table has no values." else : failed = False ... | Is gasp table set to optimize rendering? |
242,655 | def com_google_fonts_check_name_familyname_first_char ( ttFont ) : from fontbakery . utils import get_name_entry_strings failed = False for familyname in get_name_entry_strings ( ttFont , NameID . FONT_FAMILY_NAME ) : digits = map ( str , range ( 0 , 10 ) ) if familyname [ 0 ] in digits : yield FAIL , ( "Font family na... | Make sure family name does not begin with a digit . |
242,656 | def com_google_fonts_check_currency_chars ( ttFont ) : def font_has_char ( ttFont , codepoint ) : for subtable in ttFont [ 'cmap' ] . tables : if codepoint in subtable . cmap : return True return False failed = False OPTIONAL = { } MANDATORY = { 0x20AC : "EURO SIGN" } for codepoint , charname in OPTIONAL . items ( ) : ... | Font has all expected currency sign characters? |
242,657 | def com_google_fonts_check_name_ascii_only_entries ( ttFont ) : bad_entries = [ ] for name in ttFont [ "name" ] . names : if name . nameID == NameID . COPYRIGHT_NOTICE or name . nameID == NameID . POSTSCRIPT_NAME : string = name . string . decode ( name . getEncoding ( ) ) try : string . encode ( 'ascii' ) except : bad... | Are there non - ASCII characters in ASCII - only NAME table entries? |
242,658 | def com_google_fonts_check_metadata_license ( family_metadata ) : licenses = [ "APACHE2" , "OFL" , "UFL" ] if family_metadata . license in licenses : yield PASS , ( "Font license is declared" " in METADATA.pb as \"{}\"" ) . format ( family_metadata . license ) else : yield FAIL , ( "METADATA.pb license field (\"{}\")" ... | METADATA . pb license is APACHE2 UFL or OFL ? |
242,659 | def com_google_fonts_check_metadata_menu_and_latin ( family_metadata ) : missing = [ ] for s in [ "menu" , "latin" ] : if s not in list ( family_metadata . subsets ) : missing . append ( s ) if missing != [ ] : yield FAIL , ( "Subsets \"menu\" and \"latin\" are mandatory," " but METADATA.pb is missing" " \"{}\"" ) . fo... | METADATA . pb should contain at least menu and latin subsets . |
242,660 | def com_google_fonts_check_metadata_subsets_order ( family_metadata ) : expected = list ( sorted ( family_metadata . subsets ) ) if list ( family_metadata . subsets ) != expected : yield FAIL , ( "METADATA.pb subsets are not sorted " "in alphabetical order: Got ['{}']" " and expected ['{}']" ) . format ( "', '" . join ... | METADATA . pb subsets should be alphabetically ordered . |
242,661 | def com_google_fonts_check_metadata_familyname ( family_metadata ) : name = "" fail = False for f in family_metadata . fonts : if name and f . name != name : fail = True name = f . name if fail : yield FAIL , ( "METADATA.pb: Family name is not the same" " in all metadata \"fonts\" items." ) else : yield PASS , ( "METAD... | Check that METADATA . pb family values are all the same . |
242,662 | def com_google_fonts_check_metadata_nameid_family_name ( ttFont , font_metadata ) : from fontbakery . utils import get_name_entry_strings familynames = get_name_entry_strings ( ttFont , NameID . TYPOGRAPHIC_FAMILY_NAME ) if not familynames : familynames = get_name_entry_strings ( ttFont , NameID . FONT_FAMILY_NAME ) if... | Checks METADATA . pb font . name field matches family name declared on the name table . |
242,663 | def com_google_fonts_check_metadata_nameid_post_script_name ( ttFont , font_metadata ) : failed = False from fontbakery . utils import get_name_entry_strings postscript_names = get_name_entry_strings ( ttFont , NameID . POSTSCRIPT_NAME ) if len ( postscript_names ) == 0 : failed = True yield FAIL , Message ( "missing" ... | Checks METADATA . pb font . post_script_name matches postscript name declared on the name table . |
242,664 | def com_google_fonts_check_metadata_nameid_full_name ( ttFont , font_metadata ) : from fontbakery . utils import get_name_entry_strings full_fontnames = get_name_entry_strings ( ttFont , NameID . FULL_FONT_NAME ) if len ( full_fontnames ) == 0 : yield FAIL , Message ( "lacks-entry" , ( "This font lacks a FULL_FONT_NAME... | METADATA . pb font . full_name value matches fullname declared on the name table? |
242,665 | def com_google_fonts_check_metadata_nameid_font_name ( ttFont , style , font_metadata ) : from fontbakery . utils import get_name_entry_strings from fontbakery . constants import RIBBI_STYLE_NAMES if style in RIBBI_STYLE_NAMES : font_familynames = get_name_entry_strings ( ttFont , NameID . FONT_FAMILY_NAME ) nameid = N... | METADATA . pb font . name value should be same as the family name declared on the name table . |
242,666 | def com_google_fonts_check_metadata_match_fullname_postscript ( font_metadata ) : import re regex = re . compile ( r"\W" ) post_script_name = regex . sub ( "" , font_metadata . post_script_name ) fullname = regex . sub ( "" , font_metadata . full_name ) if fullname != post_script_name : yield FAIL , ( "METADATA.pb font... | METADATA . pb font . full_name and font . post_script_name fields have equivalent values ? |
242,667 | def com_google_fonts_check_metadata_match_filename_postscript ( font_metadata ) : post_script_name = font_metadata . post_script_name filename = os . path . splitext ( font_metadata . filename ) [ 0 ] if filename != post_script_name : yield FAIL , ( "METADATA.pb font filename=\"{}\" does not match" " post_script_name=\... | METADATA . pb font . filename and font . post_script_name fields have equivalent values? |
242,668 | def com_google_fonts_check_metadata_valid_name_values ( style , font_metadata , font_familynames , typographic_familynames ) : from fontbakery . constants import RIBBI_STYLE_NAMES if style in RIBBI_STYLE_NAMES : familynames = font_familynames else : familynames = typographic_familynames failed = False for font_familyna... | METADATA . pb font . name field contains font name in right format? |
242,669 | def com_google_fonts_check_metadata_valid_full_name_values ( style , font_metadata , font_familynames , typographic_familynames ) : from fontbakery . constants import RIBBI_STYLE_NAMES if style in RIBBI_STYLE_NAMES : familynames = font_familynames if familynames == [ ] : yield SKIP , "No FONT_FAMILYNAME" else : familyn... | METADATA . pb font . full_name field contains font name in right format? |
242,670 | def com_google_fonts_check_metadata_valid_filename_values ( font , family_metadata ) : expected = os . path . basename ( font ) failed = True for font_metadata in family_metadata . fonts : if font_metadata . filename == expected : failed = False yield PASS , ( "METADATA.pb filename field contains" " font name in right ... | METADATA . pb font . filename field contains font name in right format? |
242,671 | def com_google_fonts_check_metadata_valid_post_script_name_values ( font_metadata , font_familynames ) : for font_familyname in font_familynames : psname = "" . join ( str ( font_familyname ) . split ( ) ) if psname in "" . join ( font_metadata . post_script_name . split ( "-" ) ) : yield PASS , ( "METADATA.pb postScri... | METADATA . pb font . post_script_name field contains font name in right format? |
242,672 | def com_google_fonts_check_metadata_valid_copyright ( font_metadata ) : import re string = font_metadata . copyright does_match = re . search ( r'Copyright [0-9]{4} The .* Project Authors \([^\@]*\)' , string ) if does_match : yield PASS , "METADATA.pb copyright string is good" else : yield FAIL , ( "METADATA.pb: Copyr... | Copyright notices match canonical pattern in METADATA . pb |
242,673 | def com_google_fonts_check_font_copyright ( ttFont ) : import re from fontbakery . utils import get_name_entry_strings failed = False for string in get_name_entry_strings ( ttFont , NameID . COPYRIGHT_NOTICE ) : does_match = re . search ( r'Copyright [0-9]{4} The .* Project Authors \([^\@]*\)' , string ) if does_match ... | Copyright notices match canonical pattern in fonts |
242,674 | def com_google_fonts_check_metadata_italic_style ( ttFont , font_metadata ) : from fontbakery . utils import get_name_entry_strings from fontbakery . constants import MacStyle if font_metadata . style != "italic" : yield SKIP , "This check only applies to italic fonts." else : font_fullname = get_name_entry_strings ( t... | METADATA . pb font . style italic matches font internals? |
242,675 | def com_google_fonts_check_metadata_normal_style ( ttFont , font_metadata ) : from fontbakery . utils import get_name_entry_strings from fontbakery . constants import MacStyle if font_metadata . style != "normal" : yield SKIP , "This check only applies to normal fonts." else : font_familyname = get_name_entry_strings (... | METADATA . pb font . style normal matches font internals? |
242,676 | def com_google_fonts_check_metadata_nameid_family_and_full_names ( ttFont , font_metadata ) : from fontbakery . utils import get_name_entry_strings font_familynames = get_name_entry_strings ( ttFont , NameID . TYPOGRAPHIC_FAMILY_NAME ) if font_familynames : font_familyname = font_familynames [ 0 ] else : font_familynam... | METADATA . pb font . name and font . full_name fields match the values declared on the name table? |
242,677 | def com_google_fonts_check_metadata_match_weight_postscript ( font_metadata ) : WEIGHTS = { "Thin" : 100 , "ThinItalic" : 100 , "ExtraLight" : 200 , "ExtraLightItalic" : 200 , "Light" : 300 , "LightItalic" : 300 , "Regular" : 400 , "Italic" : 400 , "Medium" : 500 , "MediumItalic" : 500 , "SemiBold" : 600 , "SemiBoldIta... | METADATA . pb weight matches postScriptName . |
242,678 | def com_google_fonts_check_unitsperem_strict ( ttFont ) : upm_height = ttFont [ "head" ] . unitsPerEm ACCEPTABLE = [ 16 , 32 , 64 , 128 , 256 , 500 , 512 , 1000 , 1024 , 2000 , 2048 ] if upm_height not in ACCEPTABLE : yield FAIL , ( f"Font em size (unitsPerEm) is {upm_height}." " If possible, please consider using 1000... | Stricter unitsPerEm criteria for Google Fonts . |
242,679 | def remote_styles ( family_metadata ) : def download_family_from_Google_Fonts ( family_name ) : from zipfile import ZipFile from fontbakery . utils import download_file url_prefix = 'https://fonts.google.com/download?family=' url = '{}{}' . format ( url_prefix , family_name . replace ( ' ' , '+' ) ) return ZipFile ( do... | Get a dictionary of TTFont objects of all font files of a given family as currently hosted at Google Fonts . |
242,680 | def github_gfonts_ttFont ( ttFont , license ) : if not license : return from fontbakery . utils import download_file from fontTools . ttLib import TTFont from urllib . request import HTTPError LICENSE_DIRECTORY = { "OFL.txt" : "ofl" , "UFL.txt" : "ufl" , "LICENSE.txt" : "apache" } filename = os . path . basename ( ttFo... | Get a TTFont object of a font downloaded from Google Fonts git repository . |
242,681 | def com_google_fonts_check_version_bump ( ttFont , api_gfonts_ttFont , github_gfonts_ttFont ) : v_number = ttFont [ "head" ] . fontRevision api_gfonts_v_number = api_gfonts_ttFont [ "head" ] . fontRevision github_gfonts_v_number = github_gfonts_ttFont [ "head" ] . fontRevision failed = False if v_number == api_gfonts_v... | Version number has increased since previous release on Google Fonts? |
242,682 | def com_google_fonts_check_production_glyphs_similarity ( ttFont , api_gfonts_ttFont ) : def glyphs_surface_area ( ttFont ) : from fontTools . pens . areaPen import AreaPen glyphs = { } glyph_set = ttFont . getGlyphSet ( ) area_pen = AreaPen ( glyph_set ) for glyph in glyph_set . keys ( ) : glyph_set [ glyph ] . draw (... | Glyphs are similiar to Google Fonts version? |
242,683 | def com_google_fonts_check_italic_angle ( ttFont , style ) : failed = False value = ttFont [ "post" ] . italicAngle if value > 0 : failed = True yield FAIL , Message ( "positive" , ( "The value of post.italicAngle is positive, which" " is likely a mistake and should become negative," " from {} to {}." ) . format ( valu... | Checking post . italicAngle value . |
242,684 | def com_google_fonts_check_mac_style ( ttFont , style ) : from fontbakery . utils import check_bit_entry from fontbakery . constants import MacStyle expected = "Italic" in style yield check_bit_entry ( ttFont , "head" , "macStyle" , expected , bitmask = MacStyle . ITALIC , bitname = "ITALIC" ) expected = style in [ "Bo... | Checking head . macStyle value . |
242,685 | def com_google_fonts_check_contour_count ( ttFont ) : from fontbakery . glyphdata import desired_glyph_data as glyph_data from fontbakery . utils import ( get_font_glyph_data , pretty_print_list ) desired_glyph_data = { } for glyph in glyph_data : desired_glyph_data [ glyph [ 'unicode' ] ] = glyph bad_glyphs = [ ] desi... | Check if each glyph has the recommended amount of contours . |
242,686 | def com_google_fonts_check_metadata_nameid_copyright ( ttFont , font_metadata ) : failed = False for nameRecord in ttFont [ 'name' ] . names : string = nameRecord . string . decode ( nameRecord . getEncoding ( ) ) if nameRecord . nameID == NameID . COPYRIGHT_NOTICE and string != font_metadata . copyright : failed = Tru... | Copyright field for this font on METADATA . pb matches all copyright notice entries on the name table ? |
242,687 | def com_google_fonts_check_name_mandatory_entries ( ttFont , style ) : from fontbakery . utils import get_name_entry_strings from fontbakery . constants import RIBBI_STYLE_NAMES required_nameIDs = [ NameID . FONT_FAMILY_NAME , NameID . FONT_SUBFAMILY_NAME , NameID . FULL_FONT_NAME , NameID . POSTSCRIPT_NAME ] if style ... | Font has all mandatory name table entries ? |
242,688 | def com_google_fonts_check_name_copyright_length ( ttFont ) : from fontbakery . utils import get_name_entries failed = False for notice in get_name_entries ( ttFont , NameID . COPYRIGHT_NOTICE ) : notice_str = notice . string . decode ( notice . getEncoding ( ) ) if len ( notice_str ) > 500 : failed = True yield FAIL ,... | Length of copyright notice must not exceed 500 characters . |
242,689 | def com_google_fonts_check_fontv ( ttFont ) : from fontv . libfv import FontVersion fv = FontVersion ( ttFont ) if fv . version and ( fv . is_development or fv . is_release ) : yield PASS , "Font version string looks GREAT!" else : yield INFO , ( "Version string is: \"{}\"\n" "The version string must ideally include a ... | Check for font - v versioning |
242,690 | def com_google_fonts_check_negative_advance_width ( ttFont ) : failed = False for glyphName in ttFont [ "glyf" ] . glyphs : coords = ttFont [ "glyf" ] [ glyphName ] . coordinates rightX = coords [ - 3 ] [ 0 ] leftX = coords [ - 4 ] [ 0 ] advwidth = rightX - leftX if advwidth < 0 : failed = True yield FAIL , ( "glyph '{... | Check that advance widths cannot be inferred as negative . |
242,691 | def com_google_fonts_check_varfont_generate_static ( ttFont ) : import tempfile from fontTools . varLib import mutator try : loc = { k . axisTag : float ( ( k . maxValue + k . minValue ) / 2 ) for k in ttFont [ 'fvar' ] . axes } with tempfile . TemporaryFile ( ) as instance : font = mutator . instantiateVariableFont ( ... | Check a static ttf can be generated from a variable font . |
242,692 | def com_google_fonts_check_smart_dropout ( ttFont ) : INSTRUCTIONS = b"\xb8\x01\xff\x85\xb0\x04\x8d" if ( "prep" in ttFont and INSTRUCTIONS in ttFont [ "prep" ] . program . getBytecode ( ) ) : yield PASS , ( "'prep' table contains instructions" " enabling smart dropout control." ) else : yield FAIL , ( "'prep' table do... | Font enables smart dropout control in prep table instructions? |
242,693 | def com_google_fonts_check_aat ( ttFont ) : UNWANTED_TABLES = { 'EBSC' , 'Zaph' , 'acnt' , 'ankr' , 'bdat' , 'bhed' , 'bloc' , 'bmap' , 'bsln' , 'fdsc' , 'feat' , 'fond' , 'gcid' , 'just' , 'kerx' , 'lcar' , 'ltag' , 'mort' , 'morx' , 'opbd' , 'prop' , 'trak' , 'xref' } unwanted_tables_found = [ ] for table in ttFont .... | Are there unwanted Apple tables? |
242,694 | def com_google_fonts_check_fvar_name_entries ( ttFont ) : failed = False for instance in ttFont [ "fvar" ] . instances : entries = [ entry for entry in ttFont [ "name" ] . names if entry . nameID == instance . subfamilyNameID ] if len ( entries ) == 0 : failed = True yield FAIL , ( f"Named instance with coordinates {in... | All name entries referenced by fvar instances exist on the name table? |
242,695 | def com_google_fonts_check_varfont_weight_instances ( ttFont ) : failed = False for instance in ttFont [ "fvar" ] . instances : if 'wght' in instance . coordinates and instance . coordinates [ 'wght' ] % 100 != 0 : failed = True yield FAIL , ( "Found an variable font instance with" f" 'wght'={instance.coordinates['wght... | Variable font weight coordinates must be multiples of 100 . |
242,696 | def com_google_fonts_check_family_tnum_horizontal_metrics ( fonts ) : from fontbakery . constants import RIBBI_STYLE_NAMES from fontTools . ttLib import TTFont RIBBI_ttFonts = [ TTFont ( f ) for f in fonts if style ( f ) in RIBBI_STYLE_NAMES ] tnum_widths = { } for ttFont in RIBBI_ttFonts : glyphs = ttFont . getGlyphSe... | All tabular figures must have the same width across the RIBBI - family . |
242,697 | def com_google_fonts_check_ligature_carets ( ttFont , ligature_glyphs ) : if ligature_glyphs == - 1 : yield FAIL , Message ( "malformed" , "Failed to lookup ligatures." " This font file seems to be malformed." " For more info, read:" " https://github.com" "/googlefonts/fontbakery/issues/1596" ) elif "GDEF" not in ttFon... | Are there caret positions declared for every ligature? |
242,698 | def com_google_fonts_check_kerning_for_non_ligated_sequences ( ttFont , ligatures , has_kerning_info ) : def look_for_nonligated_kern_info ( table ) : for pairpos in table . SubTable : for i , glyph in enumerate ( pairpos . Coverage . glyphs ) : if not hasattr ( pairpos , 'PairSet' ) : continue for pairvalue in pairpos... | Is there kerning info for non - ligated sequences? |
242,699 | def com_google_fonts_check_name_family_and_style_max_length ( ttFont ) : from fontbakery . utils import ( get_name_entries , get_name_entry_strings ) failed = False for familyname in get_name_entries ( ttFont , NameID . FONT_FAMILY_NAME ) : plat = familyname . platformID familyname_str = familyname . string . decode ( ... | Combined length of family and style must not exceed 27 characters . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.