def generate_ttc_zips_with_7za():
    """Generate zipped versions of the ttc files and put in pkgs directory."""

    # The font family code skips the ttc files, but we want them in the
    # package directory. Instead of mucking with the family code to add the ttcs
    # and then exclude them from the other handling, we'll just handle them
    # separately.
    # For now at least, the only .ttc fonts are the CJK fonts

    pkg_dir = path.join(OUTPUT_DIR, 'pkgs')
    tool_utils.ensure_dir_exists(pkg_dir)
    filenames = [path.basename(f) for f in os.listdir(CJK_DIR) if f.endswith('.ttc')]
    for filename in filenames:
        zip_basename = filename + '.zip'
        zip_path = path.join(pkg_dir, zip_basename)
        if path.isfile(zip_path):
            print("Continue: assuming built %s is valid." % zip_basename)
            continue
        oldsize = os.stat(path.join(CJK_DIR, filename)).st_size
        pairs = [(path.join(CJK_DIR, filename), filename),
                 (SIL_LICENSE_LOC, 'LICENSE_CJK.txt')]
        tool_utils.generate_zip_with_7za_from_filepairs(pairs, zip_path)
        newsize = os.stat(zip_path).st_size
        print "Wrote " + zip_path
        print 'Compressed from {0:,}B to {1:,}B.'.format(oldsize, newsize)
Beispiel #2
0
def generate_ttc_zips_with_7za():
    """Generate zipped versions of the ttc files and put in pkgs directory."""

    # The font family code skips the ttc files, but we want them in the
    # package directory. Instead of mucking with the family code to add the ttcs
    # and then exclude them from the other handling, we'll just handle them
    # separately.
    # For now at least, the only .ttc fonts are the CJK fonts

    pkg_dir = path.join(OUTPUT_DIR, 'pkgs')
    tool_utils.ensure_dir_exists(pkg_dir)
    filenames = [
        path.basename(f) for f in os.listdir(CJK_DIR) if f.endswith('.ttc')
    ]
    for filename in filenames:
        zip_basename = filename + '.zip'
        zip_path = path.join(pkg_dir, zip_basename)
        if path.isfile(zip_path):
            print("Continue: assuming built %s is valid." % zip_basename)
            continue
        oldsize = os.stat(path.join(CJK_DIR, filename)).st_size
        pairs = [(path.join(CJK_DIR, filename), filename),
                 (SIL_LICENSE_LOC, 'LICENSE_CJK.txt')]
        tool_utils.generate_zip_with_7za_from_filepairs(pairs, zip_path)
        newsize = os.stat(zip_path).st_size
        print("Wrote " + zip_path)
        print('Compressed from {0:,}B to {1:,}B.'.format(oldsize, newsize))
    shutil.copy2(path.join(CJK_DIR, 'NotoSansCJK.ttc.zip'),
                 path.join(pkg_dir, 'NotoSansCJK.ttc.zip'))
Beispiel #3
0
def create_zip(major_name, target_platform, fonts):
    # Make sure no file name repeats
    assert len({path.basename(font.filepath) for font in fonts}) == len(fonts)

    all_hint_statuses = {font.hint_status for font in fonts}
    if len(all_hint_statuses) == 1:
        hint_status = list(all_hint_statuses)[0]
    else:
        hint_status = 'various'

    if target_platform == 'other':
        if hint_status == 'various':
            # This may only be the comprehensive package
            assert len(fonts) > 50
            suffix = ''
        elif hint_status == 'unhinted':
            suffix = '-unhinted'
        else:  # hint_status == 'hinted'
            suffix = '-hinted'
    elif target_platform == 'windows':
        if hint_status in ['various', 'hinted']:
            if 'windows' in {font.platform for font in fonts}:
                suffix = '-windows'
            else:
                suffix = '-hinted'
        else:  # hint_status == 'unhinted':
            suffix = '-unhinted'
    else:  # target_platform == 'linux'
        if len(fonts) > 50 or hint_status in ['various', 'hinted']:
            suffix = '-hinted'
        else:
            suffix = '-unhinted'

    zip_basename = '%s%s.zip' % (major_name, suffix)

    zippath = path.join(OUTPUT_DIR, 'pkgs', zip_basename)
    frozen_fonts = frozenset(fonts)
    if path.isfile(zippath):  # Skip if the file already exists
        # When continuing, we assume that if it exists, it is good
        if zip_basename not in zip_contents_cache:
            print("Continue: assuming built %s is valid" % zip_basename)
            zip_contents_cache[zip_basename] = frozen_fonts
        else:
            assert zip_contents_cache[zip_basename] == frozen_fonts
        return zip_basename
    else:
        assert frozen_fonts not in zip_contents_cache.values()
        zip_contents_cache[zip_basename] = frozen_fonts
        pairs = []
        license_types = set()
        for font in fonts:
            pairs.append((font.filepath, path.basename(font.filepath)))
            license_types.add(font.license_type)
        if 'apache' in license_types:
            pairs.append((APACHE_LICENSE_LOC, 'LICENSE.txt'))
        if 'sil' in license_types:
            pairs.append((SIL_LICENSE_LOC, 'LICENSE_CJK.txt'))
        tool_utils.generate_zip_with_7za_from_filepairs(pairs, zippath)
    return zip_basename
