summaryrefslogtreecommitdiff
path: root/fonts/ocr-b/ocrbmac.mf
blob: 105f9dbdd240fa7e1d22eebf5178a961547c624e (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
%%%%%%%%%%%%%%%%% Endehandlung nach Zeichenbestimmung %%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 1995, 2010 Norbert Schwarz
% You may freely use, modify, and/or distribute this file, without limitation.
%
%  Dies wird am Ende jeden Zeichens  v o r  "endchar ausgefuehrt.
%
%  Dort koennen globale Design-Entscheidungen durch evtl.
%  Mehrfachausgaben realisiert wdrden.
%
mode_setup;

pen  penxy;
picture bild; picture bildb;
path negpath;

def dofinishing =
    prule;                  % Rule in xheight-- Hoehe
    for j:=1 step 1 until subchar:
      firstpath:= firstpathcount[j];
      lastpath := lastpathcount[j];
%     message "path "&decimal j ;
%     message "   from "&decimal firstpath;
%     message "   to "&decimal lastpath ;
      if j > 1 :
         penxy := defaultpen;
         if known penrand : defaultpen := defaultpen scaled penrand; fi
         cullit;   undrawallpath;
         if sharpedges>0: cullit; shutedges -1; fi
         defaultpen :=penxy;
         cullit;
      fi
      drawallpath;
%     if globalslant>0 : "with slant"; fi
      if sharpedges>0  :
%          "with sharp edges";
          shutedges 1;
      fi
      if hohl>0   l:
%         "'hohl'";
          cullit;
          pickup pencircle scaled hohl;
          undrawallpath;
          cullit;
          if sharpedges>0  : shutedges -1 ; fi
          cullit;
      fi
      if extraline>0 :
%       " with extraline";
        pickup pencircle scaled extraline;
        drawallpath;
        if sharpedges>0   : shutedges 1; fi
    fi
    endfor
    if negativ > 0:
       cullit; bild:=currentpicture;
       clearit;
    negpath:=  (-0.5*SYMBWIDTH/scalefak ,-0.35maxy)--
               ( 0.5*SYMBWIDTH/scalefak ,-0.35maxy)--
               ( 0.5*SYMBWIDTH/scalefak , 1.2maxy)--
               (-0.5*SYMBWIDTH/scalefak , 1.2maxy)--cycle;
%              (-0.5*SYMBWIDTH/scalefak ,-0.35maxy)..cycle;
        fill  (negpath shifted (shiftfak,0) scaled scalefak);
       cullit;
       bildb := currentpicture;
       clearit;
       currentpicture := bildb-bild;
       cullit;
%      showit;
     fi
    clearallpath;
    enddef;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%def comment text x=
%      for k:=0 step 29 until (length x)+ 28 :
%       special " 9"&substring(k,k+29) of(x&"                              ") ;
%       numspecial 0;numspecial 0; endfor  enddef;

def corrwidth expr x=  charwd:=x/pt;
                        w:=x;
                        h:=w;
                        enddef;
def prule =
       proofrule((0,0.5capheight),(capheight,0.5capheight));
       proofrule((0,0.25capheight),(capheight,0.25capheight));
       proofrule((0,0.75capheight),(capheight,0.75capheight));
       proofrule((0.25capheight,0),(0.25capheight,capheight));
       proofrule((0.75capheight,0),(0.75capheight,capheight));
       proofrule((  0.5capheight,0),(0.5capheight,capheight));enddef;



sheight := 0.75 xheight;

vardef make@#=
   if (length str@#) = 1: charcode:=ASCII str @#; else: charcode:=0; fi
   "Generierung: "&str@#;
   beginchar(charcode,10,10,0);
     char@#;
   endchar;
   enddef;



path allpath[];

def clearallpath =
    subchar := 1;
    firstpathcount[subchar]:=0;
    lastpathcount[subchar]:=-1;
    pathcount:=-1;  enddef;

def nextsubchar =
    subchar := subchar+1;
    firstpathcount[subchar]:=pathcount+1;
    lastpathcount[subchar]:=pathcount;
    enddef;


clearallpath;
pen shutpen;
path unitpath;



def shutedges expr www  =
    unitpath := (-0.5,-0.5)--(0.5,-0.5)--(0.5,0.5)--(-0.5,0.5)..cycle;
    shutwidth := abs pen_lft + pen_rt;
    for i:=firstpath step 1 until lastpath:
        if cycle allpath[i]:
           else:
             shutpen:= makepen (unitpath scaled shutwidth
                       rotated (angle(direction 0 of allpath[i])))
                       slanted  globalslant ;
             pickup shutpen;
                     drawdot ((point 0 of allpath[i])
                             slanted globalslant)
                             withweight www;
             shutpen:= makepen (unitpath scaled shutwidth
                       rotated (angle (direction infinity of allpath[i])))
                       slanted  globalslant ;
             pickup shutpen; drawdot ((point infinity of allpath[i])
                       slanted globalslant)
                      withweight www;
           fi
     endfor
     pickup defaultpen;
     enddef;

def savepath text p =   pathcount:=pathcount+1;
                        lastpathcount[subchar]:=pathcount;
                        allpath[pathcount]:=p;  enddef;

def drawallpath =
    if globalslant=0:
      for i:=firstpath step 1 until lastpath: draw allpath[i]; endfor
      else:
      for i:=firstpath step 1 until lastpath:
              draw (allpath[i] slanted globalslant);
          endfor
      fi
  enddef;

def undrawallpath =
    if globalslant=0:
      for i:=firstpath step 1 until lastpath: undraw allpath[i]; endfor
      else:
      for i:=firstpath step 1 until lastpath:
              undraw (allpath[i] slanted globalslant);
          endfor
      fi
  enddef;


%=====================================================================


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$%%%%%
%%%%%%%%%%%%%% Makros und Konstanten zum Font  O C R B  %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% ==========
designfaktor := designsize*0.1;

capheight := 12.275*mm*designfaktor;        % Hoehe von "E" unskaliert
xheight   := 0.5*capheight * designfaktor;  %
SYMBWIDTH := 2.54mm*designfaktor;           % 10 Zeichen je inch

scalefak  := mm*2.28/11.4*designfaktor; % ================================

path o.s[][];

ocrb.penwidth     := 1.75;        % Strichstaerke
ocrb.width        := 7 + ocrb.penwidth;

pen defaultpen;
defaultpen :=pencircle scaled (ocrb.penwidth*scalefak);
maxy := 12.6 + 0.5ocrb.penwidth;

%shiftfak := 0.5maxy;
shiftfak := (0.5SYMBWIDTH)/scalefak;
path xpath;

%------- font dimensionen
 ptscale := 1/pt;

 font_x_height       (8.5+0.5ocrb.penwidth)*scalefak / pt * designfaktor;
 font_slant          globalslant ;
 font_normal_space   1.0 * SYMBWIDTH    * ptscale;
 font_normal_stretch 0.0 * SYMBWIDTH    * ptscale;
 font_normal_shrink  0.0 * SYMBWIDTH    * ptscale;
 font_quad           2.0 * SYMBWIDTH    * ptscale;
 font_extra_space    1.0 * SYMBWIDTH    * ptscale;

%============= Ligaturtabelle  fuer Umlaute ====================

ligtable "a" : oct"042" =: oct"200";
ligtable "o" : oct"042" =: oct"201";
ligtable "u" : oct"042" =: oct"202";
ligtable "A" : oct"042" =: oct"203";
ligtable "O" : oct"042" =: oct"204";
ligtable "U" : oct"042" =: oct"205";

%===============================================================


def makechar expr charnumber =
 if known o.i[charnumber] :
 beginchar(charnumber,ocrb.width,ocrb.width,0);
 pickup defaultpen;
   kx := 0;
   for i:=1 step 1 until o.i[charnumber]:
     if known o.s[charnumber][i] :
          xpath :=(o.s[charnumber][i] shifted (shiftfak,0) ) scaled scalefak;
          savepath xpath;
          for k:=0 step 1 until (length xpath):
              kx:=kx+1;
              z[kx] = point k of xpath;
          endfor
     fi
  endfor
 if proofing>0 :
   labels(0,1,2,3,4,5,6,7,8,9);
   labels(10,11,12,13,14,15,16,17,18,19);
   labels(20,21,22,23,24,25,26,27,28,29);
   labels(30,31,32,33,34,35,36,37,38,39);
 fi
 dofinishing;
%corrwidth capheight;
 corrwidth SYMBWIDTH;
% Tiefe korrigieren
 if known o.m[charnumber]:
   if (o.m[charnumber]-(0.5*ocrb.penwidth))< 0:
     chardp := ((o.m[charnumber]-(0.5*ocrb.penwidth)) * scalefak ) / pt;
     d :=vround (chardp*pt);
   fi
 fi
 endchar;
 else:
   message "unknown character referenced in makechar";
 fi
enddef;

body_height#:=11.5*scalefak;
asc_height#:= 11.5*scalefak;
cap_height#:= 11.5*scalefak;
fig_height#:= 12.6*scalefak;
x_height#:=    8.5*scalefak;
math_axis#:=   8.5*scalefak;

hohl := lightfactor * ocrb.penwidth * scalefak;   %   0<= lightfactor < 1