| 1 |
%% |
| 2 |
%% This is file `unibase.mf', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% universa.dtx (with options: `unibase') |
| 8 |
%% |
| 9 |
%% Copyright (C) 1998 Christian Holm. |
| 10 |
%% |
| 11 |
%% This file is NOT the source for universal, because almost all |
| 12 |
%% comments have been stripped from it. It is NOT the preferred |
| 13 |
%% form of universal for making modifications to it. |
| 14 |
%% |
| 15 |
%% Therefore you can NOT redistribute and/or modify THIS file. |
| 16 |
%% You can however redistribute the complete source (universa.dtx |
| 17 |
%% and universa.ins) and/or modify it under the terms of the GNU |
| 18 |
%% General Public License as published by the Free Software |
| 19 |
%% Foundation; either version 2, or (at your option) any later |
| 20 |
%% version. |
| 21 |
%% |
| 22 |
%% The universal font and package is distributed in the hope that |
| 23 |
%% it will be useful, but WITHOUT ANY WARRANTY; without even the |
| 24 |
%% implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 25 |
%% PURPOSE. See the GNU General Public License for more details. |
| 26 |
%% |
| 27 |
%% You should have received a copy of the GNU General Public |
| 28 |
%% License along with this package; if not, write to the |
| 29 |
%% Free Software Foundation, Inc., |
| 30 |
%% 675 Mass Ave, Cambridge, |
| 31 |
%% MA 02139, USA. |
| 32 |
%% |
| 33 |
%% See the file universa.dtx for further comments and documentation. |
| 34 |
%% |
| 35 |
|
| 36 |
unibase := 1 ; |
| 37 |
string univer ; |
| 38 |
univer = "2.0" ; |
| 39 |
if proofing > 1 : |
| 40 |
message "Base file for font `universal', version " & univer ; |
| 41 |
fi |
| 42 |
boolean medium , slant , bold , caps , strict ; |
| 43 |
medium := false ; slant := false ; bold := false ; |
| 44 |
caps := false ; strict := false ; |
| 45 |
font_identifier:="universal"; |
| 46 |
|
| 47 |
def start_font(expr size) = |
| 48 |
u# := size/18 ; |
| 49 |
mode_setup; |
| 50 |
x_h# := 8u# ; x_w# := 8u# ; m_w# := 11u# ; l_h# := 13u# ; |
| 51 |
p_d# := 5u# ; l_s# := 2u# ; r_s# := 2u# ; A_w# := 10u# ; |
| 52 |
M_w# := 14u# ; c_d# := 3u#/2 ; C_d# := 2u# ; |
| 53 |
if (medium and bold) : |
| 54 |
message "Font can't be both medium and bold, making medium font." ; |
| 55 |
medium := true ; |
| 56 |
fi; |
| 57 |
if medium : p_t# := 2u#/3 ; P_t# := u# ; P_T# := u# ; fi ; |
| 58 |
if bold : P_T# := 3u#/2 ; p_t# := 3u#/2 ; P_t# := 2u# ; fi ; |
| 59 |
a_h# := x_h#+p_t#/2 ; |
| 60 |
if (slant and (caps or strict)) : double_shape := 1 ; fi ; |
| 61 |
if (caps and (slant or strict)) : double_shape := 1 ; fi ; |
| 62 |
if (strict and (caps or slant)) : double_shape := 1 ; fi ; |
| 63 |
if known double_shape : |
| 64 |
message "Font cannot be two shapes, doing upright shape." ; |
| 65 |
slant := false ; caps := false ; strict := false ; |
| 66 |
fi ; |
| 67 |
if slant : slantratio := 1/6 ; else: slantratio := 0 ; fi ; |
| 68 |
currenttransform := identity slanted slantratio ; |
| 69 |
font_x_height 8u# ; font_quad 12u#+2u# ; |
| 70 |
font_normal_space 8u# ; font_normal_stretch 3u# ; |
| 71 |
font_normal_shrink 2u# ; font_extra_space 2u# ; |
| 72 |
font_coding_scheme:="TeX text" ; font_size 18u# ; |
| 73 |
spanish_shriek:=hex"3C" ; spanish_query:=hex"3E"; |
| 74 |
define_pixels(u,x_h,x_w,m_w,l_h,p_d,A_w,M_w,c_d,C_d,a_h); |
| 75 |
define_blacker_pixels(p_t,P_t,P_T); |
| 76 |
picture e_pic, a_pic ; |
| 77 |
do_pens ; |
| 78 |
extra_beginchar := extra_beginchar&"fit_font;" ; |
| 79 |
extra_endchar := extra_endchar& |
| 80 |
"end_fit_font;extra_proof_rules;charcode:=charcode+code_offset;" ; |
| 81 |
code_offset := 0 ; |
| 82 |
enddef; |
| 83 |
|
| 84 |
def do_pens = |
| 85 |
clear_pen_memory ; |
| 86 |
pickup pencircle scaled P_T slanted slantratio ; |
| 87 |
UniPencir := savepen ; |
| 88 |
pickup pencircle scaled p_t slanted slantratio ; |
| 89 |
unipencir := savepen ; |
| 90 |
pickup pencircle scaled P_t slanted slantratio ; |
| 91 |
Unipencir := savepen ; |
| 92 |
pickup pensquare scaled P_T slanted slantratio ; |
| 93 |
UniPensqu := savepen ; |
| 94 |
pickup pensquare scaled p_t slanted slantratio ; |
| 95 |
unipensqu := savepen ; |
| 96 |
pickup pensquare scaled P_t slanted slantratio ; |
| 97 |
Unipensqu := savepen ; |
| 98 |
enddef ; |
| 99 |
|
| 100 |
def fit_font = |
| 101 |
l := -hround(l_s#*hppp) ; interim xoffset := -l ; |
| 102 |
charwd := charwd+l_s#+r_s# ; r := l+hround(charwd*hppp) ; |
| 103 |
w := r-hround(r_s#*hppp) ; |
| 104 |
italcorr charht*slantratio ; |
| 105 |
enddef; |
| 106 |
|
| 107 |
def end_fit_font = |
| 108 |
w := r+l ; |
| 109 |
enddef; |
| 110 |
|
| 111 |
def extra_proof_rules = |
| 112 |
if proofing > 1 : |
| 113 |
for xa = l,r,w/2: proofrule((xa,-d), (xa,h)) ; endfor ; |
| 114 |
for ya = 0,h/4,h/2,3h/4,h: proofrule((l,ya), (r,ya)) ; endfor ; |
| 115 |
if d > 0 : |
| 116 |
proofrule((l,-d/2), (r,-d/2)) ; |
| 117 |
proofrule((l,-d), (r,-d)) ; |
| 118 |
fi |
| 119 |
fi |
| 120 |
enddef ; |
| 121 |
|
| 122 |
inner bye; |
| 123 |
def end_font = |
| 124 |
ligtable "u" : "h" kern u# ; |
| 125 |
ligtable "f" : "f" kern 0 , "l" kern 0 , "i" kern 0 ; |
| 126 |
ligtable "o" : "l" kern u# ; |
| 127 |
ligtable "?" : "`" =: spanish_query ; |
| 128 |
ligtable "!" : "`" =: spanish_shriek ; |
| 129 |
ligtable "`" : "`" kern -l_s#-r_s#+p_t# ; |
| 130 |
ligtable "'" : "'" kern -l_s#-r_s#+p_t# , |
| 131 |
"?" kern 2u#, "!" kern 2u# ; |
| 132 |
ligtable "-" : "-" =: hex"7B" ; |
| 133 |
ligtable hex"7B" : "-" =: hex"7C" ; |
| 134 |
ligtable hex"22" : hex"22" kern -l_s#-r_s# ; |
| 135 |
ligtable hex"5C" : hex"5C" kern -l_s#-r_s# ; |
| 136 |
ligtable hex"20" : |
| 137 |
"l" kern -3c_d#*cosd(15)-p_t#*sind(15)-l_s#-r_s# , |
| 138 |
"L" kern -3c_d#*cosd(15)-p_t#*sind(15)-l_s#-r_s# ; |
| 139 |
bye |
| 140 |
enddef ; |
| 141 |
|
| 142 |
def do_caps(expr offset) = |
| 143 |
sc_shrink := x_h#/l_h# ; |
| 144 |
P_t# := sc_shrink*P_t# ; l_h# := sc_shrink*l_h# ; |
| 145 |
A_w# := sc_shrink*A_w# ; M_w# := sc_shrink*M_w# ; |
| 146 |
C_d# := sc_shrink*C_d# ; |
| 147 |
code_offset := offset ; |
| 148 |
define_pixels(l_h,A_w,M_w,C_d) ; |
| 149 |
define_blacker_pixels(P_t) ; |
| 150 |
do_pens ; |
| 151 |
enddef ; |
| 152 |
|
| 153 |
def end_do_caps = |
| 154 |
no_shrink := 1/sc_shrink ; |
| 155 |
P_t# := no_shrink*P_t# ; l_h# := no_shrink*l_h# ; |
| 156 |
A_w# := no_shrink*A_w# ; M_w# := no_shrink*M_w# ; |
| 157 |
C_d# := no_shrink*C_d# ; |
| 158 |
code_offset := 0 ; |
| 159 |
define_pixels(l_h,A_w,M_w,C_d) ; |
| 160 |
define_blacker_pixels(P_t) ; |
| 161 |
do_pens ; |
| 162 |
enddef ; |
| 163 |
|
| 164 |
def no_adjust= |
| 165 |
old_begin_adjust := extra_beginchar ; |
| 166 |
old_end_adjust := extra_endchar ; |
| 167 |
extra_beginchar := " " ; |
| 168 |
extra_endchar := |
| 169 |
"extra_proof_rules;charcode:=charcode+code_offset" ; |
| 170 |
enddef; |
| 171 |
|
| 172 |
def restore_adjust= |
| 173 |
extra_beginchar := old_begin_adjust ; |
| 174 |
extra_endchar := old_end_adjust ; |
| 175 |
enddef; |
| 176 |
string old_begin_adjust, old_end_adjust ; |
| 177 |
|
| 178 |
def unicir(expr rad, thick, center, m)= |
| 179 |
pickup pensquare scaled thick; |
| 180 |
top z[m] = (0,rad) + center ; penpos[m](thick,90) ; |
| 181 |
lft z[m+1] = (-rad,0) + center ; penpos[m+1](thick,180) ; |
| 182 |
bot z[m+2] = (0,-rad) + center ; penpos[m+2](thick,270) ; |
| 183 |
rt z[m+3] = (rad,0) + center ; penpos[m+3](thick,0) ; |
| 184 |
penstroke z[m]e{left}..z[m+1]e{down}.. |
| 185 |
z[m+2]e{right}..z[m+3]e{up}..cycle ; |
| 186 |
penlabels(range m thru m+3); |
| 187 |
enddef; |
| 188 |
|
| 189 |
def uniarc(expr rad, thick, center, ang_a, ang_b, m)= |
| 190 |
pickup pensquare scaled thick ; |
| 191 |
path arc.l, arc.r, arc.e ; n:=m ; ang_c := abs(ang_b-ang_a) ; |
| 192 |
if ang_c >= 360 : |
| 193 |
unicir(rad,center,n) ; |
| 194 |
else: |
| 195 |
top z[n] = (0,rad) + center ; penpos[n](thick,90) ; |
| 196 |
arc.r := z[n]r{left} ; |
| 197 |
arc.l := z[n]l{left} ; |
| 198 |
if ang_c > 90 : |
| 199 |
n := n+1 ; lft z[n] = (-rad,0) + center ; penpos[n](thick,180) ; |
| 200 |
arc.r := arc.r&z[n-1]r..z[n]r{down} ; |
| 201 |
arc.l := arc.l&z[n-1]l..z[n]l{down} ; |
| 202 |
if ang_c > 180 : |
| 203 |
n := n+1 ; bot z[n] = (0,-rad) + center ; penpos[n](thick,270) ; |
| 204 |
arc.r := arc.r&z[n-1]r..z[n]r{right} ; |
| 205 |
arc.l := arc.l&z[n-1]l..z[n]l{right} ; |
| 206 |
if ang_c > 270 : |
| 207 |
n := n+1 ; rt z[n] = (rad,0) + center ; penpos[n](thick,0) ; |
| 208 |
arc.r := arc.r&z[n-1]r..z[n]r{up} ; |
| 209 |
arc.l := arc.l&z[n-1]l..z[n]l{up} ; |
| 210 |
fi ; |
| 211 |
fi ; |
| 212 |
fi ; |
| 213 |
n:=n+1 ; z[n] = z[m] rotatedabout(center,ang_c) ; |
| 214 |
penpos[n](thick,90+ang_c) ; |
| 215 |
arc.r := arc.r&z[n-1]r..z[n]r{dir(180+ang_c)} ; |
| 216 |
arc.l := arc.l&z[n-1]l..z[n]l{dir(180+ang_c)} ; |
| 217 |
arc.e := arc.l--reverse arc.r--cycle; |
| 218 |
fill (arc.e rotatedabout(center,-90+ang_a)); |
| 219 |
fi; |
| 220 |
penlabels(range m thru n); |
| 221 |
enddef; |
| 222 |
|
| 223 |
def uniend(expr rad, center, ang_a, ang_b, m)= |
| 224 |
path arc ; n:=m ; ang_c := abs(ang_b-ang_a) ; |
| 225 |
if ang_c >= 360 : |
| 226 |
Rad := 2*rad ; |
| 227 |
pickup pencircle scaled Rad ; z[n]=center ; drawdot z[n] ; |
| 228 |
else: |
| 229 |
z[n] = (0,rad) + center ; arc := center{up}--z[n]{left} ; |
| 230 |
if ang_c > 90 : |
| 231 |
n := n+1 ; z[n] = (-rad,0) + center ; |
| 232 |
arc := arc&z[n-1]..z[n]{down} ; |
| 233 |
if ang_c > 180 : |
| 234 |
n := n+1 ; z[n] = (0,-rad) + center ; |
| 235 |
arc := arc&z[n-1]..z[n]{right} ; |
| 236 |
if ang_c > 270 : |
| 237 |
n := n+1 ; z[n] = (rad,0) + center ; |
| 238 |
arc := arc&z[n-1]..z[n]{up} ; |
| 239 |
fi ; |
| 240 |
fi ; |
| 241 |
fi ; |
| 242 |
n := n+1 ; z[n] = z[m] rotatedabout(center,ang_c) ; |
| 243 |
arc := arc&z[n-1]..z[n]{dir(180+ang_c)}--cycle ; |
| 244 |
fill (arc rotatedabout(center,-90+ang_a)); |
| 245 |
fi; |
| 246 |
penlabels(range m thru n); |
| 247 |
enddef; |
| 248 |
|
| 249 |
|
| 250 |
def unilne(expr thick, start, stop, endcutstart, endcutstop, m)= |
| 251 |
pickup pensquare scaled thick; |
| 252 |
if endcutstart = endcutstop : |
| 253 |
if endcutstart = 0 : |
| 254 |
lft bot z[m] = start ; rt top z[m+1] = stop ; |
| 255 |
ang_c := angle(z[m+1]-z[m]) ; |
| 256 |
penpos[m](thick,-90+ang_c) ; |
| 257 |
penpos[m+1](thick,-90+ang_c) ; |
| 258 |
elseif endcutstart > 0 : |
| 259 |
lft z[m] = start ; rt z[m+1] = stop ; |
| 260 |
ang_c := angle(z[m+1]-z[m]) ; |
| 261 |
penpos[m](thick/sind(ang_c),0) ; |
| 262 |
penpos[m+1](thick/sind(ang_c),0) ; |
| 263 |
elseif endcutstart < 0: |
| 264 |
bot z[m] = start ; top z[m+1] = stop ; |
| 265 |
ang_c := angle(z[m+1]-z[m]) ; |
| 266 |
penpos[m](thick/cosd(ang_c),90) ; |
| 267 |
penpos[m+1](thick/cosd(ang_c),90) ; |
| 268 |
fi; |
| 269 |
penstroke z[m]e--z[m+1]e ; |
| 270 |
else : |
| 271 |
message "Different endcuts on unilne not implemented yet."; |
| 272 |
fi; |
| 273 |
n := m + 1 ; |
| 274 |
penlabels(range m thru n); |
| 275 |
enddef; |
| 276 |
|
| 277 |
\endinput |
| 278 |
%% |
| 279 |
%% End of file `unibase.mf'. |