<commit_before>from __future__ import print_function, division, absolute_import

from ufo2ft.kernFeatureWriter import KernFeatureWriter
from ufo2ft.makeotfParts import FeatureOTFCompiler
from ufo2ft.markFeatureWriter import MarkFeatureWriter
from ufo2ft.outlineOTF import OutlineOTFCompiler, OutlineTTFCompiler


def _compile(font, outlineCompilerClass, featureCompilerClass,
             kernWriter, markWriter):
    """Create FontTools TTFonts from a UFO."""

    outlineCompiler = outlineCompilerClass(font)
    outline = outlineCompiler.compile()

    featureCompiler = featureCompilerClass(
        font, outline, kernWriter=kernWriter, markWriter=markWriter)
    feasrc = featureCompiler.compile()
    for table in ['GPOS', 'GSUB']:
        if table in feasrc:
            outline[table] = feasrc[table]

    return outline


def compileOTF(font, outlineCompilerClass=OutlineOTFCompiler,
               featureCompilerClass=FeatureOTFCompiler,
               kernWriter=KernFeatureWriter, markWriter=MarkFeatureWriter):
    """Create FontTools CFF font from a UFO."""

    return _compile(font, outlineCompilerClass, featureCompilerClass,
                    kernWriter, markWriter)


def compileTTF(font, outlineCompilerClass=OutlineTTFCompiler,
               featureCompilerClass=FeatureOTFCompiler,
               kernWriter=KernFeatureWriter, markWriter=MarkFeatureWriter):
    """Create FontTools TrueType font from a UFO."""

    return _compile(font, outlineCompilerClass, featureCompilerClass,
                    kernWriter, markWriter)
<commit_msg>__init__: add glyphOrder opt. argument<commit_after>from __future__ import print_function, division, absolute_import

from ufo2ft.kernFeatureWriter import KernFeatureWriter
from ufo2ft.makeotfParts import FeatureOTFCompiler
from ufo2ft.markFeatureWriter import MarkFeatureWriter
from ufo2ft.outlineOTF import OutlineOTFCompiler, OutlineTTFCompiler


def _compile(font, glyphOrder, outlineCompilerClass, featureCompilerClass,
             kernWriter, markWriter):
    """Create FontTools TTFonts from a UFO."""

    outlineCompiler = outlineCompilerClass(font, glyphOrder=glyphOrder)
    outline = outlineCompiler.compile()

    featureCompiler = featureCompilerClass(
        font, outline, kernWriter=kernWriter, markWriter=markWriter)
    feasrc = featureCompiler.compile()
    for table in ['GPOS', 'GSUB']:
        if table in feasrc:
            outline[table] = feasrc[table]

    return outline


def compileOTF(font, glyphOrder=None, outlineCompilerClass=OutlineOTFCompiler,
               featureCompilerClass=FeatureOTFCompiler,
               kernWriter=KernFeatureWriter, markWriter=MarkFeatureWriter):
    """Create FontTools CFF font from a UFO."""

    return _compile(font, glyphOrder, outlineCompilerClass,
                    featureCompilerClass, kernWriter, markWriter)


def compileTTF(font, glyphOrder=None, outlineCompilerClass=OutlineTTFCompiler,
               featureCompilerClass=FeatureOTFCompiler,
               kernWriter=KernFeatureWriter, markWriter=MarkFeatureWriter):
    """Create FontTools TrueType font from a UFO."""

    return _compile(font, glyphOrder, outlineCompilerClass,
                    featureCompilerClass, kernWriter, markWriter)

{'fraction_non_alphanumeric': 0.06804187192118226, 'fraction_numerical': 0.0024630541871921183, 'mean_word_length': 4.1571428571428575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2811368', 'n_tokens_mistral': 867, 'n_tokens_neox': 826, 'n_words': 206}