summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/fonts/source/public/universa/unibase.mf
blob: 2436fb8887d7f4f3b9ae3f48a4fbabfceba58546 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
%%
%% This is file `unibase.mf',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% universa.dtx  (with options: `unibase')
%% 
%% Copyright (C) 1998 Christian Holm.
%% 
%% This file is NOT the source for universal, because almost all
%% comments have been stripped from it.  It is NOT the preferred
%% form of universal for making modifications to it.
%% 
%% Therefore you can NOT redistribute and/or modify THIS file.
%% You can however redistribute the complete source (universa.dtx
%% and universa.ins) and/or modify it under the terms of the GNU
%% General Public License as published by the Free Software
%% Foundation; either version 2, or (at your option) any later
%% version.
%% 
%% The universal font and package is distributed in the hope that
%% it will be useful, but WITHOUT ANY WARRANTY; without even the
%% implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
%% PURPOSE.  See the GNU General Public License for more details.
%% 
%% You should have received a copy of the GNU General Public
%% License along with this package; if not, write to the
%%   Free Software Foundation, Inc.,
%%   675 Mass Ave, Cambridge,
%%   MA 02139, USA.
%% 
%% See the file universa.dtx for further comments and documentation.
%% 

unibase := 1 ;
string univer ;
univer = "2.0" ;
if proofing > 1 :
  message "Base file for font `universal', version " & univer ;
fi
boolean medium , slant , bold , caps , strict ;
medium := false ; slant := false  ; bold := false ;
caps := false   ; strict := false ;
font_identifier:="universal";

def start_font(expr size) = 
  u# := size/18 ; 
  mode_setup;
  x_h# :=  8u# ; x_w# := 8u#   ; m_w# := 11u# ; l_h# := 13u# ;
  p_d# :=  5u# ; l_s# := 2u#   ; r_s# :=  2u# ; A_w# := 10u# ;
  M_w# := 14u# ; c_d# := 3u#/2 ; C_d# :=  2u# ;
  if (medium and bold) :
    message "Font can't be both medium and bold, making medium font." ;
    medium := true ;
  fi;
  if medium : p_t# := 2u#/3 ; P_t# := u#    ; P_T# := u#  ; fi ;
  if bold :   P_T# := 3u#/2 ; p_t# := 3u#/2 ; P_t# := 2u# ; fi ;
  a_h# := x_h#+p_t#/2 ;
  if (slant and (caps or strict)) : double_shape := 1 ; fi ;
  if (caps and (slant or strict)) : double_shape := 1 ; fi ;
  if (strict and (caps or slant)) : double_shape := 1 ; fi ;
  if known double_shape :
    message "Font cannot be two shapes, doing upright shape." ;
    slant := false ; caps := false ; strict := false ;
  fi ;
  if slant : slantratio := 1/6 ; else: slantratio := 0 ; fi ;
  currenttransform := identity slanted slantratio ;
  font_x_height 8u#                 ; font_quad 12u#+2u#       ;
  font_normal_space 8u#             ; font_normal_stretch 3u# ;
  font_normal_shrink 2u#            ; font_extra_space 2u#    ;
  font_coding_scheme:="TeX text"    ; font_size 18u#        ;
  spanish_shriek:=hex"3C"           ; spanish_query:=hex"3E";
  define_pixels(u,x_h,x_w,m_w,l_h,p_d,A_w,M_w,c_d,C_d,a_h);
  define_blacker_pixels(p_t,P_t,P_T);
  picture e_pic, a_pic ;
  do_pens ;
  extra_beginchar := extra_beginchar&"fit_font;" ;
  extra_endchar   := extra_endchar&
    "end_fit_font;extra_proof_rules;charcode:=charcode+code_offset;" ;
  code_offset := 0 ;
enddef;

def do_pens =
  clear_pen_memory ;
  pickup pencircle scaled P_T slanted slantratio ;
  UniPencir := savepen ;
  pickup pencircle scaled p_t slanted slantratio ;
  unipencir := savepen ;
  pickup pencircle scaled P_t slanted slantratio ;
  Unipencir := savepen ;
  pickup pensquare scaled P_T slanted slantratio ;
  UniPensqu := savepen ;
  pickup pensquare scaled p_t slanted slantratio ;
  unipensqu := savepen ;
  pickup pensquare scaled P_t slanted slantratio ;
  Unipensqu := savepen ;
