Esempio n. 1
0
def ttcfile_build_from_namesfile(
    output_ttc_path, file_dir, namesfile_name=None, tool_path=_BUILD_TOOL_PATH
):
    """Read names of files from namesfile and pass them to build_ttc to build
  a .ttc file.  The names file will default to one named after output_ttc and
  located in file_dir."""

    output_ttc_path = tool_utils.resolve_path(output_ttc_path)
    if not namesfile_name:
        namesfile_name = ttc_namesfile_name(output_ttc_path)

    namesfile_path = path.join(file_dir, namesfile_name)
    if not path.isfile(namesfile_path):
        raise ValueError("could not find names file %s" % namesfile_path)

    filenames = tool_utils.read_lines(namesfile_path)
    with tool_utils.temp_chdir(file_dir):
        # resolve filenames relative to file_dir
        fontpath_list = [tool_utils.resolve_path(n) for n in filenames]
    missing = [n for n in fontpath_list if not path.isfile(n)]
    if missing:
        raise ValueError(
            "%d files were missing:\n  %s" % (len(missing), "\n  ".join(missing))
        )
    ttcfile_build(output_ttc_path, fontpath_list)
Esempio n. 2
0
def ttcfile_build_from_namesfile(
    output_ttc_path, file_dir, namesfile_name=None, tool_path=_BUILD_TOOL_PATH):
  """Read names of files from namesfile and pass them to build_ttc to build
  a .ttc file.  The names file will default to one named after output_ttc and
  located in file_dir."""

  output_ttc_path = tool_utils.resolve_path(output_ttc_path)
  if not namesfile_name:
    namesfile_name = ttc_namesfile_name(output_ttc_path)

  namesfile_path = path.join(file_dir, namesfile_name)
  if not path.isfile(namesfile_path):
    raise ValueError('could not find names file %s' % namesfile_path)

  filenames = tool_utils.read_lines(namesfile_path)
  with tool_utils.temp_chdir(file_dir):
    # resolve filenames relative to file_dir
    fontpath_list = [tool_utils.resolve_path(n) for n in filenames]
  missing = [n for n in fontpath_list if not path.isfile(n)]
  if missing:
    raise ValueError(
        '%d files were missing:\n  %s' % (
            len(missing), '\n  '.join(missing)))
  ttcfile_build(output_ttc_path, fontpath_list)