예제 #1
0
def test_too_long_glyph_name(tmpdir):
    path = "%s/dummy/too_long_glyph_name.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    with pytest.raises(ACHintError):
        hintFiles(options)
예제 #2
0
def test_sparse_mmotf(tmpdir):
    base = "%s/sparse_masters" % DATA_DIR
    paths = sorted(glob.glob(base + "/*.otf"))
    # the reference font is modified in-place, make a temp copy first
    # MasterSet_Kanji-w0.00.otf has to be the reference font.
    reference = make_temp_copy(tmpdir, paths[0])
    inpaths = paths[1:]
    outpaths = [str(tmpdir / basename(p)) + ".out" for p in inpaths]

    options = Options(reference, inpaths, outpaths)
    options.allow_no_blues = True
    hintFiles(options)

    refs = [p + ".ref" for p in paths]
    for ref, out in zip(refs, [reference] + outpaths):
        for path in (ref, out):
            font = TTFont(path)
            assert "CFF " in font
            writer = XMLWriter(str(tmpdir / basename(path)) + ".xml")
            font["CFF "].toXML(writer, font)
            writer.close()

        assert differ([
            str(tmpdir / basename(ref)) + ".xml",
            str(tmpdir / basename(out)) + ".xml"
        ])
예제 #3
0
def test_hashmap_new_version(tmpdir, caplog):
    path = "%s/dummy/hashmap_new_version.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    with pytest.raises(FontParseError):
        hintFiles(options)
예제 #4
0
def test_missing_cff_table(tmpdir):
    path = "%s/dummy/nocff.otf" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    with pytest.raises(FontParseError):
        hintFiles(options)
예제 #5
0
def test_unsupported_format(tmpdir):
    path = "%s/dummy/fontinfo" % DATA_DIR
    out = str(tmpdir / basename(path))
    options = Options(path, out)

    with pytest.raises(FontParseError):
        hintFiles(options)
예제 #6
0
def test_hashmap_unnormalized_floats(tmpdir):
    path = "%s/dummy/hashmap_unnormalized_floats.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    hintFiles(options)

    assert differ([path, out])
예제 #7
0
def test_hashmap_transform(tmpdir):
    path = "%s/dummy/hashmap_transform.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    hintFiles(options)

    assert differ([path, out])
예제 #8
0
def test_autohintexe(tmpdir):
    path = "%s/dummy/font.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)
    options.use_autohintexe = True
    hintFiles(options)

    assert differ([path, out])
예제 #9
0
def test_hashmap_processed_no_autohint(tmpdir, caplog):
    path = "%s/dummy/hashmap_processed_no_autohint.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    hintFiles(options)

    assert not differ([path, out])
예제 #10
0
def test_flex_ufo(ufo, tmpdir):
    out = str(tmpdir / basename(ufo)) + ".out"
    options = Options(ufo, out)
    options.noFlex = False

    hintFiles(options)

    assert differ([ufo, out])
예제 #11
0
def test_ok_privatedict_accept(path, tmpdir, caplog):
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    hintFiles(options)

    msg = "There is no value or 0 value for Dominant"
    assert any(r.getMessage().startswith(msg) for r in caplog.records)
예제 #12
0
def test_big_glyph(tmpdir):
    path = "%s/dummy/big_glyph.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    hintFiles(options)

    assert differ([path, out])
예제 #13
0
def test_bad_privatedict_accept(path, tmpdir):
    """Same as above test, but PrivateDict is accepted because of
       `allow_no_blues` option."""
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)
    options.allow_no_blues = True

    hintFiles(options)
예제 #14
0
def test_ufo_write_to_default_layer(tmpdir):
    path = "%s/dummy/defaultlayer.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)
    options.writeToDefaultLayer = True
    hintFiles(options)

    assert differ([path, out])
예제 #15
0
def test_layers(tmpdir):
    path = "%s/dummy/layers.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)
    options.allow_no_blues = True

    hintFiles(options)

    assert differ([path, out])
예제 #16
0
def test_seac_op(tmpdir, caplog):
    path = "%s/dummy/seac.otf" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    hintFiles(options)

    msgs = [r.getMessage() for r in caplog.records]
    assert "Skipping Aacute: can't process SEAC composite glyphs." in msgs
예제 #17
0
def test_hashmap_glyph_changed(tmpdir, caplog):
    path = "%s/dummy/hashmap_glyph_changed.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    hintFiles(options)
    msgs = [r.getMessage() for r in caplog.records]
    assert "Glyph 'a' has been edited. You must first run 'checkOutlines' " \
           "before running 'autohint'. Skipping." in msgs
예제 #18
0
def test_decimals_ufo(tmpdir):
    path = "%s/dummy/decimals.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)
    options.round_coords = False

    hintFiles(options)

    assert differ([path, out])
예제 #19
0
def test_type1_supported(path, tmpdir):
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)
    hintFiles(options)

    path_dump = str(tmpdir / basename(path)) + ".txt"
    out_dump = str(tmpdir / basename(out)) + ".txt"
    subprocess.check_call(["tx", "-dump", "-6", path, path_dump])
    subprocess.check_call(["tx", "-dump", "-6", out, out_dump])
    assert differ([path_dump, out_dump])
예제 #20
0
def test_hashmap_dflt_layer(tmpdir):
    path = "%s/dummy/hashmap_dflt_layer.ufo" % DATA_DIR
    rslt = "%s/dummy/hashmap_dflt_layer_hinted.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)
    options.writeToDefaultLayer = True

    hintFiles(options)

    assert differ([rslt, out])