enddef ;

def fit_font =
  l := -hround(l_s#*hppp) ; interim xoffset := -l ;
  charwd := charwd+l_s#+r_s# ; r := l+hround(charwd*hppp) ;
  w := r-hround(r_s#*hppp) ;
  italcorr charht*slantratio ;
enddef;

def end_fit_font =
  w := r+l ;
enddef;

def extra_proof_rules =
  if proofing > 1 :
    for xa = l,r,w/2: proofrule((xa,-d), (xa,h)) ; endfor ;
    for ya = 0,h/4,h/2,3h/4,h: proofrule((l,ya), (r,ya)) ; endfor ;
    if d > 0 :
      proofrule((l,-d/2), (r,-d/2)) ;
      proofrule((l,-d), (r,-d)) ;
    fi
  fi
enddef ;

inner bye;
def end_font =
  ligtable "u" : "h" kern u# ;
  ligtable "f" : "f" kern 0 , "l" kern 0 , "i" kern 0 ;
  ligtable "o" : "l" kern u# ;
  ligtable "?" : "`" =: spanish_query ;
  ligtable "!" : "`" =: spanish_shriek ;
  ligtable "`" : "`" kern -l_s#-r_s#+p_t# ;
  ligtable "'" : "'" kern -l_s#-r_s#+p_t# ,
    "?" kern 2u#, "!" kern 2u# ;
  ligtable "-"     : "-" =: hex"7B" ;
  ligtable hex"7B" : "-" =: hex"7C" ;
  ligtable hex"22" : hex"22" kern -l_s#-r_s# ;
  ligtable hex"5C" : hex"5C" kern -l_s#-r_s# ;
  ligtable hex"20" :
    "l" kern -3c_d#*cosd(15)-p_t#*sind(15)-l_s#-r_s# ,
    "L" kern -3c_d#*cosd(15)-p_t#*sind(15)-l_s#-r_s# ;
  bye
enddef ;

def do_caps(expr offset) =
  sc_shrink := x_h#/l_h# ;
  P_t# := sc_shrink*P_t# ; l_h# := sc_shrink*l_h# ;
  A_w# := sc_shrink*A_w# ; M_w# := sc_shrink*M_w# ;
  C_d# := sc_shrink*C_d# ;
  code_offset := offset ;
  define_pixels(l_h,A_w,M_w,C_d) ;
  define_blacker_pixels(P_t) ;
  do_pens ;
enddef ;

def end_do_caps =
  no_shrink := 1/sc_shrink ;
  P_t# := no_shrink*P_t# ; l_h# := no_shrink*l_h# ;
  A_w# := no_shrink*A_w# ; M_w# := no_shrink*M_w# ;
  C_d# := no_shrink*C_d# ;
  code_offset := 0 ;
  define_pixels(l_h,A_w,M_w,C_d) ;
  define_blacker_pixels(P_t) ;
  do_pens ;
enddef ;

def no_adjust=
  old_begin_adjust := extra_beginchar ;
  old_end_adjust   := extra_endchar   ;
  extra_beginchar  := " "             ;
  extra_endchar    :=
  "extra_proof_rules;charcode:=charcode+code_offset" ;
enddef;

def restore_adjust=
  extra_beginchar  := old_begin_adjust   ;
  extra_endchar    := old_end_adjust     ;
enddef;
string old_begin_adjust, old_end_adjust ;

def unicir(expr rad, thick, center, m)=
  pickup pensquare scaled thick;
  top z[m]   = (0,rad)  + center ; penpos[m](thick,90) ;
  lft z[m+1] = (-rad,0) + center ; penpos[m+1](thick,180) ;
  bot z[m+2] = (0,-rad) + center ; penpos[m+2](thick,270) ;
  rt  z[m+3] = (rad,0)  + center ; penpos[m+3](thick,0) ;
  penstroke z[m]e{left}..z[m+1]e{down}..
    z[m+2]e{right}..z[m+3]e{up}..cycle ;
  penlabels(range m thru m+3);
enddef;

def uniarc(expr rad, thick, center, ang_a, ang_b, m)=
  pickup pensquare scaled thick ;
  path arc.l, arc.r, arc.e ; n:=m ; ang_c := abs(ang_b-ang_a) ;
  if ang_c >= 360 :
    unicir(rad,center,n) ;
  else:
    top z[n] = (0,rad) + center ; penpos[n](thick,90) ;
    arc.r := z[n]r{left} ;
    arc.l := z[n]l{left} ;
    if ang_c > 90 :
      n := n+1 ; lft z[n] = (-rad,0) + center ; penpos[n](thick,180) ;
      arc.r := arc.r&z[n-1]r..z[n]r{down} ;
      arc.l := arc.l&z[n-1]l..z[n]l{down} ;
      if ang_c > 180 :
n := n+1 ; bot z[n] = (0,-rad) + center ; penpos[n](thick,270) ;
arc.r := arc.r&z[n-1]r..z[n]r{right} ;
arc.l := arc.l&z[n-1]l..z[n]l{right} ;
if ang_c > 270 :
  n := n+1 ; rt  z[n] = (rad,0) + center ; penpos[n](thick,0) ;
  arc.r := arc.r&z[n-1]r..z[n]r{up} ;
  arc.l := arc.l&z[n-1]l..z[n]l{up} ;
fi ;
      fi ;
    fi ;
    n:=n+1 ; z[n] = z[m] rotatedabout(center,ang_c) ;
    penpos[n](thick,90+ang_c) ;
    arc.r := arc.r&z[n-1]r..z[n]r{dir(180+ang_c)} ;
    arc.l := arc.l&z[n-1]l..z[n]l{dir(180+ang_c)} ;
    arc.e := arc.l--reverse arc.r--cycle;
    fill (arc.e rotatedabout(center,-90+ang_a));
  fi;
  penlabels(range m thru n);
enddef;

def uniend(expr rad, center, ang_a, ang_b, m)=
  path arc ; n:=m ; ang_c := abs(ang_b-ang_a) ;
  if ang_c >= 360 :
    Rad := 2*rad ;
    pickup pencircle scaled Rad ; z[n]=center ; drawdot z[n] ;
  else:
    z[n] = (0,rad) + center ; arc := center{up}--z[n]{left} ;
    if ang_c > 90 :
      n := n+1 ; z[n] = (-rad,0) + center ;
      arc := arc&z[n-1]..z[n]{down} ;
      if ang_c > 180 :
n := n+1 ; z[n] = (0,-rad) + center ;
arc := arc&z[n-1]..z[n]{right} ;
if ang_c > 270 :
  n := n+1 ; z[n] = (rad,0) + center ;
  arc := arc&z[n-1]..z[n]{up} ;
fi ;
      fi ;
    fi ;
    n := n+1 ; z[n] = z[m] rotatedabout(center,ang_c) ;
    arc := arc&z[n-1]..z[n]{dir(180+ang_c)}--cycle ;
    fill (arc rotatedabout(center,-90+ang_a));
  fi;
  penlabels(range m thru n);
enddef;


def unilne(expr thick, start, stop, endcutstart, endcutstop, m)=
  pickup pensquare scaled thick;
  if endcutstart = endcutstop :
    if endcutstart = 0 :
      lft bot z[m] = start ; rt top z[m+1] = stop ;
      ang_c := angle(z[m+1]-z[m]) ;
      penpos[m](thick,-90+ang_c)  ;
      penpos[m+1](thick,-90+ang_c) ;
    elseif endcutstart > 0 :
      lft     z[m] = start ; rt     z[m+1] = stop ;
      ang_c := angle(z[m+1]-z[m]) ;
      penpos[m](thick/sind(ang_c),0) ;
      penpos[m+1](thick/sind(ang_c),0)  ;
    elseif endcutstart < 0:
      bot     z[m] = start ; top    z[m+1] = stop ;
      ang_c := angle(z[m+1]-z[m]) ;
      penpos[m](thick/cosd(ang_c),90) ;
      penpos[m+1](thick/cosd(ang_c),90) ;
    fi;
    penstroke z[m]e--z[m+1]e ;
  else :
    message "Different endcuts on unilne not implemented yet.";
  fi;
  n := m + 1 ;
  penlabels(range m thru n);
enddef;

\endinput
%%
%% End of file `unibase.mf'.