| 1 |
|
| 2 |
|
| 3 |
import sys, fontforge, psMat, math |
| 4 |
from collections import OrderedDict |
| 5 |
|
| 6 |
stroketests = sys.argv[1] |
| 7 |
shortlist = ['D', 'Q', 'asciicircum'] |
| 8 |
convex = fontforge.unitShape(7).transform(psMat.scale(25)) |
| 9 |
|
| 10 |
def do_stroke_test(short, *args, **kwargs): |
| 11 |
font=fontforge.open(stroketests) |
| 12 |
if short: |
| 13 |
font.selection.select(*shortlist) |
| 14 |
else: |
| 15 |
font.selection.all() |
| 16 |
font.stroke(*args, **kwargs) |
| 17 |
font.close() |
| 18 |
|
| 19 |
|
| 20 |
shapes = OrderedDict() |
| 21 |
shapes['triangle'] = fontforge.unitShape(3).transform(psMat.scale(25)) |
| 22 |
shapes['square'] = fontforge.unitShape(4).transform(psMat.scale(25)) |
| 23 |
shapes['pentagon'] = fontforge.unitShape(5).transform(psMat.scale(25)) |
| 24 |
shapes['circular'] = (25,) |
| 25 |
shapes['calligraphic'] = (25, 2, 45) |
| 26 |
|
| 27 |
for sn, s in shapes.items(): |
| 28 |
print(sn) |
| 29 |
if isinstance(s, tuple): |
| 30 |
do_stroke_test(False, sn, *s) |
| 31 |
else: |
| 32 |
do_stroke_test(False, 'polygonal', s) |
| 33 |
|
| 34 |
|
| 35 |
do_stroke_test(True, 'circular', 70) |
| 36 |
do_stroke_test(True, 'circular', 30, "butt", "bevel") |
| 37 |
do_stroke_test(True, 'elliptical', 30, 40, math.radians(45), "butt", "bevel") |
| 38 |
do_stroke_test(True, 'elliptical', 50, 20, math.radians(25), "butt", "miter") |
| 39 |
do_stroke_test(True, 'elliptical', 10, 100, 0, "butt", "miterclip") |
| 40 |
do_stroke_test(True, 'eliptical', 40, 42, math.radians(20), "butt", "nib") |
| 41 |
do_stroke_test(True, 'caligraphic', 30, 40, math.radians(45), "butt", "bevel") |
| 42 |
do_stroke_test(True, 'rectangular', 50, 20, math.radians(25), "nib", "miter") |
| 43 |
do_stroke_test(True, 'rectangular', 50, 20, math.radians(25), "nib", "round") |
| 44 |
do_stroke_test(True, 'rectangular', 10, 100, 0, "round", "miterclip") |
| 45 |
do_stroke_test(True, 'caligraphic', 40, 42, math.radians(20), "butt", "nib") |
| 46 |
do_stroke_test(True, 'convex', convex, math.radians(45), "butt", "bevel") |
| 47 |
do_stroke_test(True, 'polygonal', convex, math.radians(25), "nib", "miter") |
| 48 |
do_stroke_test(True, 'convex', convex, 0, "round", "miterclip") |
| 49 |
do_stroke_test(True, 'polygonal', convex, math.radians(20), "butt", "nib") |
| 50 |
|
| 51 |
do_stroke_test(True, 'calligraphic', 20, 100) |
| 52 |
do_stroke_test(True, 'calligraphic', 20, 100, angle=math.radians(30)) |
| 53 |
do_stroke_test(True, 'calligraphic', 20, 100, join="miterclip") |
| 54 |
do_stroke_test(True, 'calligraphic', 20, 100, join="bevel", cap="round") |
| 55 |
do_stroke_test(True, 'calligraphic', 20, 100, join="bevel", cap="round", removeinternal=True) |
| 56 |
do_stroke_test(True, 'calligraphic', 20, 100, join="bevel", cap="round", removeexternal=True) |
| 57 |
do_stroke_test(True, 'circular', 60, join="nib", cap="nib", extrema=False, angle=45) |
| 58 |
do_stroke_test(True, 'calligraphic', 20, 100, join="bevel", cap="round", simplify=False) |
| 59 |
do_stroke_test(True, 'calligraphic', 20, 100, join="bevel", cap="round", accuracy=3) |
| 60 |
do_stroke_test(True, 'calligraphic', 20, 100, join="bevel", cap="round", removeoverlap="contour") |
| 61 |
do_stroke_test(True, 'calligraphic', 20, 100, join="bevel", cap="round", removeoverlap="none") |
| 62 |
do_stroke_test(True, 'calligraphic', 20, 100, join="miter", cap="round", joinlimit=4) |
| 63 |
do_stroke_test(True, 'calligraphic', 20, 100, join="miterclip", cap="round", joinlimit=4) |
| 64 |
do_stroke_test(True, 'calligraphic', 20, 100, join="miterclip", cap="round", joinlimit=180, jlrelative=False) |
| 65 |
do_stroke_test(True, 'calligraphic', 20, 100, join="miterclip", cap="round", extendcap=3) |
| 66 |
do_stroke_test(True, 'calligraphic', 20, 100, join="miterclip", cap="round", extendcap=100, ecrelative=False) |
| 67 |
do_stroke_test(True, 'elliptical', 20, 20, join="arcs", cap="butt", joinlimit=4) |
| 68 |
do_stroke_test(True, 'elliptical', 20, 100, join="arcs", cap="round", joinlimit=2, arcsclip="ratio") |