예제 #1
0
def test_angle(theta):

    a = psMat.skew(theta)
    print(theta, a)

    if not isinstance(a, tuple):
        exit(10)
    if len(a) != 6:
        exit(20)
    for element in a:
        if not isinstance(element, float):
            exit(30)
    if theta == 0:
        for i in range(0, 6):
            if eps < abs(a[i] - (1, 0, 0, 1, 0, 0)[i]):
                exit(40)
    if abs(theta - pi / 4) <= eps:
        for i in range(0, 6):
            if eps < abs(a[i] - (1, 0, 1, 1, 0, 0)[i]):
                exit(42)
    if abs(theta + pi / 4) <= eps:
        for i in range(0, 6):
            if eps < abs(a[i] - (1, 0, -1, 1, 0, 0)[i]):
                exit(42)
    if abs(theta - pi) <= eps:
        for i in range(0, 6):
            if eps < abs(a[i] - (1, 0, 0, 1, 0, 0)[i]):
                exit(44)
    for i in range(0, 6):
        if eps < abs(a[i] - (1, 0, tan(theta), 1, 0, 0)[i]):
            exit(50)
예제 #2
0
def makeSlanted(infile, outfile, feafile, version, slant):

    font = makeDesktop(infile, outfile, feafile, version, False, False)

    # compute amout of skew, magic formula copied from fontforge sources
    import math

    skew = psMat.skew(-slant * math.pi / 180.0)

    font.selection.all()
    punct = (
        "period",
        "guillemotleft",
        "guillemotright",
        "braceleft",
        "bar",
        "braceright",
        "bracketleft",
        "bracketright",
        "parenleft",
        "parenright",
        "slash",
        "backslash",
        "brokenbar",
        "uni061F",
    )

    for name in punct:
        font.selection.select(("less", None), name)

    font.transform(skew)

    # fix metadata
    font.italicangle = slant
    font.fullname += " Slanted"
    if font.weight == "Bold":
        font.fontname = font.fontname.replace("Bold", "BoldSlanted")
        font.appendSFNTName("Arabic (Egypt)", "SubFamily", "عريض مائل")
        font.appendSFNTName("English (US)", "SubFamily", "Bold Slanted")
    else:
        font.fontname = font.fontname.replace("Regular", "Slanted")
        font.appendSFNTName("Arabic (Egypt)", "SubFamily", "مائل")

    mergeLatin(font, feafile, italic=skew)

    # we want to merge features after merging the latin font because many
    # referenced glyphs are in the latin font
    mergeFeatures(font, feafile)

    generateFont(font, outfile)
예제 #3
0
def makeSlanted(infile, outfile, feafile, version, slant):

    font = makeDesktop(infile, outfile, feafile, version, False, False)

    # compute amout of skew, magic formula copied from fontforge sources
    import math
    skew = psMat.skew(-slant * math.pi / 180.0)

    # Remove Arabic math alphanumerics, they are upright-only.
    font.selection.select(["ranges"], "u1EE00", "u1EEFF")
    for glyph in font.selection.byGlyphs:
        font.removeGlyph(glyph)

    font.selection.all()
    punct = ("exclam", "period", "guillemotleft", "guillemotright",
             "braceleft", "bar", "braceright", "bracketleft", "bracketright",
             "parenleft", "parenright", "slash", "backslash", "brokenbar",
             "uni061F", "dot.1", "dot.2")

    for name in punct:
        font.selection.select(["less"], name)

    font.transform(skew)

    # fix metadata
    font.italicangle = slant
    font.fullname += " Slanted"
    if font.weight == "Bold":
        font.fontname = font.fontname.replace("Bold", "BoldSlanted")
        font.appendSFNTName("Arabic (Egypt)", "SubFamily", "عريض مائل")
        font.appendSFNTName("English (US)", "SubFamily", "Bold Slanted")
    else:
        font.fontname = font.fontname.replace("Regular", "Slanted")
        font.appendSFNTName("Arabic (Egypt)", "SubFamily", "مائل")

    mergeLatin(font, feafile, italic=skew)
    makeNumerators(font)

    # we want to merge features after merging the latin font because many
    # referenced glyphs are in the latin font
    mergeFeatures(font, feafile)

    generateFont(font, outfile)