diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /fonts/ocr-a |
Initial commit
Diffstat (limited to 'fonts/ocr-a')
-rw-r--r-- | fonts/ocr-a/ocr-a.mf | 1009 | ||||
-rw-r--r-- | fonts/ocr-a/ocr-ai.mf | 8 | ||||
-rw-r--r-- | fonts/ocr-a/ocr-aii.mf | 8 | ||||
-rw-r--r-- | fonts/ocr-a/ocr-aiii.mf | 8 | ||||
-rw-r--r-- | fonts/ocr-a/ocr-aiv.mf | 8 | ||||
-rw-r--r-- | fonts/ocr-a/ocr.mf | 2133 | ||||
-rw-r--r-- | fonts/ocr-a/ocr10.mf | 10 | ||||
-rw-r--r-- | fonts/ocr-a/ocr12.mf | 10 | ||||
-rw-r--r-- | fonts/ocr-a/ocr16.mf | 10 |
9 files changed, 3204 insertions, 0 deletions
diff --git a/fonts/ocr-a/ocr-a.mf b/fonts/ocr-a/ocr-a.mf new file mode 100644 index 0000000000..8477ca871b --- /dev/null +++ b/fonts/ocr-a/ocr-a.mf @@ -0,0 +1,1009 @@ +% OCR-A Optical Character Recognition Font +% +% Coded in METAFONT84 by Tor Lillqvist, VTT/ATK (Technical Research Centre +% of Finland, Computing Services) +% (tml@fingate.BITNET, tml@santra.UUCP, mcvax!santra!tml) +% +% Based on ISO Recommendation R1073, 1st ed., May 1969 (probably +% obsolete by now). +% +% Labels are in French :-) +% + +mode_setup; + +letter_fit# := 1.25T#; + +define_whole_pixels(W,H,L,T,letter_fit); + +def adjust_fit = + l:=-letter_fit; + interim xoffset:=-l; + charwd:=charwd+2letter_fit#; + r:=l+hround(charwd*hppp); + w:=r-letter_fit; +enddef; + +pickup pencircle scaled T; +OCRpen := savepen; + +extra_beginchar := extra_beginchar & "adjust_fit;"; + +extra_endchar := extra_endchar & "penlabels(range 1 thru 20);"; + +% The join macro performs the joining of two strokes so that the +% pen centre curvature radius is join_radius. + +tertiarydef p join q = + begingroup + pair ipq_; ipq_ := p intersectionpoint q; + + pair dirv[]; + dirv0 = dir angle direction (length p) of p; + dirv1 = dir angle direction 0 of q; + if length (dirv1 - dirv0) < 1/10: + p .. q + else: + path par[]; + k_ := if ypart (dirv1 rotated -angle dirv0) > 0: 90 else: -90 fi; + forsuffixes $=0,1: + par$ := ((ipq_ - (20join_radius*dirv$))-- + (ipq_ + (20join_radius*dirv$))) + shifted ((join_radius*dirv$) rotated k_); + endfor; + numeric pt_,qt_; + (pt_,qt_) = par0 intersectiontimes par1; + if pt_ < 0: errmessage "No intersection curvature center found"; fi + + pair icc_; icc_ = point pt_ of par0; + numeric cp_,cpp_,cq_,cqp_; + (cp_, cpp_) = p intersectiontimes + (icc_--icc_+(2join_radius*dirv0 rotated -k_)); + (cq_, cqp_) = q intersectiontimes + (icc_--icc_+(2join_radius*dirv1 rotated -k_)); + + subpath (0,cp_) of p .. + (icc_ + join_radius*unitvector(dirv0-dirv1)) .. + subpath (cq_, length q) of q + fi + endgroup +enddef; + +def fill_corners(text t) = + begingroup + forsuffixes $=t: + fill unitsquare shifted (-.5,-.5) scaled T shifted z$; + endfor + endgroup +enddef; + +% The angle_fill_corner fills the corners like in the characters M and N + +def angle_fill_corner(suffix a,b,c) = + begingroup + save p; path p.q,p.w,p.e,p.r; + p.q = (z.a--z.b+(z.b-z.a)) shifted (T/2*unitvector (z.b-z.a) rotated 90); + p.w = (z.a--z.b+(z.b-z.a)) shifted (T/2*unitvector (z.b-z.a) rotated -90); + p.e = (z.b-(z.c-z.b)--z.c) shifted (T/2*unitvector (z.c-z.b) rotated 90); + p.r = (z.b-(z.c-z.b)--z.c) shifted (T/2*unitvector (z.c-z.b) rotated -90); + + save q; pair q.u,q.l; + q.u = p.q intersectionpoint p.e; + q.l = p.w intersectionpoint p.r; + + fill point 0 of p.q -- q.u -- point 1 of p.e -- point 1 of p.r -- + q.l -- point 0 of p.w -- cycle; + endgroup +enddef; + +% The curvature radiuses used in some characters + +r1# = H#/16 * ((7H#)/(6W#) + sqrt(((7H#)/(6W#))**2 + 1)); +r2# = W#/8 * ((6W#)/(7H#) + sqrt(((6W#)/(7H#))**2 + 1)); +r3# = W#/8 * (1 - H#/(2W#) + sqrt((H#/(2W#))**2 + 1)); +r4# = H#/16 * (1 - (4W#)/(3H#) + sqrt(((4W#)/(3H#))**2 + 1)); +r5# = H#/16 * (1 - (5H#)/(6W#) + sqrt(((5H#)/(6W#))**2 + 1)); +r6# = W#/8 * (1 - (6W#)/(5H#) + sqrt(((6W#)/(5H#))**2 + 1)); + +define_pixels(r1,r2,r3,r4,r5,r6); + +def OCRchar(expr code, wd, ht) = + beginchar(code, wd, ht, 0); + pickup OCRpen; +enddef; + +OCRchar("1", W#, H#); "Chiffre UN"; + x1 = 0; y1 = 0; + x2 = W; y2 = 0; + x3 = W; y3 = 3/8H; + x4 = W/2; y4 = H; + x5 = 0; y5 = H; + + draw z1--z2--z3; draw .5[z1,z2]--z4--z5; + fill_corners(4); +endchar; + +OCRchar("2", W#, H#); "Chiffre DEUX"; + x1 = 0; y1 = H; + x2 = W; y2 = H; + x3 = W; y3 = H/2; + x4 = 0; y4 = H/2; + x5 = 0; y5 = 0; + x6 = W; y6 = 0; + + join_radius := T/2; + draw (z1--z2) join ((z2--z3) join + ((z3--z4) join (z4--z5--z6))); + fill_corners(5); +endchar; + +OCRchar("3", W#, H#); "Chiffre TROIS"; + x1 = 0; y1 = H; + x2 = W; y2 = y1; + x3 = x2; y3 = H/2; + x4 = W/4; y4 = y3; + x5 = x2; y5 = 0; + x6 = x1; y6 = y5; + + join_radius := T/2; + draw (z1--z2) join (z2--.6[z2,z3]); + join_radius := T; + draw (.4[z2,z3]--z3) join (z3--z4); + draw (z4--z3) join (z3--.6[z3,z5]); + join_radius := T/2; + draw (.4[z3,z5]--z5) join (z5--z6); +endchar; + +OCRchar("4", 7/8W#, H#); "Chiffre QUATRE"; + x1 = 0; y1 = H; + x2 = x1; y2 = 3/8H; + x3 = 7/8W; y3 = y2; + x4 = 3/4W; y4 = 0; + x5 = x4; y5 = 7/8H; + + draw z1--z2--z3; draw z4--z5; +endchar; + +OCRchar("5", W#, H#); "Chiffre CINQ"; + x1 = 0; y1 = 1/16H; + x2 = 1/4W; y2 = 0; + x3 = W; y3 = y2; + x4 = x3; y4 = 1/2H; + x5 = x2; y5 = y4; + x6 = x2; y6 = H; + x7 = x3; y7 = y6; + + join_radius := T; + draw (z1--z2) join (z2--.6[z2,z3]); + join_radius := T/2; + draw (.4[z2,z3]--z3) join (z3--.6[z3,z4]); + draw (.4[z3,z4]--z4) join (z4--z5--z6--z7); + fill_corners(5,6); +endchar; + +OCRchar("6", W#, H#); "Chiffre SIX"; + x1 = 1/8W; y1 = H; + x2 = 0; y2 = y1; + x3 = x2; y3 = 0; + x4 = W; y4 = y3; + x5 = x4; y5 = 3/8H; + x6 = x2; y6 = y5; + + draw z1--z2--z3--z4--z5--z6; +endchar; + +OCRchar("7", W#, H#); "Chiffre SEPT"; + x1 = 0; y1 = 15/16H; + x2 = x1; y2 = H; + x3 = W; y3 = y2; + x4 = x3; y4 = 5/8H; + x5 = 1/2W; y5 = 3/8H; + x6 = x5; y6 = 0; + + draw z1--z2--z3--z4--z5--z6; + fill_corners(3); +endchar; + +OCRchar("8", W#, H#); "Chiffre HUIT"; + x1 = 0; y1 = 0; + x2 = W; y2 = y1; + x3 = x2; y3 = 1/2H; + x4 = x1; y4 = y3; + x5 = 1/4W; y5 = y3; + x6 = 3/4W; y6 = y5; + x7 = x6; y7 = H; + x8 = x5; y8 = y7; + + join_radius := T/2; + draw (.4[z1,z2]--z2) join (z2--.6[z2,z3]); + draw (.4[z2,z3]--z3) join (z3--.6[z3,z4]); + draw (.4[z3,z4]--z4) join (z4--.6[z4,z1]); + draw (.4[z4,z1]--z1) join (z1--.6[z1,z2]); + draw z6--z7--z8--z5; +endchar; + +OCRchar("9", W#, H#); "Chiffre NEUF"; + x1 = 7/8W; y1 = 0; + x2 = W; y2 = y1; + x3 = x2; y3 = H; + x4 = 0; y4 = y3; + x5 = x4; y5 = 5/8H; + x6 = x2; y6 = y5; + + draw z1--z2--z3--z4--z5--z6; +endchar; + +OCRchar("0", W#, H#); "Chiffre ZERO"; + x1 = 0; y1 = 0; + x2 = W; y2 = y1; + x3 = x2; y3 = H; + x4 = x1; y4 = y3; + + join_radius := T/2; + draw (.4[z1,z2]--z2) join (z2--.6[z2,z3]); + draw (.4[z2,z3]--z3) join (z3--.6[z3,z4]); + draw (.4[z3,z4]--z4) join (z4--.6[z4,z1]); + draw (.4[z4,z1]--z1) join (z1--.6[z1,z2]); +endchar; + +OCRchar(0, W#, H#); "Symbole CROCHET"; + x1 = 0; y1 = 3/8H; + x2 = x1; y2 = 0; + x3 = 1/2W; y3 = y2; + x4 = x3; y4 = H; + x5 = W; y5 = y4; + x6 = x5; y6 = 5/8H; + + draw z1--z2--z3--z4--z5--z6; + fill_corners(2,3,4,5); +endchar; + +OCRchar(1, W#, H#); "Symbole FOURCHETTE"; + x1 = 0; y1 = H; + x2 = x1; y2 = 1/2H; + x3 = W; y3 = y2; + x4 = x3; y4 = y1; + x5 = 1/2W; y5 = y2; + x6 = x5; y6 = 0; + + draw z1--z2--z3--z4; + fill_corners(2,3); + draw z5--z6; +endchar; + +OCRchar(2, W#, H#); "Symbole CHAISE"; + x1 = 0; y1 = 0; + x2 = x1; y2 = 1/2H; + x3 = W; y3 = y2; + x4 = x3; y4 = y1; + x5 = x3; y5 = H; + + draw z1--z2--z3; + fill_corners(2); + draw z4--z5; +endchar; + +beginchar("|", 0, (H#+L#)/2, (L#-H#)/2); "Trait vertical"; + pickup OCRpen; + x1 = 0; y1 = (H-L)/2; + x2 = x1; y2 = (H+L)/2; + + cutdraw z1--z2; +endchar; + +OCRchar("A", W#, H#); "Lettre A"; + x1 = 0; y1 = 0; + x2 = 1/2W; y2 = H; + x3 = W; y3 = y1; + z4 = 1/4[z1,z2]; + z5 = 1/4[z3,z2]; + + draw z1--z2--z3; draw z4--z5; +endchar; + +OCRchar("B", W#, H#); "Lettre B"; + x1 = 0; y1 = 0; + x2 = W; y2 = y1; + x3 = x2; y3 = 1/2H; + x4 = x1; y4 = y3; + x5 = x2; y5 = H; + x6 = x1; y6 = y5; + + join_radius := 3/2T; + draw (z1--z2) join (z2--.5[z2,z3]); + draw (.5[z2,z3]--z3) join (z3--z4); + draw (z4--z3) join (z3--.5[z3,z5]); + draw (.5[z3,z5]--z5) join (z5--z6); + draw z1--z6; + fill_corners(1,6); +endchar; + +OCRchar("C", W#, H#); "Lettre C"; + x1 = W; y1 = H; + x2 = 3/8W; y2 = y1; + x3 = 0; y3 = y4 + 1/8H; + x4 = x3; y4 = 7/16H; + x5 = x2; y5 = 0; + x6 = x1; y6 = y5; + z7 = (z2--z3+(z3-z2)) intersectionpoint (z5--z4+(z4-z5)); + + join_radius := T; + draw (z1--z2) join (z2--.6[z2,z3]); + draw (z6--z5) join (z5--.6[z5,z4]); + join_radius := r1; + draw (.4[z2,z3]--z7) join (z7--.6[z4,z5]); +endchar; + +OCRchar("D", W#, H#); "Lettre D"; + x1 = 0; y1 = 0; + x2 = 1/4W; y2 = y1; + x3 = 5/8W; y3 = y1; + x4 = W; y4 = 7/16H; + x5 = x4; y5 = y4 + 1/8H; + x6 = x3; y6 = H; + x7 = x2; y7 = y6; + x8 = x1; y8 = y6; + z9 = (z3--z4+(z4-z3)) intersectionpoint (z6--z5+(z5-z6)); + + join_radius := T; + draw (z1--z3) join (z3--.6[z3,z4]); + draw (z8--z6) join (z6--.6[z6,z5]); + join_radius := r1; + draw (.4[z3,z4]--z9) join (z9--.6[z5,z6]); + draw z2--z7; +endchar; + +OCRchar("E", W#, H#); "Lettre E"; + x1 = W; y1 = 0; + x2 = 0; y2 = y1; + x3 = x2; y3 = 1/2H; + x4 = 1/2W; y4 = y3; + x5 = x2; y5 = H; + x6 = x1; y6 = y5; + + draw z1--z2--z3--z4; draw z3--z5--z6; + fill_corners(2,5); +endchar; + +OCRchar("F", W#, H#); "Lettre F"; + x1 = 0; y1 = 0; + x2 = x1; y2 = 5/8H; + x3 = 3/4W; y3 = y2; + x4 = x1; y4 = H; + x5 = W; y5 = y4; + + draw z1--z2--z3; draw z2--z4--z5; + fill_corners(4); +endchar; + +OCRchar("G", W#, H#); "Lettre G"; + x1 = 5/8W; y1 = 3/8H; + x2 = W; y2 = y1; + x3 = x2; y3 = 0; + x4 = 0; y4 = y3; + x5 = x4; y5 = 5/8H; + x6 = 1/2W; y6 = H; + x7 = x2; y7 = y6; + + join_radius := T; + draw (z1--z2--z3) join (z3--.6[z3,z4]); + draw (.4[z3,z4]--z4) join (z4--.6[z4,z5]); + join_radius := 3/2T; + draw (.4[z4,z5]--z5) join (z5--.6[z5,z6]); + join_radius := T; + draw (.4[z5,z6]--z6) join (z6--z7); + fill_corners(2); +endchar; + +OCRchar("H", W#, H#); "Lettre H"; + x1 = 0; y1 = 0; + x2 = x1; y2 = H; + x3 = W; y3 = y1; + x4 = x3; y4 = y2; + + draw z1--z2; draw z3--z4; draw .5[z1,z2]--.5[z3,z4]; +endchar; + +OCRchar("I", W#, H#); "Lettre I"; + x1 = 0; y1 = 0; + x2 = x1; y2 = H; + x3 = W; y3 = y1; + x4 = x3; y4 = y2; + + draw z1--z3; draw z2--z4; draw .5[z1,z3]--.5[z2,z4]; +endchar; + +OCRchar("J", 3/4W#, H#); "Lettre J"; + x1 = 0; y1 = 3/8H; + x2 = x1; y2 = 0; + x3 = 3/4W; y3 = y2; + x4 = x3; y4 = H; + + join_radius := T; + draw (z1--z2) join ((z2--z3) join (z3--z4)); +endchar; + +OCRchar("K", W#, H#); "Lettre K"; + x1 = 0; y1 = 0; + x2 = x1; y2 = H; + x3 = W; y3 = y1; + x4 = x3; y4 = y2; + + draw z1--z2; draw .5[z1,z2]--z3; draw .5[z1,z2]--z4; +endchar; + +OCRchar("L", W#, H#); "Lettre L"; + x1 = 0; y1 = H; + x2 = x1; y2 = 0; + x3 = W; y3 = y2; + + draw z1--z2--z3; + fill_corners(2); +endchar; + +OCRchar("M", W#, H#); "Lettre M"; + x1 = 0; y1 = 0; + x2 = x1; y2 = H; + x3 = 1/8W; y3 = y2; + x4 = 1/2W; y4 = y5+1/16H; + x5 = x4; y5 = 5/8H; + x6 = W-1/8W; y6 = y2; + x7 = W; y7 = y2; + x8 = x7; y8 = y1; + + draw z1--z2--z3--z4--z5--z4--z6--z7--z8; + fill_corners(2,7); + angle_fill_corner(2,3,4); + angle_fill_corner(4,6,7); +endchar; + +OCRchar("N", W#, H#); "Lettre N"; + x1 = 0; y1 = 0; + x2 = x1; y2 = H; + x3 = 1/8W; y3 = y2; + x4 = W-1/8W; y4 = y1; + x5 = W; y5 = y1; + x6 = x5; y6 = y2; + + draw z1--z2--z3--z4--z5--z6; + fill_corners(2,5); + angle_fill_corner(2,3,4); + angle_fill_corner(3,4,5); +endchar; + +OCRchar("O", W#, H#); "Lettre O"; + x1 = 0; y1 = 7/16H; + x2 = 3/8W; y2 = 0; + x3 = x2+1/4W; y3 = y2; + x4 = W; y4 = y1; + x5 = x4; y5 = y4+1/8H; + x6 = x3; y6 = H; + x7 = x2; y7 = y6; + x8 = x1; y8 = y5; + z10 = (z1--z2+(z2-z1)) intersectionpoint (z3+(z3-z4)--z4); + z11 = (z3--z4+(z4-z3)) intersectionpoint (z5+(z5-z6)--z6); + z12 = (z5--z6+(z6-z5)) intersectionpoint (z7+(z7-z8)--z8); + z13 = (z7--z8+(z8-z7)) intersectionpoint (z1+(z1-z2)--z2); + + join_radius := r2; + draw (.4[z13,z10]--z10) join (z10--.6[z10,z11]); + draw (.4[z11,z12]--z12) join (z12--.6[z12,z13]); + join_radius := r1; + draw (.4[z10,z11]--z11) join (z11--.6[z11,z12]); + draw (.4[z12,z13]--z13) join (z13--.6[z13,z10]); + picture O_char; O_char := currentpicture; +endchar; + +OCRchar("P", W#, H#); "Lettre P"; + x1 = 0; y1 = 0; + x2 = x1; y2 = 7/16H; + x3 = x1; y3 = H; + x4 = W; y4 = y3; + x5 = x4; y5 = y2; + + join_radius := T; + draw (z1--z3--z4) join (z4--.6[z4,z5]); + draw (.4[z4,z5]--z5) join (z5--z2); + fill_corners(3); +endchar; + +OCRchar("Q", W#, H#); "Lettre Q"; + x1 = 0; y1 = 0; + x2 = 1/4W; y2 = y1; + x3 = W; y3 = 3/8H; + x4 = x3; y4 = H; + x5 = W-1/4W; y5 = y4; + x6 = x1; y6 = 5/8H; + x7 = 1/2W; y7 = y3; + x8 = x5; y8 = y1; + x9 = x3; y9 = y1; + z10 = (z6--z1+(z1-z6)) intersectionpoint (z2-(z3-z2)--z3); + z11 = (z3--z4+(z4-z3)) intersectionpoint (z5-(z6-z5)--z6); + + join_radius := r3; + draw (.4[z6,z10]--z10) join (z10--.6[z10,z3]); + draw (.4[z3,z11]--z11) join (z11--.6[z11,z6]); + join_radius := T; + draw (.4[z2,z3]--z3) join (z3--.6[z3,z4]); + draw (.4[z5,z6]--z6) join (z6--.6[z6,z1]); + draw z7--z8--z9; + angle_fill_corner(7,8,9); +endchar; + +OCRchar("R", W#, H#); "Lettre R"; + x1 = 0; y1 = 0; + x2 = x1; y2 = 5/8H; + x3 = x1; y3 = H; + x4 = W; y4 = y3; + x5 = x4; y5 = y2; + x6 = W-5/8W; y6 = y2; + x7 = x4; y7 = y1; + + join_radius := T; + draw (z1--z3--z4) join (z4--.6[z4,z5]); + draw (.4[z4,z5]--z5) join (z5--z2); + draw z6--z7; + fill_corners(3); +endchar; + +OCRchar("S", W#, H#); "Lettre S"; + x1 = 0; y1 = 1/8H; + x2 = x1; y2 = 0; + x3 = W; y3 = y2; + x4 = x3; y4 = y1; + x5 = x1; y5 = H-1/8H; + x6 = x1; y6 = H; + x7 = x3; y7 = y6; + x8 = x3; y8 = y5; + + path p; p = z4-(z5-z4)--z5+(z5-z4); + z10 = (z2--z3+(z3-z2)) intersectionpoint p; + z11 = (z6-(z7-z6)--z7) intersectionpoint p; + + join_radius := 1/8H; + draw (z1--z2) join (z2--.6[z2,z3]); + draw (.4[z6,z7]--z7) join (z7--z8); + join_radius := r4; + draw (.4[z2,z3]--z10) join (z10--.6[z10,z11]); + draw (.4[z10,z11]--z11) join (z11--.6[z6,z7]); +endchar; + +OCRchar("T", W#, H#); "Lettre T"; + x1 = 1/2W; y1 = 0; + x2 = x1; y2 = H; + x3 = 0; y3 = H-1/8H; + x4 = x3; y4 = y2; + x5 = W; y5 = y4; + x6 = x5; y6 = y3; + + draw z1--z2; + draw z3--z4--z5--z6; + fill_corners(4,5); +endchar; + +OCRchar("U", W#, H#); "Lettre U"; + x1 = 0; y1 = H; + x2 = x1; y2 = 0; + x3 = W; y3 = y2; + x4 = x3; y4 = y1; + + join_radius := T; + draw ((z1--z2) join (z2--z3)) join (z3--z4); +endchar; + +OCRchar("V", W#, H#); "Lettre V"; + x1 = 0; y1 = H; + x2 = x1; y2 = 3/4H; + x3 = 1/2W; y3 = 0; + x4 = W; y4 = y2; + x5 = x4; y5 = y1; + + draw z1--z2--z3--z4--z5; + angle_fill_corner(1,2,3); angle_fill_corner(3,4,5); +endchar; + +OCRchar("W", W#, H#); "Lettre W"; + x1 = 0; y1 = H; + x2 = x1; y2 = 1/8H; + x3 = 1/8W; y3 = 0; + x4 = 3/8W; y4 = y3; + x5 = 1/2W; y5 = y2; + x6 = x5; y6 = 5/8H; + x7 = W-x4; y7 = y4; + x8 = W-x3; y8 = y3; + x9 = W; y9 = y2; + x10 = x9; y10 = y1; + + draw z1--z2--z3--z4--z5--z6; draw z5--z7--z8--z9--z10; + angle_fill_corner(1,2,3); angle_fill_corner(8,9,10); +endchar; + +OCRchar("X", W#, H#); "Lettre X"; + x1 = 0; y1 = H; + x2 = W; y2 = 0; + x3 = x1; y3 = y2; + x4 = x2; y4 = y1; + + draw z1--z2; draw z3--z4; +endchar; + +OCRchar("Y", W#, H#); "Lettre Y"; + x1 = 0; y1 = H; + x2 = x1; y2 = H-1/8H; + x3 = 1/2W; y3 = 1/2H; + x4 = x3; y4 = 0; + x5 = W; y5 = y2; + x6 = x5; y6 = y1; + + draw z1--z2--z3--z4; draw z3--z5--z6; + angle_fill_corner(1,2,3); angle_fill_corner(3,5,6); +endchar; + +OCRchar("Z", W#, H#); "Lettre Z"; + x1 = 0; y1 = H; + x2 = W; y2 = y1; + x3 = x1; y3 = 0; + x4 = x2; y4 = y3; + + draw z1--z2--z3--z4; + fill_corners(2,3); + unfill unitsquare shifted (-1.5,-.5) scaled T + rotated (angle (z2-z3) - 90) shifted z3; + unfill unitsquare shifted (.5,-.5) scaled T + rotated (angle (z2-z3) - 90) shifted z2; +endchar; + +OCRchar(3, W#, H#); "Lettre \AA"; + x1 = 0; y1 = 0; + x2 = 1/2W; y2 = H; + z3 = 1/4[z1,z2]; + z4 = 3/4[z1,z2]; + x5 = W; y5 = y1; + z6 = 1/4[z5,z2]; + z7 = 3/4[z5,z2]; + x8 = 1/8W; y8 = y4; + x9 = x8; y9 = y2; + x10 = 7/8W; y10 = y9; + x11 = x10; y11 = y8; + + draw z1--z4; draw z5--z7; draw z3--z6; + join_radius := T/2; + draw (.4[z8,z9]--z9) join (z9--.6[z9,z10]); + draw (.4[z9,z10]--z10) join (z10--.6[z10,z11]); + draw (.4[z10,z11]--z11) join (z11--.6[z11,z8]); + draw (.4[z11,z8]--z8) join (z8--.6[z8,z9]); +endchar; + +OCRchar(4, W#, H#); "Lettre \"&ditto&"A"; + x1 = 0; y1 = 0; + x2 = 1/2W; y2 = 3/4H; + x3 = W; y3 = y1; + z4 = 3/16[z1,z2]; + z5 = 3/16[z3,z2]; + x6 = x1; y6 = H; + x7 = x6; y7 = H-1/8H; + x8 = x3; y8 = y6; + x9 = x8; y9 = y7; + + draw z1--z2--z3; draw z4--z5; draw z6--z7; draw z8--z9; +endchar; + +OCRchar(29, W#, H#); "Lettre \AE"; + x1 = 0; y1 = 0; + x2 = 1/2W; y2 = H; + x3 = 5/8W; y3 = y2; + x4 = x3; y4 = y1; + z5 = 1/4[z1,z2]; + z6 = 1/4[z4,z3]; + x7 = W; y7 = y2; + z8 = 1/2[z4,z3]; + x9 = x7; y9 = y8; + x10 = x7; y10 = y1; + + draw z1--z2--z3--z4--z10; draw z5--z6; + draw z3--z7; draw z8--z9; +endchar; + +OCRchar(5, W#, H#); "Lettre \~N"; + x1 = 0; y1 = 0; + x2 = x1; y2 = 5/8H; + x3 = W; y3 = y1; + x4 = x3; y4 = y2; + x5 = x1; y5 = H-1/16H; + x6 = x5; y6 = H; + x7 = x3; y7 = y5; + x8 = x7; y8 = y6; + + draw z1--z2--z3--z4; + draw z5--z6--z7--z8; +endchar; + +OCRchar(31, W#, H#); "Lettre \O"; + currentpicture := O_char; + x1 = 0; y1 = 0; + x2 = W; y2 = H; + + draw z1--z2; +endchar; + +OCRchar(6, W#, H#); "Lettre \"&ditto&"O"; + x1 = 0; y1 = 5/16H; + x2 = 3/8W; y2 = 0; + x3 = x2+1/4W; y3 = y2; + x4 = W; y4 = y1; + x5 = x4; y5 = y4+1/8H; + x6 = x3; y6 = 3/4H; + x7 = x2; y7 = y6; + x8 = x1; y8 = y5; + z10 = (z1--z2+(z2-z1)) intersectionpoint (z3+(z3-z4)--z4); + z11 = (z3--z4+(z4-z3)) intersectionpoint (z5+(z5-z6)--z6); + z12 = (z5--z6+(z6-z5)) intersectionpoint (z7+(z7-z8)--z8); + z13 = (z7--z8+(z8-z7)) intersectionpoint (z1+(z1-z2)--z2); + x14 = x1; y14 = H-1/8H; + x15 = x14; y15 = H; + x16 = x4; y16 = y14; + x17 = x16; y17 = y15; + + join_radius := r6; + draw (.4[z13,z10]--z10) join (z10--.6[z10,z11]); + draw (.4[z11,z12]--z12) join (z12--.6[z12,z13]); + join_radius := r5; + draw (.4[z10,z11]--z11) join (z11--.6[z11,z12]); + draw (.4[z12,z13]--z13) join (z13--.6[z13,z10]); + draw z14--z15; draw z16--z17; +endchar; + +OCRchar(7, W#, H#); "Lettre \"&ditto&"U"; + x1 = 0; y1 = 3/4H; + x2 = x1; y2 = 0; + x3 = W; y3 = y2; + x4 = x3; y4 = y1; + x5 = 1/4W; y5 = H-1/8H; + x6 = x5; y6 = H; + x7 = x5+1/2W; y7 = y5; + x8 = x7; y8 = y6; + + join_radius := T; + draw (z1--z2) join (z2--.6[z2,z3]); + draw (.4[z2,z3]--z3) join (z3--z4); + draw z5--z6; draw z7--z8; +endchar; + +OCRchar(".", 1/4W#, 3/16H#+1/8H#); "Point"; + x1 = 0; y1 = 3/16H; + x2 = 1/4W; y2 = y1; + x3 = x2; y3 = y1+1/8H; + x4 = x1; y4 = y3; + + draw z1--z2--z3--z4--cycle; +endchar; + +OCRchar(",", 1/2W#, 3/8H#); "Virgule"; + x1 = 0; y1 = 3/8H; + x2 = 1/2W; y2 = y1; + x3 = x2; y3 = 0; + + draw z1--z2--z3; +endchar; + +OCRchar(":", 1/4W#, 3/16H#+1/8H#+3/8H#+1/8H#); "Deux points"; + x1 = 0; y1 = 3/16H; + x2 = 1/4W; y2 = y1; + x3 = x2; y3 = y2+1/8H; + x4 = x1; y4 = y3; + x5 = x1; y5 = y4+3/8H; + x6 = x2; y6 = y5; + x7 = x6; y7 = y6+1/8H; + x8 = x5; y8 = y7; + + draw z1--z2--z3--z4--cycle; + draw z5--z6--z7--z8--cycle; +endchar; + +OCRchar(";", 1/2W#, 7/8H#); "Point virgule"; + x1 = 0; y1 = 3/8H; + x2 = 1/2W; y2 = y1; + x3 = x2; y3 = 0; + x4 = x1; y4 = 3/4H; + x5 = 1/4W; y5 = y4; + x6 = x5; y6 = 7/8H; + x7 = x4; y7 = y6; + + draw z1--z2--z3; + draw z4--z5--z6--z7--cycle; +endchar; + +OCRchar("=", W#, 3/8H#+5/16H#); "Egale"; + x1 = 0; y1 = 3/8H; + x2 = W; y2 = y1; + x3 = x1; y3 = y1+5/16H; + x4 = x2; y4 = y3; + + draw z1--z2; draw z3--z4; +endchar; + +OCRchar("+", W#, 1/2H#-1/2W#+W#); "Plus"; + x1 = 0; y1 = 1/2H; + x2 = W; y2 = y1; + x3 = 1/2W; y3 = 1/2H-1/2W; + x4 = x3; y4 = y3+W; + + draw z1--z2; draw z3--z4; +endchar; + +OCRchar("/", W#, H#); "Barre oblique"; + x1 = 0; y1 = 0; + x2 = W; y2 = H; + + draw z1--z2; +endchar; + +OCRchar("*", W#, 1/8H#+3/4H#); "Ast\'erisque"; + x1 = 0; y1 = 1/4H; + x2 = 1/2W; y2 = 1/8H; + x3 = W; y3 = y1; + x4 = x3; y4 = 3/4H; + x5 = x2; y5 = y2+3/4H; + x6 = x1; y6 = y4; + + draw z1--z4; draw z2--z5; draw z3--z6; +endchar; + +OCRchar(ditto, W#, H#); "Guillemet"; + x1 = 0; y1 = H; + x2 = 1/8W; y2 = 5/8H; + x3 = 1/4W; y3 = y1; + x4 = 3/4W; y4 = y1; + x5 = x4+1/8W; y5 = y2; + x6 = W; y6 = y1; + + draw z3--z1--z2--z3--z4--z5--z6--z4; + fill_corners(1,6); + unfill unitsquare shifted (-1.5,-.5) rotated (angle (z1-z2) - 90) + scaled T shifted z1; + unfill unitsquare shifted (1.5,-.5) rotated (90 - angle (z6-z5)) + scaled T shifted z6; +endchar; + +OCRchar("{", W#, H#); "Parenth\`ese gauche"; + x1 = 0; y1 = 1/2H; + x2 = 1/2W; y2 = y1; + x3 = x2; y3 = 0; + x4 = W; y4 = y3; + x5 = x2; y5 = H; + x6 = x4; y6 = y5; + + join_radius := T; + draw (z1--z2) join (z2--.6[z2,z3]); + draw (z1--z2) join (z2--.6[z2,z5]); + join_radius := 1/2T; + draw (.4[z2,z3]--z3) join (z3--z4); + draw (.4[z2,z5]--z5) join (z5--z6); +endchar; + +OCRchar("}", W#, H#); "Parenth\`ese droite"; + x1 = W; y1 = 1/2H; + x2 = 1/2W; y2 = y1; + x3 = x2; y3 = 0; + x4 = 0; y4 = y3; + x5 = x2; y5 = H; + x6 = x4; y6 = y5; + + join_radius := T; + draw (z1--z2) join (z2--.6[z2,z3]); + draw (z1--z2) join (z2--.6[z2,z5]); + join_radius := 1/2T; + draw (.4[z2,z3]--z3) join (z3--z4); + draw (.4[z2,z5]--z5) join (z5--z6); +endchar; + +OCRchar("%", W#, H#); "Pour cent"; + x1 = 0; y1 = 1/8H; + x2 = W; y2 = y1+3/4H; + x3 = x1; y3 = y2; + x4 = x3+1/4W; y4 = y3; + x5 = x4; y5 = H; + x6 = x3; y6 = y5; + x7 = x2-1/4W; y7 = 0; + x8 = x2; y8 = y7; + x9 = x8; y9 = y1; + x10 = x7; y10 = y9; + + draw z1--z2; + draw z3--z4--z5--z6--cycle; + draw z7--z8--z9--z10--cycle; +endchar; + +OCRchar("?", W#, H#); "Point d' interrogation"; + x1 = 0; y1 = H-3/8H; + x2 = W-1/4W; y2 = H; + x3 = W; y3 = H-1/8H; + x4 = x3; y4 = 3/4H; + x5 = 1/4W; y5 = y6+1/8H; + x6 = x5; y6 = 1/4H; + x7 = x5; y7 = 0; + + draw z1--z2--z3--z4--z5--z6; drawdot z7; +endchar; + +OCRchar("&", W#, 7/8H#); "Perlu\`ete"; + x1 = W; y1 = 0; + x2 = 0; y2 = y6+3/8H; + x3 = x2; y3 = 7/8H; + x4 = 3/4W; y4 = y3; + x5 = x4; y5 = y2; + x6 = x2; y6 = 1/4H; + x7 = x2; y7 = y1; + x8 = 1/2W; y8 = y1; + x9 = x1; y9 = y6; + + join_radius := T; + draw (z1--z2--z3) join (z3--.6[z3,z4]); + draw (.4[z3,z4]--z4) join (z4--z5); + draw (z5--z6--z7) join (z7--z8--z9); +endchar; + +OCRchar("'", 1/4W#, H#); "Apostrophe"; + x1 = 0; y1 = H; + x2 = 1/8W; y2 = 5/8H; + x3 = 1/4W; y3 = y1; + + draw z1--z2--z3--cycle; +endchar; + +OCRchar("-", W#, 1/2H#); "Moins, trait d'union"; + x1 = 0; y1 = 1/2H; + x2 = W; y2 = y1; + + draw z1--z2; +endchar; + +OCRchar("$", W#, H#); "Symbole dollar"; + x1 = 0; y1 = 1/4H; + x2 = W; y2 = y1; + x3 = x2; y3 = 1/2H; + x4 = x1; y4 = y3; + x5 = x1; y5 = y4+1/4H; + x6 = x2; y6 = y5; + x7 = 1/2W; y7 = 0; + x8 = x7; y8 = y1; + x9 = x7; y9 = y5; + x10 = x7; y10 = H; + + draw z1--z2--z3--z4--z5--z6; draw z7--z8; draw z9--z10; +endchar; + +OCRchar(8, W#, H#); "Symbole livre"; + x1 = 0; y1 = 0; + x2 = W; y2 = y1; + x3 = 1/4W; y3 = y1; + x4 = x2-1/4W; y4 = H; + x5 = x2; y5 = y4; + x6 = x1; y6 = 1/2H; + x7 = x2; y7 = y6; + + join_radius := T; + draw z1--z2; draw (z3--z4) join (z4--z5); draw z6--z7; +endchar; + +OCRchar(9, W#, H#); "Symbole yen"; + x1 = 0; y1 = H; + x2 = 1/2W; y2 = 1/2H; + x3 = W; y3 = y1; + x4 = x2; y4 = 0; + x5 = x1; y5 = 3/8H; + x6 = x3; y6 = y5; + + draw z1--z2--z3; draw z2--z4; draw z5--z6; +endchar; + +designsize := L#; + +font_slant := 0; +font_quad := 2W#; +font_normal_space := W#; +font_normal_stretch := .5W#; +font_normal_shrink := .4W#; +font_xheight := H#; + +end. diff --git a/fonts/ocr-a/ocr-ai.mf b/fonts/ocr-a/ocr-ai.mf new file mode 100644 index 0000000000..169c37f7d7 --- /dev/null +++ b/fonts/ocr-a/ocr-ai.mf @@ -0,0 +1,8 @@ +% OCR-A Size I + +H# = 2.4mm#; +W# = 1.4mm#; +T# = .35mm#; +L# = 3.73mm#; + +input OCR-A; diff --git a/fonts/ocr-a/ocr-aii.mf b/fonts/ocr-a/ocr-aii.mf new file mode 100644 index 0000000000..32e48f4bf8 --- /dev/null +++ b/fonts/ocr-a/ocr-aii.mf @@ -0,0 +1,8 @@ +% OCR-A Size II + +H# = 2.84mm#; +W# = 1.4mm#; +T# = .35mm#; +L# = 4.42mm#; + +input OCR-A; diff --git a/fonts/ocr-a/ocr-aiii.mf b/fonts/ocr-a/ocr-aiii.mf new file mode 100644 index 0000000000..33df84c7db --- /dev/null +++ b/fonts/ocr-a/ocr-aiii.mf @@ -0,0 +1,8 @@ +% OCR-A Size III + +H# = 3.20mm#; +W# = 1.52mm#; +T# = .38mm#; +L# = 4.98mm#; + +input OCR-A; diff --git a/fonts/ocr-a/ocr-aiv.mf b/fonts/ocr-a/ocr-aiv.mf new file mode 100644 index 0000000000..737ab41d95 --- /dev/null +++ b/fonts/ocr-a/ocr-aiv.mf @@ -0,0 +1,8 @@ +% OCR-A Size IV + +H# = 3.80mm#; +W# = 2.04mm#; +T# = .51mm#; +L# = 5.91mm#; + +input OCR-A; diff --git a/fonts/ocr-a/ocr.mf b/fonts/ocr-a/ocr.mf new file mode 100644 index 0000000000..373e9c3838 --- /dev/null +++ b/fonts/ocr-a/ocr.mf @@ -0,0 +1,2133 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% METAFONT-84 Definition for OCR-A Optical Character Recognition Font +% (C) Copyright 1988, 1989 Richard B. Wales. All Rights Reserved. +% +% Coded by: +% +% Richard B. Wales +% Computer Science Department +% University of California, Los Angeles (UCLA) +% Los Angeles, California 90024-1596 (USA) +% +1 (213) 825-5683 +% wales@CS.UCLA.EDU +% +% Source of information: +% +% ANSI Standard X3.17-1977 (approved January 20, 1977, by the +% American National Standards Institute, Inc.) +% +% Based on an earlier version by: +% +% Tor Lillqvist +% Computing Services +% Technical Research Centre of Finland +% TML@FINGATE.BITNET; mcvax!santra!tml +% +% Terms of copyright: +% +% You may do anything you wish with this font definition, as +% long as you retain the original copyright notice and credit +% information intact in the source, and do not charge any fee +% for distribution of either the source or any fonts derived +% from it beyond a reasonable copying or communications charge. +% +% Disclaimer: +% +% While I have made every reasonable effort to make this font +% definition correspond to the specifications in ANSI Standard +% X3.17-1977, I do not guarantee that it conforms fully to all +% official requirements for the OCR-A font, nor that the char- +% acters produced from this definition will be usable by any +% particular OCR hardware and/or software. It is the respon- +% sibility of the user to determine the usability of this font +% definition for his application. Use of this font definition +% is totally at the user's own risk and without any warranty +% whatsoever, express or implied. Neither the author nor his +% employer will be responsible for any damages, including +% secondary or consequential damages, arising out of the use of +% this font definition. +% +% The four ASCII characters "Tilde", "Underline", "Grave Accent", +% and "Vertical Bar" do not appear as part of ANSI X3.17-1977. +% In order to make a complete ASCII character set, I supplemented +% the standard with my own designs for these four characters. +% Since these characters are not part of any standard, they will +% presumably *NOT* be readable by any existing OCR-A equipment. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Much of the following material is copied essentially intact from +% Lillqvist's work; specifically, the "join", "fill_corners", and +% "angle_fill_corner" routines. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% +% Miscellaneous stuff. +% +mode_setup; +% letter_fit# := 1.25T#; +letter_fit# := 0; +define_whole_pixels (W, H, L, T, Y, R, letter_fit); % round off +theta := (2*94/55)*(W/H); % 2-degree angle for some small letters +def adjust_fit = + l := -letter_fit; + interim xoffset := -l; + charwd := charwd + 2letter_fit#; + r := l + hround (charwd*hppp); + w := r - letter_fit; +enddef; +extra_beginchar := extra_beginchar & "adjust_fit;"; +extra_endchar := extra_endchar & "penlabels (range 1 thru 20);"; + + +% +% Curvature radii defined in ANSI X3.17 for various characters. +% +r1# = H#/16 * ((7H#)/(6W#) + sqrt(((7H#)/(6W#))**2 + 1)); +r2# = W#/8 * ((6W#)/(7H#) + sqrt(((6W#)/(7H#))**2 + 1)); +r3# = W#/8 * (1 - H#/(2W#) + sqrt((H#/(2W#))**2 + 1)); +r4# = H#/16 * (1 - (4W#)/(3H#) + sqrt(((4W#)/(3H#))**2 + 1)); +r5# = H#/16 * (1 - (5H#)/(6W#) + sqrt(((5H#)/(6W#))**2 + 1)); +r6# = W#/8 * (1 - (6W#)/(5H#) + sqrt(((6W#)/(5H#))**2 + 1)); +define_pixels (r1, r2, r3, r4, r5, r6); + + +% +% ocrpen: +% A circular pen of diameter T; used for virtually all characters. +% +pickup pencircle scaled T; +ocrpen := savepen; + + +% +% "ocrchar" macro: +% Used at the start of almost every character definition. Note +% that the point "z0" is the lower left-hand corner of most char- +% acters. The height of the bounding box is equal to the full +% height of the character (including stroke thickness), and the +% characters are all centered left-to-right within the box. This +% requires all character point definitions to be stated relative +% to the point "z0". +% +def ocrchar (expr code) = + beginchar (code, R#, H#+T#, 0); + pickup ocrpen; + join_radius := T/2; + z0 = ((R-W)/2, T/2); +enddef; + + +% +% "join" operator: +% Joins two strokes so that the pen center curvature radius +% is "join_radius". ("join_radius" must already be defined.) +% +tertiarydef p join q = + begingroup + % "ipq_" is the point where the paths "p" and "q" would cross. + pair ipq_; + ipq_ := p intersectionpoint q; + + % "dirv0" is the angular direction at the end of "p"; + % "dirv1" is the angular direction at the start of "q". + pair dirv[]; + dirv0 = dir angle direction (length p) of p; + dirv1 = dir angle direction 0 of q; + + % If the directions of "p" and "q" are close enough, + % just connect the paths without any fancy stuff. + if length (dirv1 - dirv0) < 1/10: + p .. q + + % Otherwise, compute a joining of the required curvature. + else: + path par[]; + k_ := if ypart (dirv1 rotated -angle dirv0) > 0: + 90 else: -90 fi; + forsuffixes $=0, 1: + par$ := ((ipq_ - (20join_radius*dirv$))-- + (ipq_ + (20join_radius*dirv$))) + shifted ((join_radius*dirv$) rotated k_); + endfor; + numeric pt_, qt_; + (pt_, qt_) = par0 intersectiontimes par1; + if pt_ < 0: + errmessage "No intersection curvature center found"; + fi + pair icc_; icc_ = point pt_ of par0; + numeric cp_, cpp_, cq_, cqp_; + (cp_, cpp_) = p intersectiontimes + (icc_--icc_+(2join_radius*dirv0 rotated -k_)); + (cq_, cqp_) = q intersectiontimes + (icc_--icc_+(2join_radius*dirv1 rotated -k_)); + subpath (0, cp_) of p .. + (icc_ + join_radius*unitvector(dirv0-dirv1)) .. + subpath (cq_, length q) of q + fi + endgroup +enddef; + + +% +% "fill_corners" macro: +% Fills in one or more corners to be sharp right-angle bends. +% +def fill_corners (text t) = + begingroup + forsuffixes $=t: + fill unitsquare shifted (-.5, -.5) scaled T shifted z$; + endfor + endgroup +enddef; + + +% +% "angle_fill_corners" macro: +% Fills in a corner to be a sharp bend, but not a right angle. +% The parameters are three points that define the angle, with +% the corner specified second. +% +def angle_fill_corner (suffix a, b, c) = + begingroup + save p; + path p.q, p.w, p.e, p.r; + p.q = (z.a--z.b+(z.b-z.a)) + shifted (T/2*unitvector (z.b-z.a) rotated 90); + p.w = (z.a--z.b+(z.b-z.a)) + shifted (T/2*unitvector (z.b-z.a) rotated -90); + p.e = (z.b-(z.c-z.b)--z.c) + shifted (T/2*unitvector (z.c-z.b) rotated 90); + p.r = (z.b-(z.c-z.b)--z.c) + shifted (T/2*unitvector (z.c-z.b) rotated -90); + + save q; + pair q.u, q.l; + q.u = p.q intersectionpoint p.e; + q.l = p.w intersectionpoint p.r; + + fill point 0 of p.q -- q.u -- point 1 of p.e -- + point 1 of p.r -- q.l -- point 0 of p.w -- cycle; + endgroup +enddef; + + +% +% "to_mid" macro: +% Defines a path starting at the first point and continuing to +% a point between the two points (slightly past the middle). +% +def to_mid (expr a, b) = + (a -- .6[a,b]) +enddef; + + +% +% "from_mid" macro: +% Defines a path starting between two points (slightly before the +% middle) and continuing to the second point. +% +def from_mid (expr a, b) = + (.4[a,b] -- b) +enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% CHARACTER DEFINITIONS % +% % +% For debugging purposes, you may wish to remove the initial "%%%" % +% from the "def" and "enddef" lines below. This will allow you to % +% invoke the character definitions one at a time (e.g., to inspect % +% them on a bit-mapped display). % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Digits. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%% def draw_zero = + ocrchar ("0"); "Number ZERO"; + z1 = (x0, y0); z2 = (x0+W, y1); + z3 = (x2, y0+H); z4 = (x1, y3); + + draw from_mid (z1, z2) + join (z2 -- z3) + join to_mid (z3, z4); + draw from_mid (z3, z4) + join (z4 -- z1) + join to_mid (z1, z2); + endchar; +%%% enddef; + + +%%% def draw_one = + ocrchar ("1"); "Number ONE"; + z1 = (x0, y0); z2 = (x0+W, y1); z3 = (x2, y0+3/8H); + z4 = .5[z1,z2]; z5 = (x4, y0+H); z6 = (x1, y5); + + draw z1 -- z2 -- z3; + draw z4 -- z5 -- z6; + fill_corners (5); + endchar; +%%% enddef; + + +%%% def draw_two = + ocrchar ("2"); "Number TWO"; + z1 = (x0+W, y0); z2 = (x0, y1); z3 = (x2, y0+1/2H); + z4 = (x1, y3); z5 = (x1, y0+H); z6 = (x2, y5); + + draw (z1 -- z2 -- z3) + join (z3 -- z4) + join (z4 -- z5) + join (z5 -- z6); + fill_corners (2); + endchar; +%%% enddef; + + +%%% def draw_three = + ocrchar ("3"); "Number THREE"; + z1 = (x0, y0); z2 = (x0+W, y1); z3 = (x2, y0+1/2H); + z4 = (x0+1/4W, y3); z5 = (x0+W, y0+H); z6 = (x0, y5); + + draw (z1 -- z2) + join to_mid (z2, z3); + draw from_mid (z3, z5) + join (z5 -- z6); + join_radius := T; + draw from_mid (z2, z3) + join (z3 -- z4); + draw (z4 -- z3) + join to_mid (z3,z5); + endchar; +%%% enddef; + + +%%% def draw_four = + ocrchar ("4"); "Number FOUR"; + z1 = (x0+13/16W, y0); z2 = (x1, y0+7/8H); + z3 = (x0+15/16W, y0+3/8H); z4 = (x0+1/16W, y3); z5 = (x4, y0+H); + + draw z1 -- z2; + draw z3 -- z4 -- z5; + fill_corners (4); + endchar; +%%% enddef; + + +%%% def draw_five = + ocrchar ("5"); "Number FIVE"; + z1 = (x0+W, y0+H); z2 = (x0+1/4W, y1); z3 = (x2, y0+1/2H); + z4 = (x1, y3); z5 = (x1, y0); + z6 = (x0+1/4W, y5); z7 = (x0, y0+1/16H); + + draw z1 -- z2 -- to_mid (z3, z4); + draw from_mid (z3, z4) + join (z4 -- z5) + join to_mid (z5, z6); + join_radius := T; + draw from_mid (z5, z6) + join (z6 -- z7); + fill_corners (2, 3); + endchar; +%%% enddef; + + +%%% def draw_six = + ocrchar ("6"); "Number SIX"; + z1 = (x0+1/8W, y0+H); z2 = (x0, y0+H); z3 = (x0, y0); + z4 = (x0+W, y0); z5 = (x0+W, y0+3/8H); z6 = (x0, y5); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_seven = + ocrchar ("7"); "Number SEVEN"; + z1 = (x0, y0+15/16H); z2 = (x0, y0+H); z3 = (x0+W, y0+H); + z4 = (x0+W, y0+5/8H); z5 = (x0+1/2W, y0+3/8H); z6 = (x5, y0); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + fill_corners (3); + endchar; +%%% enddef; + + +%%% def draw_eight = + ocrchar ("8"); "Number EIGHT"; + z1 = (x0+1/4W, y0+1/2H); z2 = (x1, y0+H); + z3 = (x0+3/4W, y0+H); z4 = (x3, y1); + z5 = (x0, y0+1/2H); z6 = (x0+W, y5); + z7 = (x0+W, y0); z8 = (x0, y0); + + draw z1 -- z2 -- z3 -- z4; + draw from_mid (z5, z6) + join (z6 -- z7) + join to_mid (z7, z8); + draw from_mid (z7,z8) + join (z8 -- z5) + join to_mid (z5, z6); + endchar; +%%% enddef; + + +%%% def draw_nine = + ocrchar ("9"); "Number NINE"; + z1 = (x0+7/8W, y0); z2 = (x0+W, y0); z3 = (x0+W, y0+H); + z4 = (x0, y0+H); z5 = (x0, y0+5/8H); z6 = (x0+W, y5); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + endchar; +%%% enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Upper-case letters. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%% def draw_a = + ocrchar ("A"); "Letter A"; + z1 = (x0, y0); z2 = (x0+1/2W, y0+H); z3 = (x0+W, y0); + z4 = 1/4[z1,z2]; z5 = 1/4[z3,z2]; + + draw z1 -- z2 -- z3; + draw z4 -- z5; + endchar; +%%% enddef; + + +%%% def draw_b = + ocrchar ("B"); "Letter B"; + z1 = (x0, y0); z2 = (x0+W, y0); z3 = (x0+W, y0+1/2H); + z4 = (x0, y3); z5 = (x0+W, y0+H); z6 = (x0, y0+H); + + join_radius := 3/2T; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4); + draw (z6 -- z5) + join (z5 -- z3) + join (z3 -- z4); + draw z1 -- z6; + fill_corners (1, 6); + endchar; +%%% enddef; + + +%%% def draw_c = + ocrchar ("C"); "Letter C"; + z1 = (x0+W, y0); z2 = (x0+3/8W, y0); z3 = (x0, y0+7/16H); + z4 = (x1, y0+H); z5 = (x2, y0+H); z6 = (x3, y0+9/16H); + + join_radius := T; + draw (z1 -- z2) + join to_mid (z2, z3); + draw (z4 -- z5) + join to_mid (z5, z6); + join_radius := r1; + draw from_mid (z2, z3) + join (z3 -- z6) + join to_mid (z6, z5); + endchar; +%%% enddef; + + +%%% def draw_d = + ocrchar ("D"); "Letter D"; + z1 = (x0, y0); z2 = (x0+5/8W, y0); z3 = (x0+W, y0+7/16H); + z4 = (x1, y0+H); z5 = (x2, y0+H); z6 = (x3, y0+9/16H); + z7 = (x0+1/4W, y0); z8 = (x7, y0+H); + + join_radius := T; + draw (z1 -- z2) + join to_mid (z2, z3); + draw (z4 -- z5) + join to_mid (z5, z6); + join_radius := r1; + draw from_mid (z2, z3) + join (z3 -- z6) + join to_mid (z6, z5); + draw z7 -- z8; + endchar; +%%% enddef; + + +%%% def draw_e = + ocrchar ("E"); "Letter E"; + z1 = (x0+W, y0); z2 = (x0, y0); + z3 = (x0, y0+H); z4 = (x0+W, y0+H); + z5 = (x0, y0+1/2H); z6 = (x0+1/2W, y5); + + draw z1 -- z2 -- z3 -- z4; + draw z5 -- z6; + fill_corners (2, 3); + endchar; +%%% enddef; + + +%%% def draw_f = + ocrchar ("F"); "Letter F"; + z1 = (x0, y0); z2 = (x0, y0+H); z3 = (x0+W, y0+H); + z4 = (x0, y0+5/8H); z5 = (x0+3/4W, y4); + + draw z1 -- z2 -- z3; + draw z4 -- z5; + fill_corners (2); + endchar; +%%% enddef; + + +%%% def draw_g = + ocrchar ("G"); "Letter G"; + z1 = (x0+W, y0+H); z2 = (x0+1/2W, y0+H); z3 = (x0, y0+5/8H); + z4 = (x0, y0); z5 = (x0+W, y0); + z6 = (x0+W, y0+3/8H); z7 = (x0+5/8W, y6); + + join_radius := T; + draw (z1 -- z2) + join to_mid (z2, z3); + draw from_mid (z3, z4) + join (z4 -- z5) + join (z5 -- z6) + -- z7; + join_radius := 3/2T; + draw from_mid (z2, z3) + join to_mid (z3, z4); + fill_corners (6); + endchar; +%%% enddef; + + +%%% def draw_h = + ocrchar ("H"); "Letter H"; + z1 = (x0, y0); z2 = (x0, y0+H); + z3 = (x0+W, y0); z4 = (x0+W, y0+H); + z5 = (x0, y0+1/2H); z6 = (x0+W, y5); + + draw z1 -- z2; + draw z3 -- z4; + draw z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_i = + ocrchar ("I"); "Letter I"; + z1 = (x0+1/2W, y0); z2 = (x1, y0+H); + z3 = (x0, y0); z4 = (x0+W, y0); + z5 = (x0, y0+H); z6 = (x0+W, y0+H); + + draw z1 -- z2; + draw z3 -- z4; + draw z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_j = + ocrchar ("J"); "Letter J"; + z1 = (x0+7/8W, y0+H); z2 = (x1, y0); + z3 = (x0+1/8W, y0); z4 = (x3, y0+3/8H); + + join_radius := T; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4); + endchar; +%%% enddef; + + +%%% def draw_k = + ocrchar ("K"); "Letter K"; + z1 = (x0, y0+H); z2 = (x0, y0); + z3 = (x0+W, y0+H); z4 = (x0, y0+1/2H); z5 = (x0+W, y0); + + draw z1 -- z2; + draw z3 -- z4 -- z5; + endchar; +%%% enddef; + + +%%% def draw_l = + ocrchar ("L"); "Letter L"; + z1 = (x0, y0+H); z2 = (x0, y0); z3 = (x0+W, y0); + + draw z1 -- z2 -- z3; + fill_corners (2); + endchar; +%%% enddef; + + +%%% def draw_m = + ocrchar ("M"); "Letter M"; + z1 = (x0, y0); z2 = (x0, y0+H); z3 = (x0+1/8W, y0+H); + z4 = (x0+7/8W, y0+H); z5 = (x0+W, y0+H); z6 = (x0+W, y0); + z7 = (x0+1/2W, y0+11/16H); z8 = (x7, y0+5/8H); + + draw z1 -- z2 -- z3 -- z7 -- z4 -- z5 -- z6; + draw z7 -- z8; + fill_corners (2, 5); + angle_fill_corner (2, 3, 7); + angle_fill_corner (7, 4, 5); + endchar; +%%% enddef; + + +%%% def draw_n = + ocrchar ("N"); "Letter N"; + z1 = (x0, y0); z2 = (x0, y0+H); z3 = (x0+1/8W, y0+H); + z4 = (x0+7/8W, y0); z5 = (x0+W, y0); z6 = (x0+W, y0+H); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + fill_corners (2, 5); + angle_fill_corner (2, 3, 4); + angle_fill_corner (3, 4, 5); + endchar; +%%% enddef; + + +%%% def draw_o = + ocrchar ("O"); "Letter O"; + z1 = (x0, y0+7/16H); z2 = (x1, y0+9/16H); + z3 = (x0+3/8W, y0+H); z4 = (x0+5/8W, y3); + z5 = (x0+W, y2); z6 = (x5, y1); + z7 = (x4, y0); z8 = (x3, y7); + + join_radius := r1; + draw from_mid (z8, z1) + join (z1 -- z2) + join to_mid (z2, z3); + draw from_mid (z4, z5) + join (z5 -- z6) + join to_mid (z6, z7); + join_radius := r2; + draw from_mid (z2, z3) + join (z3 -- z4) + join to_mid (z4, z5); + draw from_mid (z6, z7) + join (z7 -- z8) + join to_mid (z8, z1); + endchar; +%%% enddef; + + +%%% def draw_p = + ocrchar ("P"); "Letter P"; + z1 = (x0, y0); z2 = (x0, y0+H); + z3 = (x0+W, y2); z4 = (x3, y0+7/16H); + z5 = (x0, y4); + + join_radius := T; + draw z1 -- z2 -- to_mid (z2, z3); + draw from_mid (z2, z3) + join (z3 -- z4) + join (z4 -- z5); + fill_corners (2); + endchar; +%%% enddef; + + +%%% def draw_q = + ocrchar ("Q"); "Letter Q"; + z1 = (x0+1/4W, y0); z1a = (x0, y0); z2 = (x0, y0+5/8H); + z3 = (x0+3/4W, y0+H); z3a = (x0+W, y3); z4 = (x3a, y0+3/8H); + z5 = (x0+1/2W, y4); z6 = (x3, y0); z7 = (x4, y0); + + join_radius := 3/2T; + draw from_mid (z1a, z2) + join to_mid (z2, z3); + draw from_mid (z3a, z4) + join to_mid (z4, z1); + join_radius := r3; + draw from_mid (z2, z3) + join (z3 -- z3a) + join to_mid (z3a, z4); + draw from_mid (z4, z1) + join (z1 -- z1a) + join to_mid (z1a, z2); + draw z5 -- z6 -- z7; + angle_fill_corner (5, 6, 7); + endchar; +%%% enddef; + + +%%% def draw_r = + ocrchar ("R"); "Letter R"; + z1 = (x0, y0); z2 = (x0, y0+H); + z3 = (x0+W, y2); z4 = (x3, y0+5/8H); z5 = (x0, y4); + z6 = (x0+3/8W, y4); z7 = (x3, y1); + + join_radius := T; + draw z1 -- z2 -- to_mid (z2, z3); + draw from_mid (z2, z3) + join (z3 -- z4) + join (z4 -- z5); + draw z6 -- z7; + fill_corners (2); + endchar; +%%% enddef; + + +%%% def draw_s = + ocrchar ("S"); "Letter S"; + z1 = (x0, y0+1/8H); z1a = (x1, y0); + z1b = (x0+W, y1a); z2 = (x1b, y1); + z3 = (x1b, y0+7/8H); z3a = (x3, y0+H); + z3b = (x0, y3a); z4 = (x3b, y3); + + join_radius := 1/8H; + draw (z1 -- z1a) + join to_mid (z1a, z1b); + draw (z3 -- z3a) + join to_mid (z3a, z3b); + join_radius := r4; + draw from_mid (z1a, z1b) + join (z1b -- z2) + join (z2 -- z4) + join (z4 -- z3b) + join to_mid (z3b, z3a); + endchar; +%%% enddef; + + +%%% def draw_t = + ocrchar ("T"); "Letter T"; + z1 = (x0, y0+7/8H); z2 = (x1, y0+H); + z3 = (x0+W, y2); z4 = (x3, y1); + z5 = (x0+1/2W, y2); z6 = (x5, y0); + + draw z1 -- z2 -- z3 -- z4; + draw z5 -- z6; + fill_corners (2, 3); + endchar; +%%% enddef; + + +%%% def draw_u = + ocrchar ("U"); "Letter U"; + z1 = (x0, y0+H); z2 = (x0, y0); + z3 = (x0+W, y0); z4 = (x3, y1); + + join_radius := T; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4); + endchar; +%%% enddef; + + +%%% def draw_v = + ocrchar ("V"); "Letter V"; + z1 = (x0, y0+H); z2 = (x1, y0+3/4H); z3 = (x0+1/2W, y0); + z4 = (x0+W, y2); z5 = (x4, y1); + + draw z1 -- z2 -- z3 -- z4 -- z5; + angle_fill_corner (1, 2, 3); + angle_fill_corner (3, 4, 5); + endchar; +%%% enddef; + + +%%% def draw_w = + ocrchar ("W"); "Letter W"; + z1 = (x0, y0+H); z2 = (x0, y0+1/8H); z3 = (x0+1/8W, y0); + z4 = (x0+3/8W, y0); z5 = (x0+1/2W, y2); z6 = (x0+5/8W, y0); + z7 = (x0+7/8W, y0); z8 = (x0+W, y2); z9 = (x8, y1); + z10 = (x5, y0+5/8H); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6 -- z7 -- z8 -- z9; + draw z5 -- z10; + angle_fill_corner (1, 2, 3); + angle_fill_corner (7, 8, 9); + endchar; +%%% enddef; + + +%%% def draw_x = + ocrchar ("X"); "Letter X"; + z1 = (x0, y0+H); z2 = (x0+W, y0); + z3 = (x1, y2); z4 = (x2, y1); + + draw z1 -- z2; + draw z3 -- z4; + endchar; +%%% enddef; + + +%%% def draw_y = + ocrchar ("Y"); "Letter Y"; + z1 = (x0, y0+H); z2 = (x1, y0+7/8H); z3 = (x0+1/2W, y0+1/2H); + z4 = (x0+W, y2); z5 = (x4, y1); z6 = (x3, y0); + + draw z1 -- z2 -- z3 -- z4 -- z5; + draw z3 -- z6; + angle_fill_corner (1, 2, 3); + angle_fill_corner (3, 4, 5); + endchar; +%%% enddef; + + +%%% def draw_z = + ocrchar ("Z"); "Letter Z"; + z1 = (x0, y0+H); z2 = (x0+W, y1); + z3 = (x0, y0); z4 = (x2, y0); + + draw z1 -- z2 -- z3 -- z4; + fill_corners (2, 3); + unfill unitsquare + shifted (-1.5,-0.5) scaled T + rotated (angle (z2-z3) - 90) shifted z3; + unfill unitsquare + shifted (0.5,-0.5) scaled T + rotated (angle (z2-z3) - 90) shifted z2; + endchar; +%%% enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ASCII punctuation symbols. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% +% Note that there is also a new "alternate" period shape. +% +%%% def draw_period = + ocrchar ("."); "Period"; + z1 = (x0+3/8W, y0+3/16H); z2 = (x0+5/8W, y1); + z3 = (x2, y0+5/16H); z4 = (x1, y3); + + draw z1 -- z2 -- z3 -- z4 -- cycle; + fill z1 -- z2 -- z3 -- z4 -- cycle; + endchar; +%%% enddef; + + +% +% Note that there is also a new "alternate" comma shape. +% +%%% def draw_comma = + ocrchar (","); "Comma"; + z1 = (x0+1/4W, y0+3/8H); z2 = (x0+3/4W, y1); z3 = (x2, y0); + + draw z1 -- z2 -- z3; + endchar; +%%% enddef; + + +%%% def draw_colon = + ocrchar (":"); "Colon"; + z1 = (x0+3/8W, y0+3/16H); z2 = (x0+5/8W, y1); + z3 = (x2, y0+5/16H); z4 = (x1, y3); + z5 = (x1, y1+1/2H); z6 = (x2, y2+1/2H); + z7 = (x3, y3+1/2H); z8 = (x4, y4+1/2H); + + draw z1 -- z2 -- z3 -- z4 -- cycle; + draw z5 -- z6 -- z7 -- z8 -- cycle; + fill z1 -- z2 -- z3 -- z4 -- cycle; + fill z5 -- z6 -- z7 -- z8 -- cycle; + endchar; +%%% enddef; + + +%%% def draw_semicolon = + ocrchar (";"); "Semicolon"; + z1 = (x0+1/4W, y0+3/8H); z2 = (x0+3/4W, y1); z3 = (x2, y0); + z4 = (x1, y0+3/4H); z5 = (x0+1/2W, y4); + z6 = (x5, y0+7/8H); z7 = (x4, y6); + + draw z1 -- z2 -- z3; + draw z4 -- z5 -- z6 -- z7 -- cycle; + fill z4 -- z5 -- z6 -- z7 -- cycle; + endchar; +%%% enddef; + + +%%% def draw_equals_sign = + ocrchar ("="); "Equals Sign"; + z1 = (x0, y0+3/8H); z2 = (x0+W, y1); + z3 = (x1, y0+11/16H); z4 = (x2, y3); + + draw z1 -- z2; + draw z3 -- z4; + endchar; +%%% enddef; + + +%%% def draw_plus_sign = + ocrchar ("+"); "Plus Sign"; + z1 = (x0, y0+1/2H); z2 = (x0+W, y1); + z3 = (x0+1/2W, y1+1/2W); z4 = (x3, y3-W); + + draw z1 -- z2; + draw z3 -- z4; + endchar; +%%% enddef; + + +%%% def draw_slant = + ocrchar ("/"); "Slant"; + z1 = (x0, y0); z2 = (x0+W, y0+H); + + draw z1 -- z2; + endchar; +%%% enddef; + + +%%% def draw_asterisk = + ocrchar ("*"); "Asterisk"; + z1 = (x0+1/2W, y0+1/8H); z2 = (x1, y0+7/8H); + z3 = (x0, y0+1/4H); z4 = (x0+W, y0+3/4H); + z5 = (x3, y4); z6 = (x4, y3); + + draw z1 -- z2; + draw z3 -- z4; + draw z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_quotation_mark = + ocrchar (ditto); "Quotation Mark"; + z1 = (x0+1/4W, y0+H); z2 = (x0+1/8W, y0+5/8H); + z3 = (x0, y1); z4 = (x0+W, y1); + z5 = (x0+7/8W, y2); z6 = (x0+3/4W, y1); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + fill z1 -- z2 -- z3 -- cycle; + fill z4 -- z5 -- z6 -- cycle; + fill_corners (3, 4); + unfill unitsquare + shifted (-1.5,-0.5) scaled T + rotated (angle (z3-z2) - 90) shifted z3; + unfill unitsquare + shifted (1.5,-0.5) scaled T + rotated (90 - angle (z6-z5)) shifted z6; + endchar; +%%% enddef; + + +%%% def draw_opening_brace = + ocrchar ("{"); "Opening Brace"; + z1 = (x0+W, y0); z2 = (x0+1/2W, y0); + z3 = (x2, y0+1/2H); z4 = (x0, y3); + z5 = (x2, y0+H); z6 = (x1, y5); + + draw (z1 -- z2) + join to_mid (z2, z3); + draw (z6 -- z5) + join to_mid (z5, z3); + join_radius := T; + draw from_mid (z2, z3) + join (z3 -- z4); + draw from_mid (z5, z3) + join (z3 -- z4); + endchar; +%%% enddef; + + +%%% def draw_closing_brace = + ocrchar ("}"); "Closing Brace"; + z1 = (x0, y0); z2 = (x0+1/2W, y0); + z3 = (x2, y0+1/2H); z4 = (x0+W, y3); + z5 = (x2, y0+H); z6 = (x1, y5); + + draw (z1 -- z2) + join to_mid (z2, z3); + draw (z6 -- z5) + join to_mid (z5, z3); + join_radius := T; + draw from_mid (z2, z3) + join (z3 -- z4); + draw from_mid (z5, z3) + join (z3 -- z4); + endchar; +%%% enddef; + + +%%% def draw_percent_sign = + ocrchar ("%"); "Percent Sign"; + z1 = (x0+3/4W, y0); z2 = (x0+W, y1); + z3 = (x2, y0+1/8H); z4 = (x1, y3); + z5 = (x0, y0+7/8H); z6 = (x0+1/4W, y5); + z7 = (x6, y0+H); z8 = (x5, y7); + z9 = (x0, y3); z10 = (x0+W, y5); + + draw z1 -- z2 -- z3 -- z4 -- cycle; + draw z5 -- z6 -- z7 -- z8 -- cycle; + draw z9 -- z10; + fill z1 -- z2 -- z3 -- z4 -- cycle; + fill z5 -- z6 -- z7 -- z8 -- cycle; + endchar; +%%% enddef; + + +% +% Note that there is also a new "alternate" question mark shape. +% +%%% def draw_question_mark = + ocrchar ("?"); "Question Mark"; + z1 = (x0, y0+5/8H); z2 = (x0+3/4W, y0+H); + z3 = (x0+W, y0+7/8H); z4 = (x3, y0+3/4H); + z5 = (x0+1/4W, y0+3/8H); z6 = (x5, y0+1/4H); + z7 = (x5, y0); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + drawdot z7; + endchar; +%%% enddef; + + +%%% def draw_ampersand = + ocrchar ("&"); "Ampersand"; + z1 = (x0+W, y0); z2 = (x0, y0+5/8H); + z3 = (x0, y0+7/8H); z4 = (x0+3/4W, y3); + z5 = (x4, y2); z6 = (x0, y0+1/4H); + z7 = (x0, y0); z8 = (x0+1/2W, y0); z9 = (x1, y6); + + join_radius := T; + draw z1 -- z2; + draw (z2 -- z3) + join (z3 -- z4) + join (z4 -- z5); + draw z5 -- z6; + draw (z6 -- z7) + join (z7 -- z8); + draw z8 -- z9; + endchar; +%%% enddef; + + +% +% This is a new apostrophe shape. The older shape has been made +% into an "alternate" form. +% +%%% def draw_apostrophe = + ocrchar ("'"); "Apostrophe"; + z1 = (x0+3/8W, y0+H); z2 = (x1, y0+1/2H); z3 = (x0+5/8W, y1); + + draw z1 -- z2 -- z3 -- cycle; + fill z1 -- z2 -- z3 -- cycle; + endchar; +%%% enddef; + + +% +% This is a new hyphen shape. The older shape has been made +% into an "alternate" form. +% +%%% def draw_hyphen = + ocrchar ("-"); "Hyphen"; + z1 = (x0, y0+1/2H); z2 = (x0+W, y1); + z3 = (x2, y0+7/16H); z4 = (x1, y3); + + draw z1 -- z2 -- z3 -- z4 -- cycle; + fill z1 -- z2 -- z3 -- z4 -- cycle; + endchar; +%%% enddef; + + +%%% def draw_dollar_sign = + ocrchar ("$"); "Dollar Sign"; + z1 = (x0, y0+1/4H); z2 = (x0+W, y1); z3 = (x2, y0+1/2H); + z4 = (x1, y3); z5 = (x4, y0+3/4H); z6 = (x2, y5); + z7 = (x0+1/2W, y0); z8 = .5[z1,z2]; + z9 = (x7, y0+H); z10 = .5[z5,z6]; + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + draw z7 -- z8; + draw z9 -- z10; + endchar; +%%% enddef; + + +%%% def draw_upward_arrowhead = + ocrchar ("^"); "Upward Arrowhead"; + z1 = (x0, y0+3/16H); z2 = (x0+1/2W, y0+5/8H); + z3 = (x0+W, y1); z4 = (x2, y0+3/4H); + + draw z1 -- z2 -- z3 -- z4 -- cycle; + fill z1 -- z2 -- z3 -- z4 -- cycle; + endchar; +%%% enddef; + + +%%% def draw_opening_bracket = + ocrchar ("["); "Opening Bracket"; + z1 = (x0+W, y0); z2 = (x0, y0); + z3 = (x2, y0+H); z4 = (x1, y3); + z5 = (5/8[x1,x2], y1); z6 = (x5, y3); + + draw z1 -- z2 -- z3 -- z4; + draw z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_closing_bracket = + ocrchar ("]"); "Closing Bracket"; + z1 = (x0, y0); z2 = (x0+W, y0); + z3 = (x2, y0+H); z4 = (x1, y3); + z5 = (5/8[x1,x2], y1); z6 = (x5, y3); + + draw z1 -- z2 -- z3 -- z4; + draw z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_less_than_sign = + ocrchar ("<"); "Less Than Sign"; + z1 = (x0+W, y0+1/8H); z2 = (x0, y0+15/32H); + z3 = (x2, y0+17/32H); z4 = (x1, y0+7/8H); + + draw z1 -- z2 -- z3 -- z4; + endchar; +%%% enddef; + + +%%% def draw_greater_than_sign = + ocrchar (">"); "Greater Than Sign"; + z1 = (x0, y0+1/8H); z2 = (x0+W, y0+15/32H); + z3 = (x2, y0+17/32H); z4 = (x1, y0+7/8H); + + draw z1 -- z2 -- z3 -- z4; + endchar; +%%% enddef; + + +%%% def draw_opening_parenthesis = + ocrchar ("("); "Opening Parenthesis"; + z1 = (x0+3/4W, y0); z2 = (x0+3/8W, y0+9/32H); + z3 = (x2, y0+23/32H); z4 = (x1, y0+H); + + join_radius := 3/2T; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4); + endchar; +%%% enddef; + + +%%% def draw_closing_parenthesis = + ocrchar (")"); "Closing Parenthesis"; + z1 = (x0+1/4W, y0); z2 = (x0+5/8W, y0+9/32H); + z3 = (x2, y0+23/32H); z4 = (x1, y0+H); + + join_radius := 3/2T; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4); + endchar; +%%% enddef; + + +%%% def draw_exclamation_point = + ocrchar ("!"); "Exclamation Point"; + z1 = (x0+7/16W, y0); z2 = (x0+9/16W, y1); + z3 = (x2, y0+1/16H); z4 = (x1, y3); + z5 = (x0+1/2W, y0+7/16H); z6 = (x1, y0+H); z7 = (x2, y6); + + draw z1 -- z2 -- z3 -- z4 -- cycle; + draw z5 -- z6 -- z7 -- cycle; + fill z1 -- z2 -- z3 -- z4 -- cycle; + fill z5 -- z6 -- z7 -- cycle; + endchar; +%%% enddef; + + +%%% def draw_number_sign = + ocrchar ("#"); "Number Sign"; + z1 = (x0+1/4W, y0+3/16H); z2 = (x1, y0+H); + z3 = (x0+3/4W, y1); z4 = (x3, y2); + z5 = (x0, y0+7/16H); z6 = (x0+W, y5); + z7 = (x5, y0+3/4H); z8 = (x6, y7); + + draw z1 -- z2; + draw z3 -- z4; + draw z5 -- z6; + draw z7 -- z8; + endchar; +%%% enddef; + + +%%% def draw_commercial_at = + ocrchar ("@"); "Commercial At"; + z1 = (x0, y0+7/8H); z2 = (x0, y0+H); z3 = (x0+W, y2); + z4 = (x3, y0); z5 = (x0+1/2W, y0); z6 = (x5, y0+9/16H); + z7 = (x0, y6); z8 = (x0, y0); + + join_radius := 3/16H; + draw (z1 -- z2) + join (z2 -- z3) + join to_mid (z3, z4); + join_radius := 1/4W; + draw from_mid (z3, z4) + join (z4 -- z5) + join (z5 -- z6); + draw (z6 -- z7) + join (z7 -- z8) + join (z8 -- z5) + join to_mid (z5, z6); + endchar; +%%% enddef; + + +%%% def draw_reverse_slant = + ocrchar ("\\"); "Reverse Slant"; + z1 = (x0, y0+H); z2 = (x0+W, y0); + + draw z1 -- z2; + endchar; +%%% enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Lower-case letters. +% Note that ANSI X3.17-1977 defines these characters as part of OCR-A +% only for the smallest size (Size I). Also, if lower-case letters are +% used, the standard requires a minimum vertical line spacing of five +% lines per inch (instead of the normal six lines per inch). +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%% def draw_small_a = + ocrchar ("a"); "Small Letter A"; + z1 = (x0+W, y0); + z2 = (0, H) rotated theta shifted (z1); + z3 = ((x0, y0+1/8H) -- (x0+W, y0+1/8H)) + intersectionpoint (z1 -- z2); + z4 = (x0+5/8W, y0); + z5 = (x0, y0); + z6 = (x0, y0+3/8H); + z7 = (z6 -- (x1, y6)) intersectionpoint (z1 -- z2); + z8 = (x0+1/4W, y0+11/16H); + z9 = (z8 -- (x1, y8)) intersectionpoint (z1 -- z2); + + join_radius := 1/4W; + draw z3 -- z4 -- to_mid (z4, z5); + draw from_mid (z4, z5) + join (z5 -- z6) + join (z6 -- z7) + join (z7 -- z3); + draw (z8 -- z9) + join (z9 -- z1); + endchar; +%%% enddef; + + +%%% def draw_small_b = + ocrchar ("b"); "Small Letter B"; + z1 = (x0, y0); z2 = (x1, y0+H); + z3 = (x1, y0+3/16H); z4 = (x0+3/8W, y0); + z5 = (x0+3/4W, y4); z6 = (x0+W, y0+1/8H); + z7 = (x6, y0+9/16H); z8 = (x5, y0+11/16H); + z9 = (x4, y8); z10 = (x3, y0+1/2H); + + join_radius := 1/4W; + draw z1 -- z2; + draw from_mid (z3, z4) + join (z4 -- z5) + join (z5 -- z6) + join (z6 -- z7) + join to_mid (z7, z8); + draw from_mid (z7, z8) + join (z8 -- z9) + join (z9 -- z10) + join (z10 -- z3) + join to_mid (z3, z4); + endchar; +%%% enddef; + + +%%% def draw_small_c = + ocrchar ("c"); "Small Letter C"; + z1 = (x0+W, y0); z2 = (x0+3/8W, y1); + z3 = (x0, y0+3/16H); z4 = (x3, y0+1/2H); + z5 = (x2, y0+11/16H); z6 = (x1, y5); + + join_radius := 1/4W; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4) + join (z4 -- z5) + join (z5 -- z6); + endchar; +%%% enddef; + + +%%% def draw_small_d = + ocrchar ("d"); "Small Letter D"; + z1 = (x0+W, y0); z2 = (x1, y0+H); + z3 = (x2, y0+3/16H); z4 = (x0+5/8W, y0); + z5 = (x0+1/4W, y4); z6 = (x0, y0+1/8H); + z7 = (x6, y0+9/16H); z8 = (x5, y0+11/16H); + z9 = (x4, y8); z10 = (x3, y0+1/2H); + + join_radius := 1/4W; + draw z1 -- z2; + draw from_mid (z3, z4) + join (z4 -- z5) + join (z5 -- z6) + join (z6 -- z7) + join to_mid (z7, z8); + draw from_mid (z7, z8) + join (z8 -- z9) + join (z9 -- z10) + join (z10 -- z3) + join to_mid (z3, z4); + endchar; +%%% enddef; + + +%%% def draw_small_e = + ocrchar ("e"); "Small Letter E"; + z1 = (x0+W, y0); z2 = (x0+1/4W, y1); + z3 = (x0, y0+1/8H); z4 = (x3, y0+9/16H); + z5 = (x2, y0+11/16H); z6 = (x0+3/4W, y5); + z7 = (x1, y4); z8 = (x7, y0+5/16H); z9 = (x3, y8); + + join_radius := 1/4W; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4) + join (z4 -- z5) + join (z5 -- z6) + join (z6 -- z7) + join (z7 -- z8) + -- z9; + endchar; +%%% enddef; + + +%%% def draw_small_f = + ocrchar ("f"); "Small Letter F"; + z1 = (x0+3/8W-1/4T, y0); + z2 = (x1, y0+H); z3 = (x0+W-1/4T, y2); + z4 = (x0+1/8W-1/4T, y0+11/16H); + z5 = (x0+3/4W-1/4T, y4); + + join_radius := .32W; + draw (z1 -- z2) + join (z2 -- z3); + draw z4 -- z5; + endchar; +%%% enddef; + + +%%% def draw_small_g = + ocrchar ("g"); "Small Letter G"; + z1 = (x0+W, y8); z2 = (x1, y0-3/16H); + z2a = (x0+3/4W, y0-5/16H); z2b = (x0+1/8W, y2a); + z3 = (x2, y0+1/4H); z4 = (x0+5/8W, y0+1/16H); + z5 = (x0+1/4W, y4); z6 = (x0, y0+3/16H); + z7 = (x6, y0+9/16H); z8 = (x5, y0+11/16H); + z9 = (x4, y8); z10 = (x3, y0+1/2H); + + join_radius := 1/4W; + draw (z1 -- z2) + join (z2 -- z2a) + join (z2a -- z2b); + draw from_mid (z3, z4) + join (z4 -- z5) + join (z5 -- z6) + join (z6 -- z7) + join to_mid (z7, z8); + draw from_mid (z7, z8) + join (z8 -- z9) + join (z9 -- z10) + join (z10 -- z3) + join to_mid (z3, z4); + endchar; +%%% enddef; + + +%%% def draw_small_h = + ocrchar ("h"); "Small Letter H"; + z1 = (x0+W, y0); + z2 = (0, H) rotated theta shifted (z1); + z3 = (x0, y0); z4 = (x0, y0+H); + z5 = (x3, y0+1/2H); z6 = (x0+1/2W, y0+11/16H); + z7 = (z6 -- (x1, y6)) intersectionpoint (z1 -- z2); + + join_radius := 1/4W; + draw z3 -- z4; + draw (z5 -- z6) + join (z6 -- z7) + join (z7 -- z1); + endchar; +%%% enddef; + + +%%% def draw_small_i = + ocrchar ("i"); "Small Letter I"; + z1 = (x0+1/2W, y0); z2 = (x1, y0+11/16H); z3 = (x0+1/8W, y2); + z4 = (x3, y0); z5 = (x0+7/8W, y4); + z6 = (x1, y0+H); z7 = (x6, y0+17/16H); + z8 = (x0+3/8W, y7); z9 = (x8, y6); + + draw z1 -- z2 -- z3; + draw z4 -- z5; + draw z6 -- z7 -- z8 -- z9 -- cycle; + fill z6 -- z7 -- z8 -- z9 -- cycle; + endchar; +%%% enddef; + + +%%% def draw_small_j = + ocrchar ("j"); "Small Letter J"; + z1 = (x0+3/8W, y0+11/16H); z2 = (x0+7/8W, y1); + z3 = (x2, y0-5/16H); z4 = (x0+1/8W, y3); z5 = (x4, y0-3/16H); + z6 = (x2, y0+H); z7 = (x6, y0+17/16H); + z8 = (x0+3/4W, y7); z9 = (x8, y6); + + join_radius := 1/4W; + draw (z5 -- z4) + join (z4 -- z3) + join (z3 -- z2) + -- z2 -- z1; + draw z6 -- z7 -- z8 -- z9 -- cycle; + fill z6 -- z7 -- z8 -- z9 -- cycle; + endchar; +%%% enddef; + + +%%% def draw_small_k = + ocrchar ("k"); "Small Letter K"; + z1 = (x0, y0); z2 = (x1, y0+H); + z3 = (x1, y0+1/4H); z4 = (x0+7/8W, y0+11/16H); + z5 = (x0+1/4W, y0+3/8H); z6 = (x0+W, y0); + + draw z1 -- z2; + draw z3 -- z4; + draw z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_small_l = + ocrchar ("l"); "Small Letter L"; + z1 = (x0+1/2W, y0); z2 = (x1, y0+H); z3 = (x0+1/8W, y2); + z4 = (x3, y0); z5 = (x0+7/8W, y4); + + draw z1 -- z2 -- z3; + draw z4 -- z5; + endchar; +%%% enddef; + + +%%% def draw_small_m = + ocrchar ("m"); "Small Letter M"; + z1 = (x0-.02W, y0+11/16H); z2 = (x1, y0); + z3 = (x1, y0+.55H); z4 = (x0+1/4W, y1); + z5 = (x0+1/2W, y1); z6 = (x5, y0); + z7 = (x5, y0+9/16H); z8 = (x0+3/4W, y1); + z10 = (x0+1.02W, y0); + z10a = (0, H) rotated theta shifted (z10); + z9 = (z8 -- (x10, y8)) intersectionpoint (z10 -- z10a); + z9b = (z7 -- (x10, y7)) intersectionpoint (z10 -- z10a); + + join_radius := 0.181W; + draw z1 -- z2; + draw (z3 -- z4) + join (z4 -- z5) + join (z5 -- z7) + -- z6; + join_radius := 0.176W; + draw (z7 -- z8) + join (z8 -- z9) + join (z9 -- z9b) + -- z10; + endchar; +%%% enddef; + + +%%% def draw_small_n = + ocrchar ("n"); "Small Letter N"; + z1 = (x0+W, y0); + z2 = (0, H) rotated theta shifted (z1); + z3 = (x0, y0); z4 = (x0, y6); + z5 = (x3, y0+1/2H); z6 = (x0+1/2W, y0+11/16H); + z7 = (z6 -- (x1, y6)) intersectionpoint (z1 -- z2); + + join_radius := 1/4W; + draw z3 -- z4; + draw (z5 -- z6) + join (z6 -- z7) + join (z7 -- z1); + endchar; +%%% enddef; + + +%%% def draw_small_o = + ocrchar ("o"); "Small Letter O"; + z1 = (x0, y0+1/8H); z2 = (x0+1/4W, y0); + z3 = (x0+3/4W, y2); z4 = (x0+W, y1); + z5 = (x4, y0+9/16H); z6 = (x3, y0+11/16H); + z7 = (x2, y6); z8 = (x1, y5); + + join_radius := 1/4W; + draw from_mid (z8, z1) + join (z1 -- z2) + join to_mid (z2, z3); + draw from_mid (z2, z3) + join (z3 -- z4) + join to_mid (z4, z5); + draw from_mid (z4, z5) + join (z5 -- z6) + join to_mid (z6, z7); + draw from_mid (z6, z7) + join (z7 -- z8) + join to_mid (z8, z1); + endchar; +%%% enddef; + + +%%% def draw_small_p = + ocrchar ("p"); "Small Letter P"; + z1 = (x0, y0+23/32H); z2 = (x1, y0-5/16H); + z3 = (x1, y0+3/16H); z4 = (x0+3/8W, y0-1/32H); + z5 = (x0+5/8W, y4); z6 = (x0+W, y0+.157H); + z7 = (x6, y0+.529H); z8 = (x5, y0+23/32H); + z9 = (x4, y8); z10 = (x3, y0+1/2H); + + join_radius := 1/4W; + draw z1 -- z2; + draw from_mid (z3, z4) + join (z4 -- z5) + join (z5 -- z6) + join (z6 -- z7) + join to_mid (z7, z8); + draw from_mid (z7, z8) + join (z8 -- z9) + join (z9 -- z10) + join (z10 -- z3) + join to_mid (z3, z4); + endchar; +%%% enddef; + + +%%% def draw_small_q = + ocrchar ("q"); "Small Letter Q"; + z1 = (x0+W, y0+11/16H); z2 = (x1, y0-5/16H); + z3 = (x2, y0+3/16H); z4 = (x0+5/8W, y0); + z5 = (x0+1/4W, y4); z6 = (x0, y0+1/8H); + z7 = (x6, y0+9/16H); z8 = (x5, y0+11/16H); + z9 = (x4, y8); z10 = (x3, y0+1/2H); + + join_radius := 1/4W; + draw z1 -- z2; + draw from_mid (z3, z4) + join (z4 -- z5) + join (z5 -- z6) + join (z6 -- z7) + join to_mid (z7, z8); + draw from_mid (z7, z8) + join (z8 -- z9) + join (z9 -- z10) + join (z10 -- z3) + join to_mid (z3, z4); + endchar; +%%% enddef; + + +%%% def draw_small_r = + ocrchar ("r"); "Small Letter R"; + z1 = (x0, y0+11/16H); z2 = (x1, y0); + z3 = (x1, y0+7/16H); z4 = (x0+1/2W, y1); + z5 = (x0+W, y4); z6 = (x5, y0+1/2H); + + join_radius := 1/4W; + draw z1 -- z2; + draw z3 -- z4; + draw (z6 -- z5) + join (z5 -- z4); + endchar; +%%% enddef; + + +%%% def draw_small_s = + ocrchar ("s"); "Small Letter S"; + z1 = (x0, y0+1/16H); z1a = (x0+.07W, y0+.03H); + z2 = (x0+.20W, y0); z3 = (x0+W, y2); z4 = (x3, y0+1/4H); + z5 = (x0+.027W, y0+1/2H); z6 = (x5, y0+11/16H); + z6a = (x0+1/2W, y6); z7 = (x0+.92W, y6); + z8 = (x0+.973W, y0+5/8H); + + join_radius := .32W; + draw (z1 -- z1a) + join (z1a -- z2) + join to_mid (z2, z3); + join_radius := .26W; + draw from_mid (z2, z3) + join (z3 -- z4) + join to_mid (z4, z5); + join_radius := .20W; + draw from_mid (z4, z5) + join (z5 -- z6) + join (z6 -- z6a); + join_radius := .25W; + draw (z8 -- z7) + join (z7 -- z6a); + endchar; +%%% enddef; + + +%%% def draw_small_t = + ocrchar ("t"); "Small Letter T"; + z1 = (x0+W, y0+1/8H); z2 = (x1, y0); + z3 = (x0+1/4W, y2); z4 = (x3, y0+15/16H); + z5 = (x0, y0+11/16H); z6 = (x0+7/8W, y5); + + join_radius := 1/4W; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4); + draw z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_small_u = + ocrchar ("u"); "Small Letter U"; + z1 = (x0, y0+11/16H); + z2 = (0, -H) rotated theta shifted (z1); + z3 = (x0+W, y1); z4 = (x3, y0); + z5 = (x3, y0+3/16H); z6 = (x0+1/2W, y0); + z7 = (z6 -- (x1, y6)) intersectionpoint (z1 -- z2); + + join_radius := 1/4W; + draw z3 -- z4; + draw (z5 -- z6) + join (z6 -- z7) + join (z7 -- z1); + endchar; +%%% enddef; + + +%%% def draw_small_v = + ocrchar ("v"); "Small Letter V"; + z1 = (x0, y0+11/16H); z2 = (x1, y0+9/16H); + z3 = (x0+.421W, y0); z4 = (x0+.579W, y0); + z5 = (x0+W, y2); z6 = (x5, y1); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + endchar; +%%% enddef; + + +%%% def draw_small_w = + ocrchar ("w"); "Small Letter W"; + z1 = (x0, y0+1/4H); z2 = (x0+1/8W, y0); z3 = (x0+1/4W, y0); + z4 = (x0+1/2W, y1); z5 = (x4, y0+7/16H); + z6 = (x0+3/4W, y0); z7 = (x0+7/8W, y0); z8 = (x0+W, y1); + z9a = (0, H) rotated theta shifted (z1); + z9b = (0, H) rotated -theta shifted (z8); + z10a = (x0-1/4W, y0+11/16H); z10b = (x0+5/4W, y10a); + z11a = (z10a -- z10b) intersectionpoint (z1 -- z9a); + z11b = (z10a -- z10b) intersectionpoint (z8 -- z9b); + + draw z11a -- z1 -- z2 -- z3 -- z4 -- z6 -- z7 -- z8 -- z11b; + draw z4 -- z5; + endchar; +%%% enddef; + + +%%% def draw_small_x = + ocrchar ("x"); "Small Letter X"; + z1 = (x0, y0); z2 = (x0+.973W, y0+11/16H); + z3 = (x0+W, y0); z4 = (x0+.027W, y0+11/16H); + + draw z1 -- z2; + draw z3 -- z4; + endchar; +%%% enddef; + + +%%% def draw_small_y = + ocrchar ("y"); "Small Letter Y"; + z1 = (x0, y0+11/16H); z2 = (x1, y0+9/16H); + z3 = (x0+3/8W, y0+1/16H); z4 = (x0+5/8W, y3); + z5 = (x0+W, y1); z6 = (x5, y2); + z8 = (x0, y0-5/16H); + z7 = (z6 -- z4+(z4-z6)) + intersectionpoint (z8 -- (x8+W, y8)); + + draw z1 -- z2 -- z3 -- z4; + draw z5 -- z6 -- z7 -- z8; + endchar; +%%% enddef; + + +%%% def draw_small_z = + ocrchar ("z"); "Small Letter Z"; + z1 = (x0+.061W, y0+11/16H); z2 = (x0+W, y1); + z3 = (x2, y0+5/8H); z4 = (x0, y0+1/16H); + z5 = (x0, y0); z6 = (x2, y5); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + endchar; +%%% enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Alternate symbol forms. +% These are all new shapes, except for Apostrophe and Hyphen, where +% the "alternate" shapes are the older versions. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% +% Alternate period was introduced because the standard character causes +% paper punch-through on some printers. +% +%%% def draw_period_alt = + ocrchar (14); "Period (Alternate)"; + z1 = (x0+5/16W, y0); z2 = (x0+11/16W, y1); + z3 = (x2, y0+3/8W); z4 = (x1, y3); + % NOTE: The use of "W" in the Y-coordinate of "z3" + % is as given in the spec, to make a square period. + + draw z1 -- z2 -- z3 -- z4 -- cycle; + fill z1 -- z2 -- z3 -- z4 -- cycle; + endchar; +%%% enddef; + + +% +% Alternate comma was introduced because the standard character causes +% paper punch-through on some printers. +% +%%% def draw_comma_alt = + ocrchar (15); "Comma (Alternate)"; + z1 = (x0+1/4W, y0+5/16H); z2 = (x1, y0+3/8H); + z3 = (x0+3/4W, y2); z4 = (x3, y0); z5 = (x0+5/8W, y4); + z6 = (x5, y1); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6 -- cycle; + fill z1 -- z2 -- z3 -- z4 -- z5 -- z6 -- cycle; + endchar; +%%% enddef; + + +% +% Alternate question mark was introduced because the small dot at the +% bottom of the standard character is difficult or impossible to form +% on some embossed plates/cards, and also causes paper punch-through +% on some printers. +% +%%% def draw_question_mark_alt = + ocrchar (16); "Question Mark (Alternate)"; + z1 = (x0, y0+5/8H); z2 = (x0+3/4W, y0+H); + z3 = (x0+W, y0+7/8H); z4 = (x3, y0+3/4H); + z5 = (x0+1/4W, y0+3/8H); z6 = (x5, y0); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + endchar; +%%% enddef; + + +% +% A new apostrophe was introduced (and the older character changed to +% alternate status) because the older character causes paper punch- +% through on some printers and cannot be properly recognized by some +% readers which do not store vertical-position data. +% +%%% def draw_apostrophe_alt = + ocrchar (17); "Apostrophe (Alternate)"; + z1 = (x0+3/8W, y0+H); z2 = (x0+1/2W, y0+5/8H); + z3 = (x0+5/8W, y1); + + draw z1 -- z2 -- z3 -- cycle; + fill z1 -- z2 -- z3 -- cycle; + endchar; +%%% enddef; + + +% +% A new hyphen was introduced (and the older character changed to +% alternate status) because the older character causes paper punch- +% through on some printers. +% +%%% def draw_hyphen_alt = + ocrchar (18); "Hyphen (Alternate)"; + z1 = (x0, y0+1/2H); z2 = (x0+W, y1); + + draw z1 -- z2; + endchar; +%%% enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Special OCR characters. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% +% The "hook" symbol (looks sort of like a squared-off S) is defined in +% ANSI X3.17-1977 to go into the "tilde" spot in the ASCII table. +% +%%% def draw_symbol_hook = + ocrchar (19); "Symbol HOOK"; + z1 = (x0, y0+3/8H); z2 = (x0, y0); z3 = (x0+1/2W, y0); + z4 = (x3, y0+H); z5 = (x0+W, y0+H); z6 = (x0+W, y0+5/8H); + + draw z1 -- z2 -- z3 -- z4 -- z5 -- z6; + fill_corners (2, 3, 4, 5); + endchar; +%%% enddef; + + +% +% The "fork" symbol (looks sort of like a squared-off Y) is defined in +% ANSI X3.17-1977 to go into the "underline" spot in the ASCII table. +% However, a note in the standard says that this assignment should not +% preclude use of the Underline in applications not needing the "fork". +% +%%% def draw_symbol_fork = + ocrchar (20); "Symbol FORK"; + z1 = (x0, y0+H); z2 = (x0, y0+1/2H); + z3 = (x0+W, y2); z4 = (x0+W, y0+H); + z5 = (x0+1/2W, y2); z6 = (x5, y0); + + draw z1 -- z2 -- z3 -- z4; + draw z5 -- z6; + fill_corners (2, 3); + endchar; +%%% enddef; + + +% +% The "chair" symbol (looks sort of like a squared-off, backwards lower- +% case H) is defined in ANSI X3.17-1977 to go into the "grave accent" +% spot in the ASCII table. +% +%%% def draw_symbol_chair = + ocrchar (21); "Symbol CHAIR"; + z1 = (x0+W, y0+H); z2 = (x1, y0); + z3 = .5[z1,z2]; z4 = (x0, y3); z5 = (x0, y0); + + draw z1 -- z2; + draw z3 -- z4 -- z5; + fill_corners (4); + endchar; +%%% enddef; + + +% +% The "Long Vertical Mark" is not really suitable as a representation +% of the ASCII "vertical bar" character. The "Long Vertical Mark" is +% intended as a field separator and is significantly taller than other +% characters in the font. +% +%%% def draw_long_vertical_mark = + ocrchar (22); "Long Vertical Mark"; + z1 = (x0+1/2W, y0+L-T/2); z2 = (x1, y0-Y+T/2); + + draw z1 -- z2; + fill_corners (1, 2); + endchar; +%%% enddef; + + +% +% "Character Erase" (a large rectangular black box) is defined in +% ANSI X3.17-1977 only for the smallest character size (Size I). +% +%%% def draw_character_erase = + ocrchar (127); "Character Erase"; + z1 = (x0-3/4T, y0-3/4T); z2 = (x0+W+3/4T, y1); + z3 = (x2, y0+H+3/4T); z4 = (x1, y3); + + fill z1 -- z2 -- z3 -- z4 -- cycle; + endchar; +%%% enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Miscellaneous symbols. +% These are not an official part of ANSI OCR-A, but were included in an +% appendix to X3.17-1977. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%% def draw_aa = + ocrchar (23); "Letter \AA"; + z1 = (x0, y0); z2 = (x0+3/8W, y0+3/4H); + z3 = (x0+5/8W, y2); z4 = (x0+W, y1); + z5 = (x0+1/8W, y2); z6 = (x0+7/8W, y2); + z7 = (x6, y0+H); z8 = (x5, y7); + z9 = (x5, y0+1/4H); z10 = (x6, y9); + + draw z1 -- z2; + draw z3 -- z4; + draw z9 -- z10; + draw from_mid (z5, z6) + join (z6 -- z7) + join to_mid (z7, z8); + draw from_mid (z7, z8) + join (z8 -- z5) + join to_mid (z5, z6); + endchar; +%%% enddef; + + +%%% def draw_a_umlaut = + ocrchar (24); "Letter \"&ditto&"A"; + z1 = (x0, y0); z2 = (x0+1/2W, y0+3/4H); z3 = (x0+W, y0); + z4 = (x0+1/8W, y0+3/16H); z5 = (x0+7/8W, y4); + z6 = (x1, y0+H); z7 = (x6, y0+7/8H); + z8 = (x3, y6); z9 = (x8, y7); + + draw z1 -- z2 -- z3; + draw z4 -- z5; + draw z6 -- z7; + draw z8 -- z9; + endchar; +%%% enddef; + + +%%% def draw_ae = + ocrchar (25); "Letter \AE"; + z1 = (x0, y0); z2 = (x0+5/8W, y0+H); z3 = (x0+W, y2); + z4 = (x2, y0+1/2H); z5 = (x3, y4); + z6 = (x2, y1); z7 = (x3, y1); + z8 = 1/4[z1,z2]; z9 = 1/4[z6,z2]; + + draw z1 -- z2 -- z3; + draw z2 -- z6 -- z7; + draw z4 -- z5; + draw z8 -- z9; + endchar; +%%% enddef; + + +%%% def draw_n_tilde = + ocrchar (26); "Letter \~N"; + z1 = (x0, y0); z2 = (x1, y0+5/8H); + z3 = (x0+W, y1); z4 = (x3, y2); + z5 = (x1, y0+15/16H); z6 = (x5, y0+H); + z7 = (x3, y5); z8 = (x3, y6); + + draw z1 -- z2 -- z3 -- z4; + draw z5 -- z6 -- z7 -- z8; + endchar; +%%% enddef; + + +%%% def draw_o_slant = + ocrchar (27); "Letter \O"; + z1 = (x0, y0+7/16H); z2 = (x1, y0+9/16H); + z3 = (x0+3/8W, y0+H); z4 = (x0+5/8W, y3); + z5 = (x0+W, y2); z6 = (x5, y1); + z7 = (x4, y0); z8 = (x3, y7); + z9 = (x0, y0); z10 = (x0+W, y0+H); + + join_radius := r1; + draw from_mid (z8, z1) + join (z1 -- z2) + join to_mid (z2, z3); + draw from_mid (z4, z5) + join (z5 -- z6) + join to_mid (z6, z7); + join_radius := r2; + draw from_mid (z2, z3) + join (z3 -- z4) + join to_mid (z4, z5); + draw from_mid (z6, z7) + join (z7 -- z8) + join to_mid (z8, z1); + draw z9 -- z10; + endchar; +%%% enddef; + + +%%% def draw_o_umlaut = + ocrchar (28); "Letter \"&ditto&"O"; + z1 = (x0, y0+5/16H); z2 = (x1, y0+7/16H); + z3 = (x0+3/8W, y0+3/4H); z4 = (x0+5/8W, y3); + z5 = (x0+W, y2); z6 = (x5, y1); + z7 = (x4, y0); z8 = (x3, y7); + z9 = (x1, y0+H); z10 = (x1, y0+7/8H); + z11 = (x5, y9); z12 = (x5, y10); + + join_radius := r5; + draw from_mid (z8, z1) + join (z1 -- z2) + join to_mid (z2, z3); + draw from_mid (z4, z5) + join (z5 -- z6) + join to_mid (z6, z7); + join_radius := r6; + draw from_mid (z2, z3) + join (z3 -- z4) + join to_mid (z4, z5); + draw from_mid (z6, z7) + join (z7 -- z8) + join to_mid (z8, z1); + draw z9 -- z10; + draw z11 -- z12; + endchar; +%%% enddef; + + +%%% def draw_u_umlaut = + ocrchar (29); "Letter \"&ditto&"U"; + z1 = (x0, y0+3/4H); z2 = (x0, y0); + z3 = (x0+W, y0); z4 = (x3, y1); + z5 = (x0+1/4W, y0+H); z6 = (x5, y0+7/8H); + z7 = (x0+3/4W, y5); z8 = (x7, y6); + + join_radius := T; + draw (z1 -- z2) + join (z2 -- z3) + join (z3 -- z4); + draw z5 -- z6; + draw z7 -- z8; + endchar; +%%% enddef; + + +%%% def draw_pound_sign = + ocrchar (30); "Pound Sign"; + z1 = (x0, y0); z2 = (x0+W, y1); + z3 = (x0+1/4W, y1); z4 = (x0+3/4W, y0+H); z5 = (x2, y4); + z6 = (x1, y0+1/2H); z7 = (x2, y6); + + join_radius := T; + draw z1 -- z2; + draw (z3 -- z4) + join (z4 -- z5); + draw z6 -- z7; + endchar; +%%% enddef; + + +%%% def draw_yen_sign = + ocrchar (31); "Yen Sign"; + z1 = (x0, y0+H); z2 = (x0+1/2W, y0+1/2H); z3 = (x0+W, y1); + z4 = (x2, y0); z5 = (x1, y0+3/8H); z6 = (x3, y5); + + draw z1 -- z2 -- z3; + draw z2 -- z4; + draw z5 -- z6; + endchar; +%%% enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Non-standard ASCII characters. +% I designed these characters myself in order to make a complete ASCII +% character set. Note that these characters are *NOT* part of ANSI +% X3.17-1977 or any other OCR-A standard, and will almost certainly +% *NOT* be understood by any OCR-A scanner currently in existence. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%% def draw_tilde = + ocrchar ("~"); "Tilde"; + z1 = (x0, y0+11/16H); z2 = (x1, y0+H); + z3 = (x0+1/2W, y2); z4 = (x3, y0+5/8H); + z5 = (x0+W, y4); z6 = (x5, y0+15/16H); + + join_radius := T; + draw (z1 -- z2) + join (z2 -- z3) + join to_mid (z3, z4); + draw (z6 -- z5) + join (z5 -- z4) + join to_mid (z4, z3); + endchar; +%%% enddef; + + +%%% def draw_underline = + ocrchar ("_"); "Underline"; + z1 = (x0, y0-T); z2 = (x0+W, y1); + + draw z1 -- z2; + endchar; +%%% enddef; + + +%%% def draw_grave_accent = + ocrchar ("`"); "Grave Accent"; + z1 = (x0+1/8W, y0+H); z2 = (x0+7/8W, y0+5/8H); + z3 = (x0+3/8W, y1); + + draw z1 -- z2 -- z3 -- cycle; + fill z1 -- z2 -- z3 -- cycle; + endchar; +%%% enddef; + + +%%% def draw_vertical_bar = + ocrchar ("|"); "Vertical Bar"; + z1 = (x0+1/2W, y0+H); z2 = (x1, y0+1/2H+T); + z3 = (x1, y0+1/2H-T); z4 = (x1, y0); + + draw z1 -- z2; + draw z3 -- z4; + fill_corners (2, 3); + endchar; +%%% enddef; + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% Font parameters % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +designsize := L#; +font_slant := 0; +font_normal_space := R#; +font_normal_stretch := 0; % mustn't be more than .8R#, per spec +font_normal_shrink := 0; % mustn't be more than .1R#, per spec +font_x_height := H#; +font_quad := 2W#; +font_extra_space := 0; + +end. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% END OF OCR-A METAFONT DEFINITION % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/fonts/ocr-a/ocr10.mf b/fonts/ocr-a/ocr10.mf new file mode 100644 index 0000000000..a75de22c43 --- /dev/null +++ b/fonts/ocr-a/ocr10.mf @@ -0,0 +1,10 @@ +% OCR-A Size I (10-point) + +H# = 0.094in#; % centerline height of characters +W# = 0.055in#; % centerline width of characters +T# = 0.014in#; % stroke width +L# = 0.146in#; % height of long vertical mark +Y# = 0.021in#; % depth of long vertical mark +R# = 0.100in#; % horizontal character spacing + +input ocra; diff --git a/fonts/ocr-a/ocr12.mf b/fonts/ocr-a/ocr12.mf new file mode 100644 index 0000000000..b7a8a159ec --- /dev/null +++ b/fonts/ocr-a/ocr12.mf @@ -0,0 +1,10 @@ +% OCR-A Size I, magnified 20% (12-point) + +H# = 0.112in#; % centerline height of characters +W# = 0.066in#; % centerline width of characters +T# = 0.017in#; % stroke width +L# = 0.175in#; % height of long vertical mark +Y# = 0.025in#; % depth of long vertical mark +R# = 0.120in#; % horizontal character spacing + +input ocra; diff --git a/fonts/ocr-a/ocr16.mf b/fonts/ocr-a/ocr16.mf new file mode 100644 index 0000000000..54e18b6dcd --- /dev/null +++ b/fonts/ocr-a/ocr16.mf @@ -0,0 +1,10 @@ +% OCR-A Size I, magnified 60% (16-point) + +H# = 0.150in#; % centerline height of characters +W# = 0.088in#; % centerline width of characters +T# = 0.022in#; % stroke width +L# = 0.234in#; % height of long vertical mark +Y# = 0.034in#; % depth of long vertical mark +R# = 0.160in#; % horizontal character spacing + +input ocra; |