def main(): parser = argparse.ArgumentParser() parser.add_argument('path', type=pathlib.Path, nargs='+') parser.add_argument('-v', '--verbose', help='increase output verbosity', action='count', default=0) args = parser.parse_args() init_logging(args.verbose, main=logger) for path in args.path: ttc_split(path)
async def main(): parser = argparse.ArgumentParser() parser.add_argument("path") parser.add_argument("-i", "--index", type=int, default=0) parser.add_argument("-v", "--verbose", help="increase output verbosity", action="count", default=0) args = parser.parse_args() init_logging(args.verbose) font = Font.load(args.path) if font.is_collection: font = font.fonts_in_collection[args.index] spacing = EastAsianSpacing() config = Config.default await spacing.add_glyphs(font, config) spacing.save_glyphs(sys.stdout)
async def main(): parser = argparse.ArgumentParser() parser.add_argument("font_path") parser.add_argument("-f", "--feature") parser.add_argument("-i", "--index", type=int, default=0) parser.add_argument("text") parser.add_argument("-l", "--language") parser.add_argument("-s", "--script") parser.add_argument("-v", "--verbose", help="increase output verbosity", action="count", default=0) args = parser.parse_args() show_dump_images() utils.init_logging(args.verbose) _init_shaper() # Re-initialize to show logging. font = Font.load(args.font_path) if font.is_collection: font = font.fonts_in_collection[args.index] if args.feature: features = args.feature.split(',') if 'vert' in features: font = font.vertical_font else: features = None shaper = Shaper(font, language=args.language, script=args.script, features=features) print(f'fullwidth={await shaper.compute_fullwidth_advance()}, ' f'upem={font.units_per_em}') result = await shaper.shape(args.text) result.set_text(args.text) result.compute_ink_parts(font) for g in result: print(g)
async def main(): parser = argparse.ArgumentParser() parser.add_argument("path", nargs="+") parser.add_argument("--diff", type=pathlib.Path, help="source font or directory " "to compute differences against.") parser.add_argument("-f", "--features", action="store_true", help="dump GPOS/GSUB feature names.") parser.add_argument("-o", "--output", type=pathlib.Path, help="output directory.") parser.add_argument("-r", "--ref", type=Dump.References, help="reference directory.") parser.add_argument("-s", "--sort", default="tag", choices=["offset", "tag"], help="sort order.") parser.add_argument("--ttx", action="store_true", help="create TTX files in addition to table list.") parser.add_argument("-v", "--verbose", help="increase output verbosity.", action="count", default=0) args = parser.parse_args() init_logging(args.verbose, main=logger) if args.output: args.output.mkdir(exist_ok=True, parents=True) dump_file_name = args.output is None and len(args.path) > 1 for i, (path, diff_src, glyphs) in enumerate(Dump.expand_paths(args)): if dump_file_name: if i: print() print(f'File: {path}') if diff_src: diffs = await Dump.diff_font(path, diff_src, diff_out=args.output) if args.ref: if not isinstance(diffs[0], os.PathLike): raise Exception('`-r` requires `-o`') if glyphs: diffs.append(glyphs) await args.ref.diff_with_references(diffs) continue font = Font.load(path) await Dump.dump_font(font, **vars(args)) logger.debug("dump %d completed: %s", i, font) if args.ref and args.ref.has_any: args.ref.print_stats() script = args.output / 'update-ref.sh' args.ref.write_update_script(script) if args.ref.has_any_diffs: print( f'Created a script to update reference files at "{script}".' ) logger.debug("main completed")
async def main(): parser = argparse.ArgumentParser() parser.add_argument("inputs", nargs="+") parser.add_argument("-i", "--index", help="font index, or a list of font indices" " for a font collection (TTC)") parser.add_argument("--debug", help="names of debug logs") parser.add_argument("--em", help="fullwidth advance, " "or characters to compute fullwidth advance from") parser.add_argument("-g", "--glyph-out", help="output glyph list") parser.add_argument("-G", "--glyph-comment", type=int, default=1, help="comment level for the glyph list") parser.add_argument("-l", "--language", help="language if the font is language-specific," " or a comma separated list of languages" " for a font collection (TTC)") parser.add_argument("--no-monospace", action="store_true", help="Skip ASCII-monospace fonts") parser.add_argument("-o", "--output", default="build", type=pathlib.Path, help="output directory") parser.add_argument("-p", "--print-path", action="store_true", help="print the file paths to stdout") parser.add_argument("-s", "--suffix", help="suffix to add to the output file name") parser.add_argument("--test", type=int, default=1, help="0=no tests, 1=smoke tests, 2=full tests") parser.add_argument("-v", "--verbose", help="increase output verbosity", action="count", default=0) args = parser.parse_args() init_logging(args.verbose, main=logger, debug=args.debug) if args.em is not None: with contextlib.suppress(ValueError): args.em = int(args.em) if args.glyph_out: if args.glyph_out == '-': args.glyph_out = sys.stdout else: args.glyph_out = pathlib.Path(args.glyph_out) args.glyph_out.mkdir(exist_ok=True, parents=True) for input in Builder.expand_paths(args.inputs): font = Font.load(input) if font.is_collection: config = Config.for_collection(font, languages=args.language, indices=args.index) else: config = Config.default if args.language: assert ',' not in args.language config = config.for_language(args.language) if args.no_monospace: config = config.with_skip_monospace_ascii(True) if args.em is not None: config = config.with_fullwidth_advance(args.em) builder = Builder(font, config) output = await builder.build_and_save( args.output, stem_suffix=args.suffix, glyph_out=args.glyph_out, glyph_comment=args.glyph_comment, print_path=args.print_path) if not output: logger.info('Skipped saving due to no changes: "%s"', input) continue if args.test: await builder.test(smoke=(args.test == 1))