def create_zip(major_name, target_platform, fonts):
    # Make sure no file name repeats
    assert len({path.basename(font.filepath) for font in fonts}) == len(fonts)

    all_hint_statuses = {font.hint_status for font in fonts}
    if len(all_hint_statuses) == 1:
        hint_status = list(all_hint_statuses)[0]
    else:
        hint_status = 'various'

    if target_platform == 'other':
        if hint_status == 'various':
            # This may only be the comprehensive package
            assert len(fonts) > 50
            suffix = ''
        elif hint_status == 'unhinted':
            suffix = '-unhinted'
        else:  # hint_status == 'hinted'
            suffix = '-hinted'
    elif target_platform == 'windows':
        if hint_status in ['various', 'hinted']:
            if 'windows' in {font.platform for font in fonts}:
                suffix = '-windows'
            else:
                suffix = '-hinted'
        else:  # hint_status == 'unhinted':
            suffix = '-unhinted'
    else:  # target_platform == 'linux'
        if len(fonts) > 50 or hint_status in ['various', 'hinted']:
            suffix = '-hinted'
        else:
            suffix = '-unhinted'

    zip_basename = '%s%s.zip' % (major_name, suffix)

    zippath = path.join(OUTPUT_DIR, 'pkgs', zip_basename)
    frozen_fonts = frozenset(fonts)
    if path.isfile(zippath):  # Skip if the file already exists
        # When continuing, we assume that if it exists, it is good
        if zip_basename not in zip_contents_cache:
            print("Continue: assuming built %s is valid" % zip_basename)
            zip_contents_cache[zip_basename] = frozen_fonts
        else:
            assert zip_contents_cache[zip_basename] == frozen_fonts
        return zip_basename
    else:
        assert frozen_fonts not in zip_contents_cache.values()
        zip_contents_cache[zip_basename] = frozen_fonts
        pairs = []
        license_types = set()
        for font in fonts:
            pairs.append((font.filepath, path.basename(font.filepath)))
            license_types.add(font.license_type)
        if 'apache' in license_types:
            pairs.append((APACHE_LICENSE_LOC, 'LICENSE.txt'))
        if 'sil' in license_types:
            pairs.append((SIL_LICENSE_LOC, 'LICENSE_CJK.txt'))
        tool_utils.generate_zip_with_7za_from_filepairs(pairs, zippath)
    return zip_basename
Beispiel #5
0
 def create_zip(self, name, fonts, readme_path):
   zipname = name + '.zip'
   zippath = path.join(self.pkgs, zipname)
   if path.isfile(zippath):
     print('Assuming %s is valid.' % zipname)
   else:
     pairs = [(readme_path, path.basename(readme_path))]
     license_types = set(font.license_type for font in fonts)
     if 'apache' in license_types:
       pairs.append((APACHE_LICENSE_LOC, 'LICENSE_APACHE.txt'))
     if 'sil' in license_types:
       pairs.append((SIL_LICENSE_LOC, 'LICENSE_OFL.txt'))
     for font in fonts:
       pairs.append((font.filepath, path.basename(font.filepath)))
     tool_utils.generate_zip_with_7za_from_filepairs(pairs, zippath)
     print 'Created zip %s' % zippath
   return os.stat(zippath).st_size
 def create_zip(self, name, fonts):
   zipname = name + '.zip'
   zippath = path.join(self.pkgs, zipname)
   if path.isfile(zippath):
     print('Assuming %s is valid.' % zipname)
   else:
     pairs = []
     license_types = set()
     for font in fonts:
       pairs.append((font.filepath, path.basename(font.filepath)))
       license_types.add(font.license_type)
     if 'apache' in license_types:
       pairs.append((APACHE_LICENSE_LOC, 'LICENSE.txt'))
     if 'sil' in license_types:
       pairs.append((SIL_LICENSE_LOC, 'LICENSE_CJK.txt'))
     tool_utils.generate_zip_with_7za_from_filepairs(pairs, zippath)
     print 'Created zip %s' % zippath
   return os.stat(zippath).st_size
