Exemplo n.º 1
0
def main():
  parser = argparse.ArgumentParser(
      description="Generate 'cleaned' svg files.")
  parser.add_argument(
      'in_dir', help='Input directory.', metavar='dir')
  parser.add_argument(
      '-o', '--out_dir', help='Output directory, defaults to sibling of in_dir',
      metavar='dir')
  parser.add_argument(
      '-c', '--clean', help='Clean output directory', action='store_true')
  parser.add_argument(
      '-r', '--regex', help='Regex to select files, default matches all files.',
      metavar='regex', default=None)
  parser.add_argument(
      '-l', '--loglevel', help='log level name/value', default='warning')
  parser.add_argument(
      '-w', '--strip_whitespace', help='remove newlines and indentation',
      action='store_true')
  args = parser.parse_args()

  tool_utils.setup_logging(args.loglevel)

  if not args.out_dir:
    if args.in_dir.endswith('/'):
      args.in_dir = args.in_dir[:-1]
    args.out_dir = args.in_dir + '_clean'
    logging.info('Writing output to %s', args.out_dir)

  clean_svg_files(
      args.in_dir, args.out_dir, match_pat=args.regex, clean=args.clean,
      strip=args.strip_whitespace)
Exemplo n.º 2
0
def main(argv):
  DEFAULT_EMOJI_DIR = '[emoji]/svg'
  DEFAULT_FLAGS_DIR = '[emoji]/third_party/region-flags/svg'

  parser = argparse.ArgumentParser(
      description='Collect svg files into target directory with prefix.')
  parser.add_argument(
      'dst_dir', help='Directory to hold copied files.', metavar='dir')
  parser.add_argument(
      '--clean', '-c', help='Replace target directory', action='store_true')
  parser.add_argument(
      '--flags_dir', '-f', metavar='dir', help='directory containing flag svg, '
      'default %s' % DEFAULT_FLAGS_DIR, default=DEFAULT_FLAGS_DIR)
  parser.add_argument(
      '--emoji_dir', '-e', metavar='dir',
      help='directory containing emoji svg, default %s' % DEFAULT_EMOJI_DIR,
      default=DEFAULT_EMOJI_DIR)
  parser.add_argument(
      '-l', '--loglevel', help='log level name/value', default='warning')
  args = parser.parse_args(argv)

  tool_utils.setup_logging(args.loglevel)

  args.flags_dir = tool_utils.resolve_path(args.flags_dir)
  args.emoji_dir = tool_utils.resolve_path(args.emoji_dir)
  build_svg_dir(
      args.dst_dir, clean=args.clean, emoji_dir=args.emoji_dir,
      flags_dir=args.flags_dir)
Exemplo n.º 3
0
def main():
  parser = argparse.ArgumentParser(
      description="Generate 'cleaned' svg files.")
  parser.add_argument(
      'in_dir', help='Input directory.', metavar='dir')
  parser.add_argument(
      '-o', '--out_dir', help='Output directory, defaults to sibling of in_dir',
      metavar='dir')
  parser.add_argument(
      '-c', '--clean', help='Clean output directory', action='store_true')
  parser.add_argument(
      '-r', '--regex', help='Regex to select files, default matches all files.',
      metavar='regex', default=None)
  parser.add_argument(
      '-l', '--loglevel', help='log level name/value', default='warning')
  args = parser.parse_args()

  tool_utils.setup_logging(args.loglevel)

  if not args.out_dir:
    if args.in_dir.endswith('/'):
      args.in_dir = args.in_dir[:-1]
    args.out_dir = args.in_dir + '_clean'
    logging.info('Writing output to %s', args.out_dir)

  clean_svg_files(
      args.in_dir, args.out_dir, match_pat=args.regex, clean=args.clean)
