diff -Nru python-pysilfont-1.5.1.dev0-0~709-snapshot/debian/changelog python-pysilfont-1.5.1.dev0-0~711-snapshot/debian/changelog --- python-pysilfont-1.5.1.dev0-0~709-snapshot/debian/changelog 2021-11-29 19:02:35.000000000 +0000 +++ python-pysilfont-1.5.1.dev0-0~711-snapshot/debian/changelog 2021-11-30 19:41:00.000000000 +0000 @@ -1,8 +1,8 @@ -python-pysilfont (1.5.1.dev0-0~709-snapshot-202111291902~ubuntu18.04.1) bionic; urgency=low +python-pysilfont (1.5.1.dev0-0~711-snapshot-202111301941~ubuntu18.04.1) bionic; urgency=low * Auto build. - -- Launchpad Package Builder Mon, 29 Nov 2021 19:02:35 +0000 + -- Launchpad Package Builder Tue, 30 Nov 2021 19:41:00 +0000 python-pysilfont (1.5.1.dev0-1ubuntu1) bionic; urgency=medium diff -Nru python-pysilfont-1.5.1.dev0-0~709-snapshot/debian/git-build-recipe.manifest python-pysilfont-1.5.1.dev0-0~711-snapshot/debian/git-build-recipe.manifest --- python-pysilfont-1.5.1.dev0-0~709-snapshot/debian/git-build-recipe.manifest 2021-11-29 19:02:35.000000000 +0000 +++ python-pysilfont-1.5.1.dev0-0~711-snapshot/debian/git-build-recipe.manifest 2021-11-30 19:41:00.000000000 +0000 @@ -1,3 +1,3 @@ -# git-build-recipe format 0.4 deb-version {debupstream}-0~709-snapshot-202111291902 -lp:~silnrsi/smith/+git/pysilfont-master git-commit:2553dbb64da07ec64a44c935f84248c1c4fb061a +# git-build-recipe format 0.4 deb-version {debupstream}-0~711-snapshot-202111301941 +lp:~silnrsi/smith/+git/pysilfont-master git-commit:c0b17069be42c04e0c5543d05665d4ec22554d11 nest-part packaging lp:~silnrsi/smith/+git/pysilfont-pkg-py3 debian debian git-commit:968ddc65611f3573aba071297a7e75edd0f0ba22 diff -Nru python-pysilfont-1.5.1.dev0-0~709-snapshot/docs/scripts.md python-pysilfont-1.5.1.dev0-0~711-snapshot/docs/scripts.md --- python-pysilfont-1.5.1.dev0-0~709-snapshot/docs/scripts.md 2021-11-29 19:02:26.000000000 +0000 +++ python-pysilfont-1.5.1.dev0-0~711-snapshot/docs/scripts.md 2021-11-30 19:40:55.000000000 +0000 @@ -1269,12 +1269,13 @@ --- #### psfshownames -Usage: **`psfshownames [--bits] ifont [infont1 [ifont2]]`** +Usage: **`psfshownames [--bits] [--multiline] ifont [infont1 [ifont2]]`** _([Standard options](docs.md#standard-command-line-options) also apply)_ Show fields from the name table and optionally various bits that control linking font styles into font families. +The default output is a table, use the `--multiline` option to produce a line oriented output. Example usage: diff -Nru python-pysilfont-1.5.1.dev0-0~709-snapshot/lib/silfont/scripts/psfshownames.py python-pysilfont-1.5.1.dev0-0~711-snapshot/lib/silfont/scripts/psfshownames.py --- python-pysilfont-1.5.1.dev0-0~709-snapshot/lib/silfont/scripts/psfshownames.py 2021-11-29 19:02:26.000000000 +0000 +++ python-pysilfont-1.5.1.dev0-0~711-snapshot/lib/silfont/scripts/psfshownames.py 2021-11-30 19:40:55.000000000 +0000 @@ -8,6 +8,8 @@ from silfont.core import execute, splitfn from fontTools.ttLib import TTFont import glob +from operator import attrgetter, methodcaller +import tabulate WINDOWS_ENGLISH_IDS = 3, 1, 0x409 @@ -20,6 +22,7 @@ 17: 'Typographic/Preferred subfamily', 21: 'WWS family', 22: 'WWS subfamily', + 25: 'Variations PostScript Name Prefix', } @@ -36,10 +39,14 @@ self.width_class = 0 self.wws = '' + def sort_fullname(self): + return self.name_table[4] + argspec = [ ('font', {'help': 'ttf font(s) to run report against; wildcards allowed', 'nargs': "+"}, {'type': 'filename'}), ('-b', '--bits', {'help': 'Show bits', 'action': 'store_true'}, {}), + ('-m', '--multiline', {'help': 'Output multi-line key:values instead of a table', 'action': 'store_true'}, {}), ] @@ -59,31 +66,71 @@ font_info = FontInfo() font_info.filename = fullpath - names(font, font_info) - bits(font, font_info) + get_names(font, font_info) + get_bits(font, font_info) font_infos.append(font_info) + # Only needed for multi-line mode filename_width = max(filename_width, len(fullpath) + 1) if not font_infos: logger.log("No files match the filespec provided for fonts: " + str(args.fonts), "S") - name_width = max([len(name_id_name) for name_id_name in FAMILY_RELATED_IDS.values()]) + 1 - for font_info in font_infos: - filename = '' - if len(font_infos) > 1: - filename = font_info.filename + ':' - filename = f'{filename:{filename_width}} ' - records = multiline_names(name_width, font_info, filename) - if args.bits: - records += multiline_bits(name_width, font_info, filename) - if args.quiet: - print(records[1:]) - else: - logger.log("The following family-related values were found in the name, head, and OS/2 tables" + records, "P") + font_infos.sort(key=methodcaller('sort_fullname')) + font_infos.sort(key=attrgetter('width_class'), reverse=True) + font_infos.sort(key=attrgetter('weight_class')) + + if args.multiline: + # Multi-line mode + name_width = max([len(name_id_name) for name_id_name in FAMILY_RELATED_IDS.values()]) + 1 + for font_info in font_infos: + filename = '' + + if len(font_infos) > 1: + filename = font_info.filename + ':' + filename = f'{filename:{filename_width}} ' + + records = multiline_names(name_width, font_info, filename) + if args.bits: + records += multiline_bits(name_width, font_info, filename) + if args.quiet: + print(records[1:]) + else: + logger.log("The following family-related values were found in the name, head, and OS/2 tables" + records, "P") + else: + # Table mode + + # Record information for headers + headers = table_headers(args.bits) + + # Record information for each instance. + records = list() + for font_info in font_infos: + record = table_records(font_info, args.bits) + records.append(record) + + # Not all fonts in a family with have the same name ids present, + # for instance 16: Typographic/Preferred family is only needed in + # non-RIBBI familes, and even then only for the non-RIBBI instances. + # Also, not all the bit fields are present in each instance. + # Therefore, columns with no data in any instance are removed. + indices = list(range(len(headers))) + indices.reverse() + for index in indices: + empty = True + for record in records: + data = record[index] + if data: + empty = False + if empty: + for record in records + [headers]: + del record[index] + + # Format 'pipe' is nicer for GitHub, but is wider on a command line + print(tabulate.tabulate(records, headers, tablefmt='simple')) -def names(font, font_info): +def get_names(font, font_info): table = font['name'] (platform_id, encoding_id, language_id) = WINDOWS_ENGLISH_IDS @@ -98,7 +145,7 @@ font_info.name_table[name_id] = str(record) -def bits(font, font_info): +def get_bits(font, font_info): os2 = font['OS/2'] head = font['head'] font_info.weight_class = os2.usWeightClass @@ -155,6 +202,35 @@ return '' +def table_headers(bits): + headers = ['filename'] + for name_id in sorted(FAMILY_RELATED_IDS): + name_id_key = FAMILY_RELATED_IDS[name_id] + header = f'{name_id}: {name_id_key}' + if len(header) > 20: + header = header.replace(' ', '\n') + header = header.replace('/', '\n') + headers.append(header) + if bits: + headers.extend(['wght', 'R', 'B', 'I', 'wdth', 'WWS']) + return headers + + +def table_records(font_info, bits): + record = [font_info.filename] + for name_id in sorted(FAMILY_RELATED_IDS): + name_id_value = font_info.name_table.get(name_id, '') + record.append(name_id_value) + if bits: + record.append(font_info.weight_class) + record.append(font_info.regular) + record.append(font_info.bold) + record.append(font_info.italic) + record.append(font_info.width) + record.append(font_info.wws) + return record + + def cmd(): execute('FT', doit, argspec) diff -Nru python-pysilfont-1.5.1.dev0-0~709-snapshot/lib/silfont/scripts/psfversion.py python-pysilfont-1.5.1.dev0-0~711-snapshot/lib/silfont/scripts/psfversion.py --- python-pysilfont-1.5.1.dev0-0~709-snapshot/lib/silfont/scripts/psfversion.py 2021-11-29 19:02:26.000000000 +0000 +++ python-pysilfont-1.5.1.dev0-0~711-snapshot/lib/silfont/scripts/psfversion.py 2021-11-30 19:40:55.000000000 +0000 @@ -23,6 +23,7 @@ ('mutatorMath', '?', ''), ('odf', '?', ''), ('palaso', '?', ''), + ('tabulate', '?', ''), ('ufo2ft', '?', ''), ('ufoLib2', '?', ''), ) diff -Nru python-pysilfont-1.5.1.dev0-0~709-snapshot/setup.py python-pysilfont-1.5.1.dev0-0~711-snapshot/setup.py --- python-pysilfont-1.5.1.dev0-0~709-snapshot/setup.py 2021-11-29 19:02:26.000000000 +0000 +++ python-pysilfont-1.5.1.dev0-0~711-snapshot/setup.py 2021-11-30 19:40:55.000000000 +0000 @@ -18,7 +18,7 @@ warnings = [] if sys.argv[1] in ('develop', 'install') : - for m in ('Brotli', 'defcon', 'fontbakery','fontMath', 'fontParts', 'fontTools', 'glyphConstruction', 'glyphsLib', 'lxml', 'lz4', 'mutatorMath', 'palaso', 'odf', 'ufo2ft', 'ufoLib2'): + for m in ('Brotli', 'defcon', 'fontbakery','fontMath', 'fontParts', 'fontTools', 'glyphConstruction', 'glyphsLib', 'lxml', 'lz4', 'mutatorMath', 'palaso', 'odf', 'tabulate', 'ufo2ft', 'ufoLib2'): try: module = importlib.import_module(m) except ImportError : warnings.append("- Some modules/scripts require the python %s package which is not currently installed" % m)