Example #1
0
def _set_ompl():
    """Set up OMPL.

    OMPL is defined to be the list of mirrored pairs in Unicode 5.1:
    http://www.microsoft.com/typography/otspec/ttochap1.htm#ltrrtl
    """

    global OMPL
    unicode_data.load_data()
    bmg_data = unicode_data._bidi_mirroring_glyph_data
    OMPL = {char: bmg for (char, bmg) in bmg_data.items() if float(unicode_data.age(char)) <= 5.1}
Example #2
0
def _set_ompl():
    """Set up OMPL.

    OMPL is defined to be the list of mirrored pairs in Unicode 5.1:
    http://www.microsoft.com/typography/otspec/ttochap1.htm#ltrrtl
    """

    global OMPL
    unicode_data.load_data()
    bmg_data = unicode_data._bidi_mirroring_glyph_data
    OMPL = {char:bmg for (char, bmg) in bmg_data.items()
            if float(unicode_data.age(char)) <= 5.1}
Example #3
0
def find_fonts():
    font_name_regexp = re.compile(
        '(NotoSans|NotoSerif|NotoNaskh|NotoKufi|Arimo|Cousine|Tinos)'
        '(Mono)?'
        '(.*?)'
        '(UI|Eastern|Estrangela|Western)?'
        '-'
        '(|Black|Bold|DemiLight|Light|Medium|Regular|Thin)'
        '(Italic)?'
        '(-Windows)?'
        '.[ot]t[cf]')

    unicode_data.load_data()

    for directory in [
            path.join(FONT_DIR, 'hinted'),
            path.join(FONT_DIR, 'unhinted'),
            path.join(FONT_DIR, 'alpha'), CJK_DIR
    ]:
        for filename in os.listdir(directory):
            match = font_name_regexp.match(filename)
            if match:
                family, mono, script, variant, weight, style, platform = match.groups(
                )
            elif filename == 'NotoNastaliqUrduDraft.ttf':
                family = 'NotoNastaliq'
                script = 'Aran'  # Arabic Nastaliq
                weight = ''
                style = variant = platform = None
            else:
                if not (filename == 'NotoSansCJK.ttc.zip'
                        or  # All-comprehensive CJK
                        filename.endswith('.ttx') or filename.endswith('.git')
                        or filename.startswith('README.') or filename
                        in ['COPYING', 'LICENSE', 'NEWS', 'HISTORY']):
                    raise ValueError("unexpected filename in %s: '%s'." %
                                     (directory, filename))
                continue

            if directory == CJK_DIR:
                license_type = 'sil'
            else:
                license_type = 'apache'

            if mono:
                # we don't provide the Mono CJK on the website
                continue
            if script == "Historic":
                # we don't provide this either
                continue

            if family in {'Arimo', 'Cousine', 'Tinos'}:
                continue  # Skip these three for the website

            if family.startswith('Noto'):
                family = family.replace('Noto', 'Noto ')

            if weight == '':
                weight = 'Regular'

            assert platform is None

            if script == '':  # LGC
                supported_scripts.update({'Latn', 'Grek', 'Cyrl'})
            elif script == 'Aran':
                supported_scripts.add(script)
            elif script in {'JP', 'KR', 'SC', 'TC', 'CJK'}:
                continue  # Skip unified or old CJK fonts
            else:
                script = convert_to_four_letter(script)
                supported_scripts.add(script)

            file_path = path.join(directory, filename)
            if filename.endswith('.ttf') or filename.endswith('.otf'):
                charset = coverage.character_set(file_path)
            else:
                charset = NotImplemented

            if directory == CJK_DIR:
                hint_status = 'hinted'
            elif directory.endswith('alpha'):
                hint_status = 'unhinted'
            else:
                hint_status = path.basename(directory)
            assert hint_status in ['hinted', 'unhinted']

            key = family.replace(' ', '-')
            if script:
                key += '-' + script
            if variant not in {None, 'UI'}:
                key += '-' + variant
            key = key.lower()

            font = Font(file_path, hint_status, key, family, script, variant,
                        weight, style, platform, charset, license_type)
            all_fonts.append(font)