Exemplo n.º 4
0
def main(argv):
    usage = """This will search for files that have image_prefix followed by one
  or more hex numbers (separated by underscore if more than one), and end in
  ".svg". For example, if image_prefix is "icons/u", then files with names like
  "icons/u1F4A9.svg" or "icons/u1F1EF_1F1F5.svg" will be loaded.  The script
  then adds cmap, htmx, and potentially GSUB entries for the Unicode characters
  found.  The advance width will be chosen based on image aspect ratio.  If
  Unicode values outside the BMP are desired, the existing cmap table should be
  of the appropriate (format 12) type.  Only the first cmap table and the first
  GSUB lookup (if existing) are modified."""

    parser = argparse.ArgumentParser(
        description=
        'Update cmap, glyf, GSUB, and hmtx tables from image glyphs.',
        epilog=usage)
    parser.add_argument('in_file',
                        help='Input ttx file name.',
                        metavar='fname')
    parser.add_argument('out_file',
                        help='Output ttx file name.',
                        metavar='fname')
    parser.add_argument('image_prefix',
                        help='Location and prefix of image files.',
                        metavar='path')
    parser.add_argument('-i',
                        '--include',
                        help='include files whoses name matches this regex',
                        metavar='regex')
    parser.add_argument('-e',
                        '--exclude',
                        help='exclude files whose name matches this regex',
                        metavar='regex')
    parser.add_argument('-l',
                        '--loglevel',
                        help='log level name',
                        default='warning')
    args = parser.parse_args(argv)

    tool_utils.setup_logging(args.loglevel)

    pairs = collect_glyphstr_file_pairs(args.image_prefix,
                                        'svg',
                                        include=args.include,
                                        exclude=args.exclude)
    add_image_glyphs(args.in_file, args.out_file, pairs)
Exemplo n.º 5
0
def main(argv):
    DEFAULT_EMOJI_DIR = '[emoji]/svg'
    DEFAULT_FLAGS_DIR = '[emoji]/third_party/region-flags/svg'

    parser = argparse.ArgumentParser(
        description='Collect svg files into target directory with prefix.')
    parser.add_argument('dst_dir',
                        help='Directory to hold copied files.',
                        metavar='dir')
    parser.add_argument('--clean',
                        '-c',
                        help='Replace target directory',
                        action='store_true')
    parser.add_argument('--flags_dir',
                        '-f',
                        metavar='dir',
                        help='directory containing flag svg, '
                        'default %s' % DEFAULT_FLAGS_DIR,
                        default=DEFAULT_FLAGS_DIR)
    parser.add_argument('--emoji_dir',
                        '-e',
                        metavar='dir',
                        help='directory containing emoji svg, default %s' %
                        DEFAULT_EMOJI_DIR,
                        default=DEFAULT_EMOJI_DIR)
    parser.add_argument('-l',
                        '--loglevel',
                        help='log level name/value',
                        default='warning')
    args = parser.parse_args(argv)

    tool_utils.setup_logging(args.loglevel)

    args.flags_dir = tool_utils.resolve_path(args.flags_dir)
    args.emoji_dir = tool_utils.resolve_path(args.emoji_dir)
    build_svg_dir(args.dst_dir,
                  clean=args.clean,
                  emoji_dir=args.emoji_dir,
                  flags_dir=args.flags_dir)
Exemplo n.º 6
0
def main(argv):
  usage = """This will search for files that have image_prefix followed by one
  or more hex numbers (separated by underscore if more than one), and end in
  ".svg". For example, if image_prefix is "icons/u", then files with names like
  "icons/u1F4A9.svg" or "icons/u1F1EF_1F1F5.svg" will be loaded.  The script
  then adds cmap, htmx, and potentially GSUB entries for the Unicode characters
  found.  The advance width will be chosen based on image aspect ratio.  If
  Unicode values outside the BMP are desired, the existing cmap table should be
  of the appropriate (format 12) type.  Only the first cmap table and the first
  GSUB lookup (if existing) are modified."""

  parser = argparse.ArgumentParser(
      description='Update cmap, glyf, GSUB, and hmtx tables from image glyphs.',
      epilog=usage)
  parser.add_argument(
      'in_file', help='Input ttx file name.', metavar='fname')
  parser.add_argument(
      'out_file', help='Output ttx file name.', metavar='fname')
  parser.add_argument(
      'image_prefix', help='Location and prefix of image files.',
      metavar='path')
  parser.add_argument(
      '-i', '--include', help='include files whoses name matches this regex',
      metavar='regex')
  parser.add_argument(
      '-e', '--exclude', help='exclude files whose name matches this regex',
      metavar='regex')
  parser.add_argument(
      '-l', '--loglevel', help='log level name', default='warning')
  args = parser.parse_args(argv)

  tool_utils.setup_logging(args.loglevel)

  pairs = collect_glyphstr_file_pairs(
      args.image_prefix, 'svg', include=args.include, exclude=args.exclude)
  add_image_glyphs(args.in_file, args.out_file, pairs)