コード例 #1
0
def check_familyname(name, styles):
  notofont = noto_fonts.get_noto_font('unhinted/' + name + '-Regular.ttf')
  if not notofont:
    print 'Error: could not parse', name
    return False
  print name, noto_fonts.noto_font_to_wws_family_id(notofont), styles
  return True
コード例 #2
0
def check_familyname(name, styles):
    notofont = noto_fonts.get_noto_font("unhinted/" + name + "-Regular.ttf")
    if not notofont:
        print("Error: could not parse", name)
        return False
    print(name, noto_fonts.noto_font_to_wws_family_id(notofont), styles)
    return True
コード例 #3
0
def check_familyname(name, styles):
    notofont = noto_fonts.get_noto_font('unhinted/' + name + '-Regular.ttf')
    if not notofont:
        print 'Error: could not parse', name
        return False
    print name, noto_fonts.noto_font_to_wws_family_id(notofont), styles
    return True
コード例 #4
0
def _get_noto_fonts(font_paths):
    FMTS = frozenset(['ttf', 'otf'])
    SCRIPTS = frozenset(['CJK', 'HST'])
    fonts = []
    for p in font_paths:
        font = noto_fonts.get_noto_font(p)
        if font and font.fmt in FMTS and font.script not in SCRIPTS:
            fonts.append(font)
    return fonts
コード例 #5
0
def _get_noto_fonts(font_paths):
    FMTS = frozenset(["ttf", "otf"])
    SCRIPTS = frozenset(["CJK", "HST"])
    fonts = []
    for p in font_paths:
        font = noto_fonts.get_noto_font(p)
        if font and font.fmt in FMTS and font.script not in SCRIPTS:
            fonts.append(font)
    return fonts
コード例 #6
0
ファイル: noto_names.py プロジェクト: bitforks/nototools
def _get_noto_fonts(font_paths):
  FMTS = frozenset(['ttf', 'otf'])
  SCRIPTS = frozenset(['CJK', 'HST'])
  fonts = []
  for p in font_paths:
    font = noto_fonts.get_noto_font(p)
    if font and font.fmt in FMTS and font.script not in SCRIPTS:
      fonts.append(font)
  return fonts
コード例 #7
0
def _get_font_info(f):
  font_info = noto_fonts.get_noto_font(f)
  if not font_info:
    raise Exception('not a noto font: "%s"' % f)
  return font_info
コード例 #8
0
def _get_sample_text(directory, font_names, lang):
    script_keys = set()
    scripts = set()
    for name in font_names:
        noto_font = noto_fonts.get_noto_font(path.join(directory, name))
        if noto_font.script not in script_keys:
            script_keys.add(noto_font.script)
            scripts |= noto_fonts.script_key_to_scripts(noto_font.script)

    if lang:
        lang_scripts = ["%s-%s" % (lang, script) for script in scripts]
    else:
        lang_scripts = [
            "%s-%s" % (lang_data.script_to_default_lang(script), script)
            for script in scripts
        ]
    lang_scripts.extend("und-%s" % script for script in scripts)

    samples = []
    sample_dir = tool_utils.resolve_path("[tools]/sample_texts")
    for f in os.listdir(sample_dir):
        for lang_script in lang_scripts:
            if f.startswith(lang_script):
                samples.append(f)
                break

    print(sorted(samples))
    # limit to scripts supported by all fonts
    selected = []
    for sample in samples:
        sample_supported = True
        for script_key in script_keys:
            script_key_supported = False
            for script in noto_fonts.script_key_to_scripts(script_key):
                if "-%s_" % script in sample:
                    script_key_supported = True
                    break
            if not script_key_supported:
                sample_supported = False
                break
        if sample_supported:
            selected.append(sample)
    if not selected:
        raise Exception("no sample supported by all fonts")
    samples = selected

    # limit to udhr ones if any exist
    selected = [s for s in samples if "_udhr" in s]
    if selected:
        samples = selected
    # limit to non-'und' ones if any exist
    selected = [s for s in samples if not s.startswith("und-")]
    if selected:
        samples = selected
    if len(samples) != 1:
        raise Exception(
            "found %d sample files (%s) but need exactly 1"
            % (len(samples), ", ".join(sorted(samples)))
        )
    print("selected sample %s" % samples[0])

    with codecs.open(path.join(sample_dir, samples[0]), "r", "utf-8") as f:
        text = f.read()
    return text.strip()
コード例 #9
0
def _get_font_info(f):
  font_info = noto_fonts.get_noto_font(f)
  if not font_info:
    raise Exception('not a noto font: "%s"' % f)
  return font_info