<s> """<STR_LIT>""" <EOL> import sys <EOL> from fontTools import ttLib <EOL> from nototools import font_data <EOL> import temporary_touchups <EOL> def apply_web_specific_fixes ( font , unhinted , family_name ) : <EOL> """<STR_LIT>""" <EOL> os2 = font [ '<STR_LIT>' ] <EOL> os2 . sTypoAscender = <NUM_LIT> <EOL> os2 . sTypoDescender = - <NUM_LIT> <EOL> os2 . sTypoLineGap = <NUM_LIT> <EOL> os2 . usWinAscent = <NUM_LIT> <EOL> os2 . usWinDescent = <NUM_LIT> <EOL> subfamily_name = font_data . get_name_records ( font ) [ <NUM_LIT:2> ] . encode ( '<STR_LIT>' ) <EOL> assert ( subfamily_name in <EOL> [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in font_data . get_name_records ( font ) [ <NUM_LIT:1> ] : <EOL> family_name += '<STR_LIT>' <EOL> full_name = family_name <EOL> if subfamily_name != '<STR_LIT>' : <EOL> full_name += '<STR_LIT:U+0020>' + subfamily_name <EOL> font_data . set_name_record ( font , <NUM_LIT:16> , family_name ) <EOL> style_map = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if subfamily_name in style_map : <EOL> font_data . set_name_record ( font , <NUM_LIT:1> , family_name ) <EOL> else : <EOL> weight = subfamily_name . split ( ) [ <NUM_LIT:0> ] <EOL> new_family_name = family_name <EOL> if weight != '<STR_LIT>' : <EOL> new_family_name += '<STR_LIT:U+0020>' + weight <EOL> font_data . set_name_record ( font , <NUM_LIT:1> , new_family_name ) <EOL> italic = subfamily_name . endswith ( '<STR_LIT>' ) <EOL> font_data . set_name_record ( font , <NUM_LIT:2> , style_map [ italic << <NUM_LIT:1> ] ) <EOL> font_data . set_name_record ( font , <NUM_LIT:3> , full_name ) <EOL> font_data . set_name_record ( font , <NUM_LIT:4> , full_name ) <EOL> font_data . set_name_record ( font , <NUM_LIT> , None ) <EOL> font_data . set_name_record ( <EOL> font , <NUM_LIT:6> , ( family_name + '<STR_LIT:->' + subfamily_name ) . replace ( '<STR_LIT:U+0020>' , '<STR_LIT>' ) ) <EOL> font_data . set_name_record ( <EOL> font , <NUM_LIT:0> , '<STR_LIT>' ) <EOL> glyf = font [ '<STR_LIT>' ] <EOL> tmp = glyf [ '<STR_LIT>' ] <EOL> glyf [ '<STR_LIT>' ] = glyf [ '<STR_LIT>' ] <EOL> glyf [ '<STR_LIT>' ] = tmp <EOL> glyph_order = font . getGlyphOrder ( ) <EOL> for i , glyph_name in enumerate ( glyph_order ) : <EOL> if glyph_name . endswith ( '<STR_LIT>' ) : <EOL> new_name = glyph_name . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> glyph_order [ i ] = new_name <EOL> font [ '<STR_LIT>' ] [ new_name ] = font [ '<STR_LIT>' ] [ glyph_name ] <EOL> glyph_order . append ( glyph_name ) <EOL> del font [ '<STR_LIT>' ] [ glyph_name ] <EOL> for table in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> font [ table ] = unhinted [ table ] <EOL> def correct_font ( source_name , unhinted_name , target_font_name , family_name ) : <EOL> """<STR_LIT>""" <EOL> font = ttLib . TTFont ( source_name ) <EOL> unhinted = ttLib . TTFont ( unhinted_name ) <EOL> apply_web_specific_fixes ( font , unhinted , family_name ) <EOL> temporary_touchups . apply_temporary_fixes ( font ) <EOL> font . save ( target_font_name ) <EOL> def main ( argv ) : <EOL> """<STR_LIT>""" <EOL> correct_font ( * argv [ <NUM_LIT:1> : ] ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( sys . argv ) </s>
