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)
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" ])
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)
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)
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)
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])
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])
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])
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])
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])
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)
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])
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)
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])
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])
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
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
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])
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])
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])
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)
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])
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])
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"])
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"])
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])
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" ])
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'])
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"])
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" ])