예제 #1
0
 def get_ufo(self, path):
     root, ext = os.path.splitext(path)
     ext = ext.lower()
     if ext == ".glyphs":
         return glyphsLib.load_to_ufos(path)
     elif ext == ".ufo":
         return defcon.font(path)
예제 #2
0
def test_link_metrics_to_master():
    ufos = load_to_ufos(glyphs_file_path())
    # M1 should be linked to M3
    M1 = ufos[1]
    M3 = ufos[3]
    assert M1.kerning == M3.kerning
    assert M1["A"].width == M3["A"].width
예제 #3
0
def test_link_metrics_to_first_master():
    ufos = load_to_ufos(glyphs_file_path())
    # M2 should be linked to M0
    M0 = ufos[0]
    M2 = ufos[2]
    assert M2.kerning == M0.kerning
    assert M2["A"].width == M0["A"].width
예제 #4
0
def test_ufo_with_propagated_anchors(datadir):

    ufo = glyphsLib.load_to_ufos(datadir.join("AnchorPropagation.glyphs"))[0]

    # In UFO, the same two glyphs (see above) are supposed to show anchors
    assert len(ufo["lam_alefHamzaabove-ar"].anchors) > 0
    assert len(ufo["shadda_fatha-ar"].anchors) > 0

    # Additionally, we’ll check the anchor positions and compare them with Glyphs.app’s
    # own results (hard coded) from `layer.anchorsTraversingComponents()`

    # In case of `lam_alefHamzaabove-ar` it’s crucial that the `top_2` anchor moved
    # upwards following the `hamza-ar` mark as part of the ligature base glyph

    # lam_alefHamzaabove-ar
    assert "top_2" in [x.name for x in ufo["lam_alefHamzaabove-ar"].anchors]
    for anchor in ufo["lam_alefHamzaabove-ar"].anchors:
        if anchor.name == "top_2":
            assert anchor.x == 129
            assert anchor.y == 950

    # lamHamzaabove_alefHamzaabove-ar (fictional glyph with 2x same component)
    assert "top_1" in [
        x.name for x in ufo["lamHamzaabove_alefHamzaabove-ar"].anchors
    ]
    assert "top_2" in [
        x.name for x in ufo["lamHamzaabove_alefHamzaabove-ar"].anchors
    ]
    for anchor in ufo["lamHamzaabove_alefHamzaabove-ar"].anchors:
        if anchor.name == "top_1":
            assert anchor.x == 497
            assert anchor.y == 1082
    for anchor in ufo["lamHamzaabove_alefHamzaabove-ar"].anchors:
        if anchor.name == "top_2":
            assert anchor.x == 129
            assert anchor.y == 950

    # shadda_fatha-ar
    assert "top" in [x.name for x in ufo["shadda_fatha-ar"].anchors]
    for anchor in ufo["shadda_fatha-ar"].anchors:
        if anchor.name == "top":
            assert anchor.x == 160
            assert anchor.y == 971
예제 #5
0
def test_link_metrics_to_master_missing():
    ufos = load_to_ufos(glyphs_file_path())
    # M4 should be linked to M5 which is missing, thus it has no kerning
    M4 = ufos[4]
    assert M4.kerning == {}
    assert M4["A"].width == 300