Beispiel #7
0
  def build_ttc_zips(self):
    """Generate zipped versions of the ttc files and put in pkgs directory."""

    # The font family code skips the ttc files, but we want them in the
    # package directory. Instead of mucking with the family code to add the ttcs
    # and then exclude them from the other handling, we'll just handle them
    # separately.
    # For now at least, the only .ttc fonts are the CJK fonts

    readme_path = self.get_readme_path('cjk')
    readme_pair = (readme_path, path.basename(readme_path))
    filenames = [path.basename(f) for f in os.listdir(CJK_DIR)
                 if f.endswith('.ttc')]
    for filename in filenames:
      zip_basename = filename + '.zip'
      zip_path = path.join(self.pkgs, zip_basename)
      if path.isfile(zip_path):
          print("Assuming built %s is valid." % zip_basename)
          continue
      oldsize = os.stat(path.join(CJK_DIR, filename)).st_size
      pairs = [
          readme_pair,
          (SIL_LICENSE_LOC, 'LICENSE_OFL.txt'),
          (path.join(CJK_DIR, filename), filename)]
      tool_utils.generate_zip_with_7za_from_filepairs(pairs, zip_path)
      newsize = os.stat(zip_path).st_size
      print "Wrote " + zip_path
      print 'Compressed from {0:,}B to {1:,}B.'.format(oldsize, newsize)

    # NotoSansCJK.ttc.zip already has been zipped for size reasons because
    # git doesn't like very large files. So it wasn't in the above
    # files. For our purposes ideally it would have the license file in it,
    # but it doesn't.  So we have to copy the zip and add the license to
    # the copy.
    filename = 'NotoSansCJK.ttc.zip'
    src_zip = path.join(CJK_DIR, filename)
    dst_zip = path.join(self.pkgs, filename)
    shutil.copy2(src_zip, dst_zip)
    pairs = [readme_pair, (SIL_LICENSE_LOC, 'LICENSE_OFL.txt')]
    tool_utils.generate_zip_with_7za_from_filepairs(pairs, dst_zip)
  def build_ttc_zips(self):
    """Generate zipped versions of the ttc files and put in pkgs directory."""

    # The font family code skips the ttc files, but we want them in the
    # package directory. Instead of mucking with the family code to add the ttcs
    # and then exclude them from the other handling, we'll just handle them
    # separately.
    # For now at least, the only .ttc fonts are the CJK fonts

    filenames = [path.basename(f) for f in os.listdir(CJK_DIR)
                 if f.endswith('.ttc')]
    for filename in filenames:
      zip_basename = filename + '.zip'
      zip_path = path.join(self.pkgs, zip_basename)
      if path.isfile(zip_path):
          print("Assuming built %s is valid." % zip_basename)
          continue
      oldsize = os.stat(path.join(CJK_DIR, filename)).st_size
      pairs = [(path.join(CJK_DIR, filename), filename),
               (SIL_LICENSE_LOC, 'LICENSE_OFL.txt')]
      tool_utils.generate_zip_with_7za_from_filepairs(pairs, zip_path)
      newsize = os.stat(zip_path).st_size
      print "Wrote " + zip_path
      print 'Compressed from {0:,}B to {1:,}B.'.format(oldsize, newsize)

    # NotoSansCJK.ttc.zip already has been zipped for size reasons because
    # git doesn't like very large files. So it wasn't in the above
    # files. For our purposes ideally it would have the license file in it,
    # but it doesn't.  So we have to copy the zip and add the license to
    # the copy.
    filename = 'NotoSansCJK.ttc.zip'
    src_zip = path.join(CJK_DIR, filename)
    dst_zip = path.join(self.pkgs, filename)
    shutil.copy2(src_zip, dst_zip)
    pairs = [(SIL_LICENSE_LOC, 'LICENSE_OFL.txt')]
    tool_utils.generate_zip_with_7za_from_filepairs(pairs, dst_zip)