| 1 |
%% File LXBBASE copied and modified from AMSYB by American Mathematical Society |
| 2 |
%% in order to cope with the necessities of the slides fonts |
| 3 |
%% |
| 4 |
%% Claudio Beccari 2007 |
| 5 |
% |
| 6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7 |
|
| 8 |
% Changes made for version 2.1: |
| 9 |
% Fixed Problems with smode in draw_outlines and showpoints |
| 10 |
% Stefan Lindner, 21-March-1991 |
| 11 |
% Fixed Problems with serifs at small point sizes |
| 12 |
% Stefan Lindner and Lutz Birkhahn, 14-April-91 |
| 13 |
|
| 14 |
vardef curve@#(expr a,one,b,two)= |
| 15 |
save x,y; |
| 16 |
z0=if(str@#="br")or(str@#="tl"):(xpart b,ypart a) |
| 17 |
else:(xpart a,ypart b) fi; |
| 18 |
z1=one[a,z0]; z2=two[b,z0]; |
| 19 |
a ..controls z1 and z2.. b |
| 20 |
enddef; |
| 21 |
|
| 22 |
vardef reversecurve@#(expr a,one,b,two)=reverse curve@#(a,one,b,two) enddef; |
| 23 |
|
| 24 |
|
| 25 |
vardef beak(expr injoin,intip,outtip,indent,outjoin,tense)= |
| 26 |
save x,y,t,toward,onright,ref; pair toward; boolean onright; path ref; |
| 27 |
onright=(xpart intip>xpart injoin); |
| 28 |
toward=if onright: right else: left fi; |
| 29 |
z1=intip if onright:-else:+ fi (inbeak,0); |
| 30 |
z2=outtip if onright:-else:+ fi (outbeak,0); |
| 31 |
ref=outjoin{toward}...(z1 if onright:+else:- fi (2*abs(outjoin-injoin),0)); |
| 32 |
y4=.5[ypart outjoin,ypart indent]; |
| 33 |
z3=ref intersectionpoint ((0,y4)--(w,y4)); |
| 34 |
(t3,t4)=ref intersectiontimes ((0,y4)--(w,y4)); |
| 35 |
|
| 36 |
injoin{toward}..tension tense..z1--intip--outtip--z2...indent{-toward}... |
| 37 |
{-(direction t3 of ref)}z3--subpath(t3,0) of ref |
| 38 |
enddef; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
boolean its_a_leftserif; |
| 44 |
|
| 45 |
vardef full_serif_points@# |
| 46 |
(expr A,B,Bl,Br,leftlength,rightlength,midbracket_pull)= |
| 47 |
%%%% min_limit(join_radius)(.5serif_thickness); % -sl 14.04.91 |
| 48 |
(z1-B)=whatever*(A@#-B@#); |
| 49 |
(z1l-Bl)=whatever*(A@#-B@#); |
| 50 |
(z1r-Br)=whatever*(A@#-B@#); |
| 51 |
|
| 52 |
y2=y2l=y2r=ypart A; |
| 53 |
y1=y1l=y1r=y3=y4=ypart A if ypart A>ypart B:-else:+fi serif_thickness; |
| 54 |
|
| 55 |
x5=x2=.5[x1l,x1r]; |
| 56 |
y5=entasis[y2l,y1l]; |
| 57 |
|
| 58 |
if its_a_leftserif:x3=x2l=x1l-round(leftlength+serif_constant_amt); |
| 59 |
else:x4=x2r=x1r+round(rightlength+serif_constant_amt); fi |
| 60 |
enddef; |
| 61 |
|
| 62 |
vardef leftserif@#(expr A,B,Bl,Br,alength,midbracket_pull)= |
| 63 |
its_a_leftserif:=true; |
| 64 |
save x,y,p; path p[]; |
| 65 |
min_limit(join_radius)(.5serif_thickness); % -sl 14.04.91 |
| 66 |
full_serif_points@#(A,B,Bl,Br,alength,0,midbracket_pull); |
| 67 |
p0:=Bl{z1l-Bl}...{z3-z1l}z3; |
| 68 |
if midbracket_pull<>0: |
| 69 |
z3'l=z1l; pos3'(alength+5pt,.5[angle(B-A),if ypart A>ypart B:-fi 180]); |
| 70 |
z8'=p0 intersectionpoint (z3'l--z3'r); |
| 71 |
z8=(midbracket_pull-eps)[z8',z1l];fi |
| 72 |
if ypart A>ypart B:reverse fi |
| 73 |
((if midbracket_pull=0:p0 else:Bl{z1l-Bl}...z8...{z3-z1l}z3 fi |
| 74 |
if softpath:)softjoin(z3--z2l)softjoin(else:--fi z2l..z5{right})) |
| 75 |
enddef; |
| 76 |
|
| 77 |
vardef rightserif@#(expr A,B,Bl,Br,alength,midbracket_pull)= |
| 78 |
its_a_leftserif:=false; |
| 79 |
save x,y,p; path p[]; |
| 80 |
min_limit(join_radius)(.5serif_thickness); % -sl 14.04.91 |
| 81 |
full_serif_points@#(A,B,Bl,Br,0,alength,midbracket_pull); |
| 82 |
p4:=z4{z1r-z4}...{Br-z1r}Br; |
| 83 |
if midbracket_pull<>0: |
| 84 |
z4'l=z1r; pos4'(alength+5pt,.5[angle(B-A),0]); |
| 85 |
z9'=p4 intersectionpoint (z4'l--z4'r); |
| 86 |
z9=(midbracket_pull-eps)[z9',z1r];fi |
| 87 |
if ypart A>ypart B:reverse fi |
| 88 |
((z5{right}..z2r if softpath:)softjoin(z2r--z4)softjoin(else:--fi |
| 89 |
if midbracket_pull=0:p4 else:z4{z1r-z4}...z9...{Br-z1r}Br fi)) |
| 90 |
enddef; |
| 91 |
|
| 92 |
vardef fullserif@#(expr A,B,Bl,Br,leftlength,rightlength,midbracket_pull)= |
| 93 |
save x,y,p; path p[]; |
| 94 |
p1=rightserif(A,B,Bl,Br,rightlength,midbracket_pull); |
| 95 |
p2=leftserif(A,B,Bl,Br,leftlength,midbracket_pull); |
| 96 |
if ypart A>ypart B:(p1--p2)else:(p2--p1)fi |
| 97 |
enddef; |
| 98 |
|
| 99 |
|
| 100 |
vardef straightarm@#(expr join,tip,heel,thickness,pull)= |
| 101 |
save x,y,toward,p; pair toward; path p; |
| 102 |
toward=if (str@#="br")or(str@#="tr"):right else:left fi; |
| 103 |
z1=tip if (str@#="br")or(str@#="tr"):- else:+ fi (thickness,0); |
| 104 |
z2=point .5 of (join{toward}...{tip-heel}z1); |
| 105 |
z1-z3=whatever*(tip-heel); y3=ypart join; |
| 106 |
p=z1{z3-z1}...{join-z3}join; |
| 107 |
z4=pull[z3,point .5 of p]; |
| 108 |
if (str@#="br")or(str@#="tl"):reverse fi |
| 109 |
(join{toward}...z4...{tip-heel}z1--tip--heel) |
| 110 |
enddef; |
| 111 |
|
| 112 |
|
| 113 |
vardef constant_angle(expr top_pt,bot_pt,stem)suffix $= |
| 114 |
save theta; |
| 115 |
theta=if str$="lr":-else:+fi (angle(length(top_pt-bot_pt) +-+ stem,stem)); |
| 116 |
angle(top_pt-bot_pt)+theta-90 |
| 117 |
enddef; |
| 118 |
|
| 119 |
|
| 120 |
vardef pos@#(expr b,d) = |
| 121 |
(x@#r-x@#l,y@#r-y@#l)=(b,0)rotated d;x@#=.5(x@#l+x@#r);y@#=.5(y@#l+y@#r)enddef; |
| 122 |
|
| 123 |
vardef mpos(text t)(expr b,d)=forsuffixes $=t:pos$(b,d); endfor enddef; |
| 124 |
|
| 125 |
|
| 126 |
def draw_outlines= pickup pencircle scaled 1.5linethickness; |
| 127 |
for n=1 upto 3:if known p[n]:draw p[n];fi |
| 128 |
if known p[n]':draw p[n]';fi |
| 129 |
if known p[n]'':draw p[n]'';fi endfor |
| 130 |
if numeric mode: % -sl 21.03.1991 |
| 131 |
if mode=proof: drawgrid; fi |
| 132 |
fi % -sl 21.03.1991 |
| 133 |
enddef; |
| 134 |
|
| 135 |
def drawgrid= |
| 136 |
pickup pencircle scaled 1; |
| 137 |
for y:=h,xheight,0,-descender: draw (0,y)--(w,y); endfor |
| 138 |
for y:=unit step unit until (cap+.5unit): draw (0,y)--(w,y); endfor |
| 139 |
for y:=unit step -unit until (-d-.5unit): draw (0,y)--(w,y); endfor |
| 140 |
for x:=0 step unit until (w+.5unit): draw (x,-d)--(x,h); endfor |
| 141 |
enddef; |
| 142 |
|
| 143 |
|
| 144 |
vardef onaline(suffix a,b)(text t)=forsuffixes $=t:z$=whatever[z.a,z.b]; endfor |
| 145 |
enddef; |
| 146 |
|
| 147 |
|
| 148 |
def showpoints(text t)= |
| 149 |
if numeric mode: % -sl 21.03.1991 |
| 150 |
if mode=proof:pickup pencircle scaled 3; |
| 151 |
forsuffixes $:=t:forsuffixes s:=l,,r:if known z$.s:draw z$s;fi endfor endfor |
| 152 |
pickup pencircle scaled 1; penlabels(t); fi |
| 153 |
fi % -sl 21.03.1991 |
| 154 |
enddef; |
| 155 |
|
| 156 |
|
| 157 |
vardef inlimit(text amt)(expr lowerlimit,upperlimit)=save this; |
| 158 |
this:=max(amt,lowerlimit); this:=min(this,upperlimit);this |
| 159 |
enddef; |
| 160 |
|
| 161 |
|
| 162 |
let semi_ = ;; let colon_ = :; let endchar_ = endchar; |
| 163 |
def iff expr b = if b:let next_=use_it else:let next_=lose_it fi; next_ enddef; |
| 164 |
def use_it = let : = restore_colon; enddef; |
| 165 |
def restore_colon = let : = colon_; enddef; |
| 166 |
def lose_it = let endchar=fi; let ;=restore_endchar semi_ if false enddef; |
| 167 |
def restore_endchar=let ;=semi_; let endchar=endchar_; enddef; |
| 168 |
def always_iff expr b = use_it enddef; |
| 169 |
boolean wanted[]; |
| 170 |
|
| 171 |
% for x:="I": |
| 172 |
% wanted[byte x]:=true; endfor |
| 173 |
% this allows specifying only those characters which are to be shown |
| 174 |
% the chars can be specified inside of quotes("c") or as a number(23) |
| 175 |
def OK expr x=known wanted[byte x] enddef; |
| 176 |
% let iff=always_iff; % allows testing of all chars in the file |
| 177 |
|
| 178 |
|
| 179 |
def min_limit(text this)(expr limit)=if this>limit:save this;this=limit;fi |
| 180 |
enddef; |
| 181 |
|
| 182 |
|
| 183 |
% def define_adj_whole_pixels(text t)= |
| 184 |
% forsuffixes $:=t: $:=hround(max(eps,$.#-linethickness#)*hppp); endfor enddef; |
| 185 |
|
| 186 |
def define_min_adj_whole_pixels(text t)= |
| 187 |
forsuffixes $:=t: $:=max(lowres_min,hround(max(eps,$.#-linethickness#)*hppp)); |
| 188 |
endfor enddef; |
| 189 |
|
| 190 |
def bool(text t)=boolean t; t enddef; |
| 191 |
|
| 192 |
def vpix(text t)(text tt)= t:=tt; t:=vround(tt.#*hppp); enddef; % whole v pix |
| 193 |
def wpix(text tt)(text t)= |
| 194 |
forsuffixes $:=t: $:=hround(tt.#*hppp); endfor enddef; % whole pixels |
| 195 |
def adjpix(text tt)(text t)= % adjusted pixels |
| 196 |
forsuffixes $:=t: $:=hround(max(eps,tt.#*hppp-linethickness)); endfor enddef; |
| 197 |
|
| 198 |
def minadjpix(text ttt)(text tt)(text t)= % adjusted pixels with a minimum |
| 199 |
forsuffixes $:=t: $:=max(ttt,hround(tt.#*hppp-linethickness)); |
| 200 |
endfor enddef; |
| 201 |
|
| 202 |
|
| 203 |
def highres_lowres(text t)(expr a,b)=t:=if lowres:b else:a fi enddef; |
| 204 |
|