def find_fonts():
    font_name_regexp = re.compile(
        '(NotoSans|NotoSerif|NotoNaskh|NotoKufi|Arimo|Cousine|Tinos)'
        '(Mono)?'
        '(.*?)'
        '(UI|Eastern|Estrangela|Western)?'
        '-'
        '(|Black|Bold|DemiLight|Light|Medium|Regular|Thin)'
        '(Italic)?'
        '(-Windows)?'
        '.[ot]t[cf]')

    unicode_data.load_data()

    for directory in [path.join(INDIVIDUAL_FONT_DIR, 'hinted'),
                      path.join(INDIVIDUAL_FONT_DIR, 'unhinted'),
                      path.join(FONT_DIR, 'alpha'),
                      CJK_DIR]:
        for filename in os.listdir(directory):
            match = font_name_regexp.match(filename)
            if match:
                family, mono, script, variant, weight, style, platform = match.groups()
            elif filename == 'NotoNastaliqUrduDraft.ttf':
                family = 'NotoNastaliq'
                script = 'Aran'  # Arabic Nastaliq
                weight = ''
                style = variant = platform = None
            else:
                if not (
                    filename == 'NotoSansCJK.ttc' or  # All-comprehensive CJK
                    filename.endswith('.ttx') or
                    filename.startswith('README.') or
                    filename in ['COPYING', 'LICENSE', 'NEWS', 'HISTORY']):
                    raise ValueError("unexpected filename in %s: '%s'." %
                                     (directory, filename))
                continue

            if directory == CJK_DIR:
                license_type = 'sil'
            else:
                license_type = 'apache'

            if mono:
                # we don't provide the Mono CJK on the website
                continue
            if script == "Historic":
                # we don't provide this either
                continue

            if family in {'Arimo', 'Cousine', 'Tinos'}:
                continue  # Skip these three for the website

            if family.startswith('Noto'):
                family = family.replace('Noto', 'Noto ')

            if weight == '':
                weight = 'Regular'

            assert platform is None

            if script == '':  # LGC
                supported_scripts.update({'Latn', 'Grek', 'Cyrl'})
            elif script == 'Aran':
                supported_scripts.add(script)
            elif script in {'JP', 'KR', 'SC', 'TC', 'CJK'}:
                continue  # Skip unified or old CJK fonts
            else:
                script = convert_to_four_letter(script)
                supported_scripts.add(script)

            file_path = path.join(directory, filename)
            if filename.endswith('.ttf') or filename.endswith('.otf'):
                charset = coverage.character_set(file_path)
            else:
                charset = NotImplemented

            if directory == CJK_DIR:
                hint_status = 'hinted'
            elif directory.endswith('alpha'):
                hint_status = 'unhinted'
            else:
                hint_status = path.basename(directory)
            assert hint_status in ['hinted', 'unhinted']

            key = family.replace(' ', '-')
            if script:
                key += '-' + script
            if variant not in {None, 'UI'}:
                key += '-' + variant
            key = key.lower()

            font = Font(file_path, hint_status, key,
                        family, script, variant, weight, style, platform,
                        charset, license_type)
            all_fonts.append(font)
Example #5
0
def find_fonts():
    font_name_regexp = re.compile(
        "(NotoSans|NotoSerif|NotoNaskh|NotoKufi|Arimo|Cousine|Tinos)"
        "(Mono)?"
        "(.*?)"
        "(UI|Eastern|Estrangela|Western)?"
        "-"
        "(|Black|Bold|DemiLight|Light|Medium|Regular|Thin)"
        "(Italic)?"
        "(-Windows)?"
        ".[ot]t[cf]")

    unicode_data.load_data()

    for directory in [
            path.join(FONT_DIR, "hinted"),
            path.join(FONT_DIR, "unhinted"),
            path.join(FONT_DIR, "alpha"),
            CJK_DIR,
    ]:
        for filename in os.listdir(directory):
            match = font_name_regexp.match(filename)
            if match:
                family, mono, script, variant, weight, style, platform = match.groups(
                )
            elif filename == "NotoNastaliqUrduDraft.ttf":
                family = "NotoNastaliq"
                script = "Aran"  # Arabic Nastaliq
                weight = ""
                style = variant = platform = None
            else:
                if not (filename == "NotoSansCJK.ttc.zip"
                        or filename.endswith(".ttx")  # All-comprehensive CJK
                        or filename.endswith(".git")
                        or filename.startswith("README.") or filename
                        in ["COPYING", "LICENSE", "NEWS", "HISTORY"]):
                    raise ValueError("unexpected filename in %s: '%s'." %
                                     (directory, filename))
                continue

            if directory == CJK_DIR:
                license_type = "sil"
            else:
                license_type = "apache"

            if mono:
                # we don't provide the Mono CJK on the website
                continue
            if script == "Historic":
                # we don't provide this either
                continue

            if family in {"Arimo", "Cousine", "Tinos"}:
                continue  # Skip these three for the website

            if family.startswith("Noto"):
                family = family.replace("Noto", "Noto ")

            if weight == "":
                weight = "Regular"

            assert platform is None

            if script == "":  # LGC
                supported_scripts.update({"Latn", "Grek", "Cyrl"})
            elif script == "Aran":
                supported_scripts.add(script)
            elif script in {"JP", "KR", "SC", "TC", "CJK"}:
                continue  # Skip unified or old CJK fonts
            else:
                script = convert_to_four_letter(script)
                supported_scripts.add(script)

            file_path = path.join(directory, filename)
            if filename.endswith(".ttf") or filename.endswith(".otf"):
                charset = coverage.character_set(file_path)
            else:
                charset = NotImplemented

            if directory == CJK_DIR:
                hint_status = "hinted"
            elif directory.endswith("alpha"):
                hint_status = "unhinted"
            else:
                hint_status = path.basename(directory)
            assert hint_status in ["hinted", "unhinted"]

            key = family.replace(" ", "-")
            if script:
                key += "-" + script
            if variant not in {None, "UI"}:
                key += "-" + variant
            key = key.lower()

            font = Font(
                file_path,
                hint_status,
                key,
                family,
                script,
                variant,
                weight,
                style,
                platform,
                charset,
                license_type,
            )
            all_fonts.append(font)