def compare_cmap_data(base_cmap_data, target_cmap_data, scripts, cps, except_scripts, except_cps, no_additions, no_removals): result = {} base_map = cmap_data.create_map_from_table(base_cmap_data.table) target_map = cmap_data.create_map_from_table(target_cmap_data.table) for script in sorted(base_map): if except_scripts and script in except_scripts: continue if scripts and script not in scripts: continue if script in target_map: name = base_map[script].name base_cps = lint_config.parse_int_ranges(base_map[script].ranges) target_cps = lint_config.parse_int_ranges( target_map[script].ranges) added, removed = compare_cmaps(base_cps, target_cps, cps, except_cps, no_additions, no_removals) base_xcps, target_xcps = (set(), set()) if int(getattr(base_map[script], 'xcount', -1)) != -1: base_xcps = lint_config.parse_int_ranges( base_map[script].xranges) if int(getattr(target_map[script], 'xcount', -1)) != -1: target_xcps = lint_config.parse_int_ranges( target_map[script].xranges) xadded, xremoved = compare_cmaps(base_xcps, target_xcps, cps, except_cps, no_additions, no_removals) result[script] = added, removed, xadded, xremoved return result
def compare_cmap_data(base_cmap_data, target_cmap_data, scripts, cps, except_scripts, except_cps, no_additions, no_removals): result = {} base_map = cmap_data.create_map_from_table(base_cmap_data.table) target_map = cmap_data.create_map_from_table(target_cmap_data.table) for script in sorted(base_map): if except_scripts and script in except_scripts: continue if scripts and script not in scripts: continue if script in target_map: name = base_map[script].name base_cps = lint_config.parse_int_ranges(base_map[script].ranges) target_cps = lint_config.parse_int_ranges(target_map[script].ranges) if cps: base_cps &= cps target_cps &= cps if except_cps: base_cps -= except_cps target_cps -= except_cps if base_cps != target_cps: added = None if no_additions else target_cps - base_cps removed = None if no_removals else base_cps - target_cps else: added, removed = None, None result[script] = (added, removed) return result
def compare_cmap_data(base_cmap_data, target_cmap_data, scripts, cps, except_scripts, except_cps, no_additions, no_removals): result = {} base_map = cmap_data.create_map_from_table(base_cmap_data.table) target_map = cmap_data.create_map_from_table(target_cmap_data.table) for script in sorted(base_map): if except_scripts and script in except_scripts: continue if scripts and script not in scripts: continue if script in target_map: name = base_map[script].name base_cps = lint_config.parse_int_ranges(base_map[script].ranges) target_cps = lint_config.parse_int_ranges(target_map[script].ranges) added, removed = compare_cmaps( base_cps, target_cps, cps, except_cps, no_additions, no_removals) base_xcps, target_xcps = (set(), set()) if int(getattr(base_map[script], 'xcount', -1)) != -1: base_xcps = lint_config.parse_int_ranges(base_map[script].xranges) if int(getattr(target_map[script], 'xcount', -1)) != -1: target_xcps = lint_config.parse_int_ranges(target_map[script].xranges) xadded, xremoved = compare_cmaps( base_xcps, target_xcps, cps, except_cps, no_additions, no_removals) result[script] = added, removed, xadded, xremoved return result
def compare_cmap_data(base_cmap_data, target_cmap_data, scripts, cps, except_scripts, except_cps, no_additions, no_removals): result = {} base_map = cmap_data.create_map_from_table(base_cmap_data.table) target_map = cmap_data.create_map_from_table(target_cmap_data.table) for script in sorted(base_map): if except_scripts and script in except_scripts: continue if scripts and script not in scripts: continue if script in target_map: name = base_map[script].name base_cps = lint_config.parse_int_ranges(base_map[script].ranges) target_cps = lint_config.parse_int_ranges(target_map[script].ranges) if cps: base_cps &= cps target_cps &= cps if except_cps: base_cps -= except_cps target_cps -= except_cps if base_cps != target_cps: added = None if no_additions else target_cps - base_cps removed = None if no_removals else base_cps - target_cps else: added, removed = None, None result[script] = (added, removed) return result
def compare_data(base_data, target_data, opts=None): base_cps = lint_config.parse_int_ranges(base_data.ranges) target_cps = lint_config.parse_int_ranges(target_data.ranges) added, removed = compare_cmaps(base_cps, target_cps, opts) base_xcps, target_xcps = set(), set() if int(getattr(base_data, 'xcount', -1)) != -1: base_xcps = lint_config.parse_int_ranges(base_data.xranges) if int(getattr(target_data, 'xcount', -1)) != -1: target_xcps = lint_config.parse_int_ranges(target_data.xranges) xadded, xremoved = compare_cmaps(base_xcps, target_xcps, opts) return added, removed, xadded, xremoved
def compare_data(base_data, target_data, opts=None): base_cps = lint_config.parse_int_ranges(base_data.ranges) target_cps = lint_config.parse_int_ranges(target_data.ranges) added, removed = compare_cmaps(base_cps, target_cps, opts) base_xcps, target_xcps = set(), set() if int(getattr(base_data, 'xcount', -1)) != -1: base_xcps = lint_config.parse_int_ranges(base_data.xranges) if int(getattr(target_data, 'xcount', -1)) != -1: target_xcps = lint_config.parse_int_ranges(target_data.xranges) xadded, xremoved = compare_cmaps(base_xcps, target_xcps, opts) return added, removed, xadded, xremoved
def main(): parser = argparse.ArgumentParser() parser.add_argument( '-b', '--base', help='base cmap data file', metavar='file', required=True) parser.add_argument( '-t', '--target', help='target cmap data file', metavar='file', required=True) parser.add_argument( '-s', '--scripts', help='only these scripts (except ignored)', metavar='code', nargs='+') parser.add_argument( '-r', '--ranges', help='only these ranges (except ignored)', metavar='ranges', nargs='+') parser.add_argument( '-xs', '--except_scripts', help='ignore these scripts', metavar='code', nargs='+') parser.add_argument( '-xr', '--except_ranges', help='ignore these codepoints', metavar='ranges', nargs='+') parser.add_argument( '-na', '--no_additions', help='do not report additions (in target ' 'but not base)', action='store_true') parser.add_argument( '-nr', '--no_removals', help='do not report removals (in base ' 'but not target)', action='store_true') args = parser.parse_args() if args.scripts: scripts = set(args.scripts) else: scripts = None if args.ranges: cps = lint_config.parse_int_ranges(' '.join(args.ranges)) else: cps = None if args.except_ranges: except_cps = lint_config.parse_int_ranges(' '.join(args.except_ranges)) else: except_cps = None if args.except_scripts: except_scripts = set(args.except_scripts) else: except_scripts = None result = compare_cmap_data_files( args.base, args.target, scripts, cps, except_scripts, except_cps, args.no_additions, args.no_removals) report_compare(result)
def main(): parser = argparse.ArgumentParser() parser.add_argument( '-b', '--base', help='base cmap data file', metavar='file', required=True) parser.add_argument( '-t', '--target', help='target cmap data file', metavar='file', required=True) parser.add_argument( '-s', '--scripts', help='only these scripts (except ignored)', metavar='code', nargs='+') parser.add_argument( '-r', '--ranges', help='only these ranges (except ignored)', metavar='ranges', nargs='+') parser.add_argument( '-xs', '--except_scripts', help='ignore these scripts', metavar='code', nargs='+') parser.add_argument( '-xr', '--except_ranges', help='ignore these codepoints', metavar='ranges', nargs='+') parser.add_argument( '-na', '--no_additions', help='do not report additions (in target ' 'but not base)', action='store_true') parser.add_argument( '-nr', '--no_removals', help='do not report removals (in base ' 'but not target)', action='store_true') args = parser.parse_args() if args.scripts: scripts = set(args.scripts) else: scripts = None if args.ranges: cps = lint_config.parse_int_ranges(' '.join(args.ranges)) else: cps = None if args.except_ranges: except_cps = lint_config.parse_int_ranges(' '.join(args.except_ranges)) else: except_cps = None if args.except_scripts: except_scripts = set(args.except_scripts) else: except_scripts = None result = compare_cmap_data_files( args.base, args.target, scripts, cps, except_scripts, except_cps, args.no_additions, args.no_removals) report_compare(result)
def main(): parser = argparse.ArgumentParser() parser.add_argument("files", help="Files to dump", metavar="file", nargs="+") parser.add_argument("--ranges", help="Dump cmap as hex ranges", action="store_true") parser.add_argument("--text", help="Dump cmap as sample text", action="store_true") parser.add_argument("--sep", help="Separator between chars in text, default space", default=" ") parser.add_argument( "--info", help="Dump cmap as cp and unicode name, one per line", action="store_true", ) parser.add_argument( "--chars_per_line", help="Format text in lines of at most this " "many codepoints, 0 to format as a single line", type=int, metavar="N", default=32, ) parser.add_argument( "--limit", help="string of hex codepoint ranges limiting cmap " "to output", metavar="ranges", ) args = parser.parse_args() if not (args.ranges or args.text or args.info): args.info = True if args.limit: args.limit_set = lint_config.parse_int_ranges(args.limit) print("limit to: " + lint_config.write_int_ranges(args.limit_set)) else: # make sure it exists so checks don't have to care args.limit_set = None for fontpath in args.files: print("Font: " + path.normpath(fontpath)) _process_font(fontpath, args)
def main(): parser = argparse.ArgumentParser() parser.add_argument('files', help='Files to dump', metavar='file', nargs='+') parser.add_argument('--ranges', help='Dump cmap as hex ranges', action='store_true') parser.add_argument('--text', help='Dump cmap as sample text', action='store_true') parser.add_argument('--sep', help='Separator between chars in text, default space', default=' ') parser.add_argument('--info', help='Dump cmap as cp and unicode name, one per line', action='store_true') parser.add_argument('--chars_per_line', help='Format text in lines of at most this ' 'many codepoints, 0 to format as a single line', type=int, metavar='N', default=32) parser.add_argument('--limit', help='string of hex codepoint ranges limiting cmap ' 'to output', metavar='ranges') args = parser.parse_args() if not (args.ranges or args.text or args.info): args.info = True if args.limit: args.limit_set = lint_config.parse_int_ranges(args.limit) print 'limit to: ' + lint_config.write_int_ranges(args.limit_set) else: # make sure it exists so checks don't have to care args.limit_set = None for fontpath in args.files: print 'Font: ' + path.normpath(fontpath) _process_font(fontpath, args)
def main(): parser = argparse.ArgumentParser() parser.add_argument('files', help='Files to dump', metavar='file', nargs='+') parser.add_argument('--ranges', help='Dump cmap as hex ranges', action='store_true') parser.add_argument('--text', help='Dump cmap as sample text', action='store_true') parser.add_argument('--sep', help='Separator between chars in text, default space', default=' ') parser.add_argument('--info', help='Dump cmap as cp and unicode name, one per line', action='store_true') parser.add_argument('--chars_per_line', help='Format text in lines of at most this ' 'many codepoints, 0 to format as a single line', type=int, metavar='N', default=32) parser.add_argument('--limit', help='string of hex codepoint ranges limiting cmap ' 'to output', metavar='ranges') args = parser.parse_args() if not (args.ranges or args.text or args.info): args.info = True if args.limit: args.limit_set = lint_config.parse_int_ranges(args.limit) print 'limit to: ' + lint_config.write_int_ranges(args.limit_set) else: # make sure it exists so checks don't have to care args.limit_set = None for fontpath in args.files: print 'Font: ' + path.normpath(fontpath) _process_font(fontpath, args)
def main(): parser = argparse.ArgumentParser() parser.add_argument("-b", "--base", help="base cmap data file", metavar="file", required=True) parser.add_argument("-t", "--target", help="target cmap data file", metavar="file") parser.add_argument( "-s", "--scripts", help="only these scripts (except ignored)", metavar="code", nargs="+", ) parser.add_argument( "-r", "--ranges", help="only these ranges (except ignored)", metavar="ranges", nargs="+", ) parser.add_argument( "-xs", "--except_scripts", help="ignore these scripts", metavar="code", nargs="+", ) parser.add_argument( "-xr", "--except_ranges", help="ignore these codepoints", metavar="ranges", nargs="+", ) parser.add_argument( "-na", "--no_additions", help="do not report additions (in target " "but not base)", action="store_true", ) parser.add_argument( "-nr", "--no_removals", help="do not report removals (in base " "but not target)", action="store_true", ) parser.add_argument("-d", "--detailed", help="report details", action="store_true") args = parser.parse_args() if args.scripts: scripts = set(args.scripts) else: scripts = None if args.ranges: cps = lint_config.parse_int_ranges(" ".join(args.ranges)) else: cps = None if args.except_ranges: except_cps = lint_config.parse_int_ranges(" ".join(args.except_ranges)) else: except_cps = None if args.except_scripts: except_scripts = set(args.except_scripts) else: except_scripts = None opts = CompareOptions(cps, except_cps, args.no_additions, args.no_removals) if not args.target: if not scripts or len(scripts) < 2: print("Interscript comparison requires two or more scripts.") return result = compare_interscript_data_file(args.base, args.scripts, opts) report_interscript_compare(result, detailed=args.detailed) return result = compare_cmap_data_files(args.base, args.target, scripts, except_scripts, opts) report_compare(result, detailed=args.detailed)
def _emoji_pua_set(): """Returns the legacy PUA characters required for Android emoji.""" return lint_config.parse_int_ranges('FE4E5-FE4EE FE82C FE82E-FE837')
def _emoji_pua_set(): """Returns the legacy PUA characters required for Android emoji.""" return lint_config.parse_int_ranges('FE4E5-FE4EE FE82C FE82E-FE837')