diff options
Diffstat (limited to 'rename_font/build_font.py')
-rwxr-xr-x | rename_font/build_font.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/rename_font/build_font.py b/rename_font/build_font.py index a53ebbc25c..db0c98a3fe 100755 --- a/rename_font/build_font.py +++ b/rename_font/build_font.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (C) 2014 The Android Open Source Project # @@ -96,7 +96,7 @@ def main(argv): def convert_font(input_path): filename = os.path.basename(input_path) - print 'Converting font: ' + filename + print('Converting font: ' + filename) # the path to the output file. The file name is the fontfilename.ttx ttx_path = os.path.join(dest_dir, filename) ttx_path = ttx_path[:-1] + 'x' @@ -116,11 +116,11 @@ def convert_font(input_path): ttx.main(ttx_args) except InvalidFontException: # In case of invalid fonts, we exit. - print filename + ' is not a valid font' + print(filename + ' is not a valid font') raise except Exception as e: - print 'Error converting font: ' + filename - print e + print('Error converting font: ' + filename) + print(e) # Some fonts are too big to be handled by the ttx library. # Just copy paste them. shutil.copy(input_path, dest_dir) @@ -136,7 +136,7 @@ def get_font_info(tag): found in the name table of the font. """ fonts = [] font = None - last_name_id = sys.maxint + last_name_id = sys.maxsize for namerecord in tag.iter('namerecord'): if 'nameID' in namerecord.attrib: name_id = int(namerecord.attrib['nameID']) @@ -164,14 +164,14 @@ def get_font_info(tag): def update_tag(tag, fonts): - last_name_id = sys.maxint + last_name_id = sys.maxsize fonts_iterator = fonts.__iter__() font = None for namerecord in tag.iter('namerecord'): if 'nameID' in namerecord.attrib: name_id = int(namerecord.attrib['nameID']) if name_id <= last_name_id: - font = fonts_iterator.next() + font = next(fonts_iterator) font = update_font_name(font) last_name_id = name_id if name_id == NAMEID_FAMILY: @@ -192,7 +192,7 @@ def update_font_name(font): new_family = font.family + font.version else: new_family = font.family - if font.style is 'Regular' and not font.ends_in_regular: + if font.style == 'Regular' and not font.ends_in_regular: font.fullname = new_family else: font.fullname = new_family + ' ' + font.style @@ -205,7 +205,7 @@ def ends_in_regular(string): 'Regular' for plain fonts. However, some fonts don't obey this rule. We keep the style info, to minimize the diff. """ string = string.strip().split()[-1] - return string is 'Regular' + return string == 'Regular' def get_version(string): |