Exemple #1
0
def modify_fonts(font_names,
                 presentation='emoji',
                 output=None,
                 suffix=None,
                 dst_dir=None,
                 vs_added=None):
    assert dst_dir
    if output:
        assert len(font_names) == 1

    for font_name in font_names:
        font = ttLib.TTFont(font_name)
        if font_data.get_variation_sequence_cmap(font):
            # process no font if any already has a var selector cmap
            raise ValueError('font %s already has a format 14 cmap' %
                             font_name)

    if not path.exists(dst_dir):
        os.makedirs(dst_dir)

    emoji_variants = unicode_data.get_unicode_emoji_variants()
    if vs_added:
        emoji_variants = emoji_variants | vs_added

    for font_name in font_names:
        font = ttLib.TTFont(font_name)
        modify_font(font_name, font, presentation, emoji_variants)
        if output:
            new_name = output
        else:
            new_name = path.basename(font_name)
            if suffix:
                name, ext = path.splitext(new_name)
                new_name = name + suffix + ext
        font.save(path.join(dst_dir, new_name))
Exemple #2
0
def modify_fonts(font_names, presentation='emoji', output=None, suffix=None,
                 dst_dir=None, vs_added=None):
  assert dst_dir
  if output:
    assert len(font_names) == 1

  for font_name in font_names:
    font = ttLib.TTFont(font_name)
    if font_data.get_variation_sequence_cmap(font):
      # process no font if any already has a var selector cmap
      raise ValueError('font %s already has a format 14 cmap' % font_name)

  if not path.exists(dst_dir):
    os.makedirs(dst_dir)

  emoji_variants = unicode_data.get_unicode_emoji_variants()
  if vs_added:
    emoji_variants = emoji_variants | vs_added

  for font_name in font_names:
    font = ttLib.TTFont(font_name)
    modify_font(font_name, font, presentation, emoji_variants)
    if output:
      new_name = output
    else:
      new_name = path.basename(font_name)
      if suffix:
        name, ext = path.splitext(new_name)
        new_name = name + suffix + ext
    font.save(path.join(dst_dir, new_name))