예제 #21
0
def test_incompatible_masters(tmpdir):
    base = "%s/source-serif-pro/" % DATA_DIR
    paths = [base + "Light/font.ufo", base + "Black/font.ufo"]
    # the reference font is modified in-place, make a temp copy first
    reference = make_temp_copy(tmpdir, paths[0])
    inpaths = paths[1:]
    outpaths = [str(tmpdir / p) for p in inpaths]

    options = Options(reference, inpaths, outpaths)
    with pytest.raises(ACHintError):
        hintFiles(options)
예제 #22
0
def test_hashmap_old_version(tmpdir, caplog):
    caplog.set_level(logging.INFO)
    path = "%s/dummy/hashmap_old_version.ufo" % DATA_DIR
    out = str(tmpdir / basename(path)) + ".out"
    options = Options(path, out)

    hintFiles(options)
    msgs = [r.getMessage() for r in caplog.records]
    assert "Updating hash map: was older version" in msgs

    assert not differ([path, out])
예제 #23
0
def test_mmufo(base, tmpdir):
    paths = sorted(glob.glob(base + "/*.ufo"))
    # the reference font is modified in-place, make a temp copy first
    reference = make_temp_copy(tmpdir, paths[0])
    inpaths = paths[1:]
    outpaths = [str(tmpdir / basename(p)) + ".out" for p in inpaths]

    options = Options(reference, inpaths, outpaths)
    hintFiles(options)

    for inpath, outpath in zip(inpaths, outpaths):
        assert differ([inpath, outpath])
예제 #24
0
def test_otf(otf, tmpdir):
    out = str(tmpdir / basename(otf)) + ".out"
    options = Options(otf, out)
    hintFiles(options)

    for path in (otf, out):
        font = TTFont(path)
        assert "CFF " in font
        writer = XMLWriter(str(tmpdir / basename(path)) + ".xml")
        font["CFF "].toXML(writer, font)
        writer.close()

    assert differ([str(tmpdir / basename(otf)) + ".xml",
                   str(tmpdir / basename(out)) + ".xml"])
예제 #25
0
def test_cff(cff, tmpdir):
    out = str(tmpdir / basename(cff)) + ".out"
    options = Options(cff, out)
    hintFiles(options)

    for path in (cff, out):
        font = CFFFontSet()
        writer = XMLWriter(str(tmpdir / basename(path)) + ".xml")
        with open(path, "rb") as fp:
            font.decompile(fp, None)
            font.toXML(writer)
        writer.close()

    assert differ([str(tmpdir / basename(cff)) + ".xml",
                   str(tmpdir / basename(out)) + ".xml"])
예제 #26
0
def test_mmufo(base, tmpdir):
    paths = sorted(glob.glob(base + "/*.ufo"))
    # the reference font is modified in-place, make a temp copy first
    referenceSrc = py.path.local(paths[0])
    referenceDst = tmpdir / referenceSrc.basename
    referenceSrc.copy(referenceDst)
    reference = str(referenceDst)
    inpaths = paths[1:]
    outpaths = [str(tmpdir / p) for p in inpaths]

    options = Options(reference, inpaths, outpaths)
    hintFiles(options)

    for inpath, outpath in zip(inpaths, outpaths):
        assert differ([inpath, outpath])
예제 #27
0
def test_vfotf(otf, tmpdir):
    out = str(tmpdir / basename(otf)) + ".out"
    options = Options(None, [otf], [out])
    options.allow_no_blues = True
    hintFiles(options)

    for path in (otf, out):
        font = TTFont(path)
        assert "CFF2" in font
        writer = XMLWriter(str(tmpdir / basename(path)) + ".xml")
        font["CFF2"].toXML(writer, font)
        writer.close()
    assert differ([
        str(tmpdir / basename(otf)) + ".xml",
        str(tmpdir / basename(out)) + ".xml"
    ])
예제 #28
0
def test_otf(zones, stems, all_stems, tmpdir):
    path = "%s/dummy/font.otf" % DATA_DIR
    out = str(tmpdir / basename(path))
    options = Options(path, out, zones, stems, all_stems)

    hintFiles(options)

    if zones:
        suffixes = ['.top.txt', '.bot.txt']
    else:
        suffixes = ['.hstm.txt', '.vstm.txt']

    for suffix in suffixes:
        exp_suffix = suffix
        if all_stems:
            exp_suffix = '.all' + suffix
        assert differ([path + exp_suffix, out + suffix, '-l', '1'])
예제 #29
0
def test_decimals_otf(tmpdir):
    otf = "%s/dummy/decimals.otf" % DATA_DIR
    out = str(tmpdir / basename(otf)) + ".out"
    options = Options(otf, out)
    options.round_coords = False

    hintFiles(options)

    for path in (otf, out):
        font = TTFont(path)
        assert "CFF " in font
        writer = XMLWriter(str(tmpdir / basename(path)) + ".xml")
        font["CFF "].toXML(writer, font)
        writer.close()

    assert differ([str(tmpdir / basename(otf)) + ".xml",
                   str(tmpdir / basename(out)) + ".xml"])
예제 #30
0
def test_mmotf(base, tmpdir):
    paths = sorted(glob.glob(base + "/*.otf"))
    # the reference font is modified in-place, make a temp copy first
    reference = make_temp_copy(tmpdir, paths[0])
    inpaths = paths[1:]
    outpaths = [str(tmpdir / basename(p)) + ".out" for p in inpaths]

    options = Options(reference, inpaths, outpaths)
    hintFiles(options)

    refs = [p + ".ref" for p in paths]
    for ref, out in zip(refs, [reference] + outpaths):
        for path in (ref, out):
            font = TTFont(path)
            assert "CFF " in font
            writer = XMLWriter(str(tmpdir / basename(path)) + ".xml")
            font["CFF "].toXML(writer, font)
            writer.close()

        assert differ([
            str(tmpdir / basename(ref)) + ".xml",
            str(tmpdir / basename(out)) + ".xml"
        ])