]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-nummer-code.mf
* mf/feta-nummer-code.mf: use ascii names for number glyphs.
[lilypond.git] / mf / feta-nummer-code.mf
1 % feta-nummer.mf -- implement bold Orator numerals
2 %
3 % part of LilyPond's pretty-but-neat music font
4 %
5 % source file of the Feta (not the Font-En-Tja) music font
6
7 % (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
8
9 %
10 % These numbers were taken from a part that that the EJE violas played
11 % 1997 -- Probably Mendelssohn's ouverture Heimkehr aus der Fremde.
12 %
13
14 %
15 % TODO all the invocation of flare_path are weird -- 
16 % the horizontal tangents should be more at the center of the 
17 % glyph.
18 %
19
20 define_pixels(height,thick,thick,thin,hair,flare);
21 define_pixels(foot_top,foot_width);
22 define_pixels(kuulleke);
23
24 %
25 % Yet Another Bulb Routine with smooth inside curve.
26 %
27 % alpha = start direction.
28 % beta = which side to turn to.
29 % flare = diameter of the bulb
30 % line = diameter of line attachment
31 % direction = is ink on left or right side (1 or -1)
32 %
33
34
35 % move_away_to = amount left (for 2) 
36 % turn_to  = amount down (for  2 )
37
38 def number_flare_path(expr pos,alpha,beta,line,flare,
39
40                         move_away_to,
41                         turn_to, taille, taille_ratio,
42                         direction) =
43         begingroup;
44         clearxy;
45
46 %       z5 = z2 + 0.43* flare *dir (alpha - 1.5 beta);
47
48         z4 = (0.75 - taille)  [z2r, z2l] + whatever* dir (alpha - beta) ;
49         z4 = (taille_ratio * taille) [z3l, z3r] + whatever* dir(alpha);
50         penpos1(line,180+beta+alpha);
51         z1r=pos;
52
53         z2r = z1r + move_away_to *dir (alpha) + (line + turn_to) * dir(alpha+beta);
54         z3r = 0.5 [z2l,z2r] + 0.5 *flare *dir(alpha + beta);
55
56         penpos2(flare, alpha );
57         penpos3(flare, alpha +  beta);
58         penlabels(1, 2, 3, 4, 5);
59         pickup pencircle;
60
61         save p;
62         path p;
63         p := z1r{dir(alpha)}
64                 .. z2r{dir(180+alpha-beta)}
65                 .. z3r{dir(alpha+180)}
66                 .. z2l{dir(alpha-beta)} 
67
68
69 %%% Two versions of the curve: one with z4, the other with z5.
70 %               .. z5{dir(alpha- beta/2 )}
71                 ..z4{dir(180+alpha+beta)}
72                 ..z1l{dir(alpha+180)};
73 %       draw p ;
74         if direction = 1:
75                 p
76         else:
77                 reverse p
78         fi
79         endgroup
80         enddef;
81
82
83
84 def calc_kuulleke(expr w,alpha) = 
85         begingroup;
86         save beta; beta=(alpha-90)/2;
87         save gamma; gamma=(90+alpha)/2;
88
89         penpos1(w/cosd(alpha),alpha);
90         penpos2(hair,90+beta);
91         z2=z1l+(1/2hair/tand((alpha+90)/2))*dir(beta);
92
93         penpos3(hair,gamma-90);
94         z3=z1r-(1/2hair/tand((90-alpha)/2))*dir(gamma);
95         z4=z1+kuulleke*dir(alpha-90);
96         endgroup;
97         enddef;
98
99 % should make generic macro? 
100 %
101 def draw_foot(expr xpos) = 
102         begingroup;
103         clearxy;
104         penpos1(thick,0);
105         z1=(xpos,foot_top);
106         penpos2(foot_width,0);
107         z2=(x1,0);
108         penpos3(hair,-90);
109         z3r=z2r;
110         penpos4(hair,90);
111         z4l=z2l;
112         z5=(x1,kuulleke);
113         penlabels(1,2,3,4);
114         fill z1..{right}z1r{down}..{right}z3l..z3r{left}..z5
115                 ..{left}z4l..z4r{right}..{up}z1l{right}..z1..cycle;
116         endgroup;
117         enddef;
118
119 def draw_six =
120         set_char_box(0, .68  height#*widen, 0, height#);
121         message "w:"&decimal w;
122         message "h:"&decimal h;
123
124         penpos1(thin,90);
125         z1=(thick,h/2+thin-hair/2);
126         penpos2(hair,90);
127         
128         z2=(w/2,y1);
129
130         penpos3 (15/16 thick,0);
131         % yup, should use the path fract [] "everywhere"
132         x3r=w;
133         y3r = .5 [y4r, y2r];
134         penpos4(hair,-90);
135         z4r=(x2,0);
136         penpos6(hair,90);
137         x6r = .56 w;
138         y6r = h;
139         penpos7(thick,180);
140
141         x7r=0;
142         y7r = .50 h;
143
144         penpos10(thick,180);
145         z10r=(0,y3);
146         penlabels(1,2,3,4,5,6,7,8,9,10,11);
147
148
149         save outer_t; outer_t= 0.88;
150         save t ; t := tense; 
151         fill
152 %       draw
153                 z7{right}..z2r{right}
154                 ..tension outer_t
155                 ..z3r{down}
156                 ..tension outer_t
157                 ..z4r{left}
158 %               ..tension t
159                 ..z7r{up}
160 %               .. flare_path (z6r,0,-90,hair,flare, 1)
161                 .. number_flare_path (z6r, 0,-90,hair,flare,
162                         w - x6r -hair/2, .16 h, 0.05, 2.5, 1)
163
164 %               ..tension t
165                 ..z7l{down}
166                  .. {down}z10l -- cycle;
167
168         unfill z2l{right}..tension t..z3l{down}..tension t
169                 ..z4l{left}..tension t..z10l{up}..tension t..cycle;
170         enddef;
171
172 save dot_diam;
173 dot_diam# = 7/8flare#;
174 define_pixels(dot_diam);
175
176 code := 31; % , 32
177 fet_beginchar("Space", "space", "space")
178         set_char_box(0, space#,  0,height#);
179 fet_endchar;
180
181 code := 43;  % , = 44 
182
183 % urg
184 fet_beginchar("Numeral comma", "comma", "comma")
185         set_char_box(0, dot_diam#, 3/2dot_diam#, dot_diam#);
186         pickup pencircle scaled dot_diam;
187         draw (dot_diam/2,dot_diam/2);
188         z0=(w/3,0);
189         alpha=65;
190         penpos1(thin,alpha+90);
191         z1l=(w/2,-1.5h+hair);
192         z2=(w,h/2);
193         pickup pencircle;
194         filldraw z1l{dir(alpha)}..{up}z2..{z0-z2}z0{right}..{dir(180+alpha)}z1r..cycle;
195         labels(0,1,2);
196         penlabels(1);
197 fet_endchar;
198
199 fet_beginchar("Numeral dash", "hyphen", "hyphen")
200         set_char_box(0, height#/3, 0, height#);
201         pickup pencircle scaled thin;
202         lft x1 = -b;
203         rt x2 = w;
204         y1 = y2 = h/3;
205         draw z1 .. z2;
206 fet_endchar;
207
208 fet_beginchar("Numeral dot", "period", "period")
209         set_char_box(0, dot_diam#, 0, dot_diam#);
210         pickup pencircle scaled dot_diam;
211         draw (dot_diam/2,dot_diam/2);
212 fet_endchar;
213
214
215 % skip slash
216
217 code := 47; % 0 = 48
218
219 fet_beginchar("Numeral 0", "zero", "zero")
220         set_char_box(0, 11/15height# * widen, 0, height#);
221         message "w:"&decimal w;
222         message "h:"&decimal h;
223         penpos1(thin,90);
224         z1r=(w/2,h);
225         penpos2(thick,180);
226         z2r=(0,h/2);
227         penpos3(thin,-90);
228         z3r=(w/2,0);
229         penpos4(thick,0);
230         z4r=(w,h/2);
231         fill z1r..z2r..z3r..z4r..cycle;
232         save t; t=1/tense;
233         penlabels(1,2,3,4);
234         unfill z1l..tension t..z2l..tension t..z3l
235                 ..tension t..z4l..tension t..cycle;
236 fet_endchar;
237         
238 fet_beginchar("Numeral 1", "one", "one")
239 %       set_char_box(0, 19/30height#*widen, 0, height#);
240         set_char_box(0, 1/2foot_width#+3/2thick#+1/2hair#, 0, height#);
241         message "w:"&decimal w;
242         message "h:"&decimal h;
243
244         save alpha; alpha=0;
245         calc_kuulleke(thick,alpha);
246         z1=(3/2thick,height);
247
248         penpos5(thick,0);
249         z5=(x1,foot_top);
250         
251         z6=(0,h/2);
252         save beta; beta=angle(z1l-z6);
253         penpos7(thin,beta-90);
254         z7l=z6;
255         penpos8(thin/cosd(beta),-90);
256         z8l=z1l;
257         penpos9(thin,beta-90);
258         z9r=z8r+(thin/cosd(beta))*(0,-1);
259         penlabels(1,2,3,4,5,6,7,8,9);
260         save gamma; gamma=angle(length(z1r-z1),+2kuulleke);
261         fill z2r{dir(alpha-gamma)}..z4..{dir(alpha+gamma)}z3l..z3r{down}
262                 ..{down}z5r{left}..z5..{left}z5l{up}..{up}z2l..cycle;
263         fill z7l{dir(beta)}..{dir(beta)}z1l..z2r..z9r{up}
264                 ..z9l{dir(180+beta)}..{dir(180+beta)}z7r..cycle;
265         penlabels(7,8,9);
266
267         draw_foot(x1);
268 fet_endchar;
269
270 fet_beginchar("Numeral 2", "two", "two")
271         set_char_box(0, 22/30 height#*widen, 0, height#);
272         message "w:"&decimal w;
273         message "h:"&decimal h;
274         clearxy;
275         save alpha; alpha=-45*widen;
276         save beta; beta=85;
277         save gamma; gamma=beta-10;
278         save flare_start_distance;
279
280         flare_start = 0.25 ;
281         save theta; theta=20/widen;
282         penpos1(hair,90+beta);
283         z1=(0,0)+(1/2sqrt(2)*hair)*dir(45);
284         penpos3(hair,90+gamma);
285         z3=(w,thick)+(1/2sqrt(2)*hair)*dir(-135);
286         penpos2(thick, 90+alpha -15);
287         x2-x1=x3-x2;
288         y2=10/16 thick/widen;
289         fill z1r{dir(beta)}.. tension 0.9 .. {dir(alpha + 10)}z2r..{dir(gamma)}z3r
290                 ..z3l{dir(180+gamma)}..{dir(180+alpha - 5)}z2l
291                 ..{dir(180+beta)}z1l..cycle;
292
293         penpos4(thick,0);
294         z4r=(w-thin/2, .71 h);
295         penpos5(hair,90);
296         y5r = h;
297         x5r = 9/20 w ;
298
299         penlabels(1,2,3,4);
300         penlabels(5,6);
301         save t; t=tense;
302
303         save p;
304         path p ;
305         p := z1l{dir(beta)}..tension t..z4r{up}
306                 .. number_flare_path(z5r,180,90,hair, 1.05 flare,
307                                 x5r  - 1/2 hair,
308                                 .21 h, 0.006, 0.4, 1)
309                 .. z4l{down}..tension t
310                 ..{dir(180+beta)}z1r..cycle;
311
312         pickup pencircle scaled 1;
313 %       draw p;
314         fill p;
315
316 fet_endchar;
317
318
319 %%
320 % TODO: should widen a bit. The right edge of the 3 bumps into next glyph in
321 % combinations 
322 %
323 fet_beginchar("Numeral 3", "three", "three")
324         set_char_box(0, 2/3height#*widen, 0, height#);
325         message "w:"&decimal w;
326         message "h:"&decimal h;
327         penpos1(hair,-90);
328
329 %       flare_start = 0.25 ;
330         x1l = 36/80 w;
331         y1l = h;
332         
333 %       z1l=(17/16thick,h);
334         penpos2(7/8thick,180);
335         x2l= w-thick/8;
336         y2l = 3/4h + thick*  3/32; 
337         penpos3(thin,90);
338         z3=(w/2,h/2+1/8thick);
339         penpos4(thin,90);
340         z4=(5/8thick+1/2thin,y3);
341         penpos5(thick,0);
342         x5r=w;
343         y5r = 17/64 h + thick/16;
344
345         penpos6(hair,-90);
346
347         x6r= 37/80 w;
348         y6r = 0;
349         penpos7(3/2thin,90);
350         x7 = .83 w ;
351         y7 = y3;
352         penlabels(1,2,3,4,5,6,7);
353         save alpha; alpha=25;
354         save t; t=tense;
355         save outer_t; outer_t := 0.93;
356         pickup pencircle scaled 1;
357
358 %       draw
359         fill
360                 number_flare_path (z1l, 180, 90, hair,  7/8 flare, x1l - .5 hair,
361                         .16 h, 0.06, 1.5,  -1)
362                 ..tension outer_t
363                 .. z2l{down}
364                 .. tension outer_t
365                 ..z7r{dir(180+alpha)}
366                 ..z7l{dir(-alpha)}
367                 .. tension outer_t 
368                 ..z5r{down}
369                 .. tension outer_t
370                 .. number_flare_path (z6r, 180, -90, hair,  flare, x6l,
371                         .18 h, 0.06, 1.5,  1)
372
373                 .. z5l{up}
374                 ..tension t
375                 ..z3l{left}
376                 ..z4l{left}
377                 ..z4r{right}
378                 ..z3r{right}
379                 ..tension t
380                 ..z2r{up}
381                 ..tension t
382                 .. cycle
383 ;
384 fet_endchar;
385
386
387         
388 fet_beginchar("Numeral 4", "four", "four")
389         set_char_box(0, 4/5height#*widen, 0, height#);
390         message "w:"&decimal w;
391         message "h:"&decimal h;
392
393         save alpha; alpha=0;
394         calc_kuulleke(3/2thick,alpha);
395         z1r=(w-3/4thick,height);
396
397         z5=(thin,1/4height+thin);
398         save beta; beta=angle(z3r-z5);
399         penpos6(thin,-90);
400         z6l=z5;
401         penpos7(thin,-90);
402         y7=y6; x7=w-1/2thin;
403         penpos8(thin,-alpha);
404         z8r=z5;
405         penlabels(1,2,3,4,5,6,7);
406         save gamma; gamma=angle(length(z1r-z1),+2kuulleke);
407         fill z2r{dir(alpha-gamma)}..z4..{dir(alpha+gamma)}z3l
408                 ..z3r{dir(180+beta)}..{dir(180+beta)}z8r{right}
409                 ..{right}z7l..z7r{left}..{left}z6r..z8l{dir(beta)}
410                 ..{up}z2l..cycle;
411
412         clearxy;
413
414         save alpha; alpha=beta;
415         calc_kuulleke(thick,alpha);
416         z1r=(w-3/4thick,height-(3/2thin)/cosd(alpha));
417
418         penpos5(thick,0);
419         z5=(x1,foot_top);
420         
421         save gamma; gamma=angle(length(z1r-z1),+2kuulleke);
422         fill z2r{dir(alpha-gamma)}..z4..{dir(alpha+gamma)}z3l
423                 ..z3r{down}..{down}z5r{left}..z5..{left}z5l{up}
424                 ..{up}z2l..cycle;
425         penlabels(1,2,3,4,5);
426
427         draw_foot(x5);
428 fet_endchar;
429
430 fet_beginchar("Numeral 5", "five", "five")
431         set_char_box(0, 27/40 height#*widen, 0, height#);
432         message "w:"&decimal w;
433         message "h:"&decimal h;
434         calc_kuulleke(w-thin,0);
435
436         z1=(w/2+1/8thick,h);
437         save alpha; alpha=0;
438         penpos5(thin,0);
439         z5l=(x1l,h-15/16thick);
440         penpos6(hair,90-45);
441         z6=z5r+1/2hair*dir(-45);
442         penpos7(thin,0);
443         z7l=(x1l,h/2+thin-hair);
444         penlabels(1,2,3,4,5,6,7);
445         save gamma; gamma=angle(length(z1r-z1),+2kuulleke);
446         fill z2r{dir(alpha-gamma)}..z4..{dir(alpha+gamma)}z3l
447                 ..z3r{dir(-135)}..{left}z6r..z6l{down}..z7r{down}
448                 ..z7l{up}..{up}z2l..cycle;
449         penpos8(thin,90);
450         z8l=(x7r,y7r-1/16thick);
451         penpos9(thin,90);
452
453         
454         y9=10/16[y5,y7];
455         x9 = .36 [x8r, x10r] ;
456
457         penpos10(thick,0);
458         x10r = w+ hair/2;
459         y10r = 1/2[y9r,y11r];
460         penpos11(hair,-90);
461         y11r = 0;
462         x11r = .7 [0, x10l]; 
463
464         penlabels(8,9,10,11, 12);
465         save beta; beta=45;
466
467         save inner_t, outer_t;
468         inner_t= 1.0;
469         outer_t= .85;
470         fill z8r{dir(beta)}..z9r{right}
471                 ..tension outer_t
472                 ..z10r{down}
473                 .. number_flare_path (z11r, 180, -90, hair,  flare, x11l,
474                         .18 h, 0.06, 1.5,  1)
475                 ..z11l{right}
476                 ..tension inner_t
477                 ..z10l{up}
478                 ..tension inner_t
479                 ..z9l{left}..z8l{dir(180+beta+10)}..cycle;
480
481 fet_endchar;
482
483 fet_beginchar("Numeral 6", "six", "six")
484         draw_six;
485 fet_endchar;
486
487 fet_beginchar("Numeral 7", "seven", "seven")
488         set_char_box(0, 11/15height#*widen, 0, height#);
489         message "w:"&decimal w;
490         message "h:"&decimal h;
491
492         save alpha; alpha=-180;
493 if true:
494         penpos1(3/2thick,180+alpha);
495         penpos2(hair,180+alpha-45);
496         z2=z1l+(1/4sqrt(2)*hair)*dir(alpha-135);
497         penpos3(hair,180+alpha+45);
498         z3=z1r+(1/4sqrt(2)*hair)*dir(alpha-45);
499         z4=z1+kuulleke*dir(alpha-90);
500 else:
501         % shit, does not work
502         calc_kuulleke(3/2thick,-alpha);
503 fi
504         z1l=(thin,0);
505
506         save beta; beta=55;
507         penpos5(thin,90+beta);
508         z5=(w,h)+(1/2sqrt(2)*thin)*dir(-135);
509
510         save gamma; gamma=angle(length(z1r-z1),+2kuulleke);
511         save delta; delta=12;
512         pickup pencircle;
513         fill z3l{dir(alpha-gamma)}..z4..{dir(alpha+gamma)}z2r..
514                 z2l{dir(beta+delta)}..{dir(beta)}z5r
515                 ..z5l{dir(180+beta)}..{dir(delta-90)}z3r..cycle;
516         penlabels(1,2,3,4,5);
517
518         clearxy;
519         save alpha; alpha=-45*widen;
520         penpos1(1/2thick,90);
521         z1=(3/2thin,h-(thick+thin)/2);
522         penpos3(thin,90+beta);
523         z3=(w,h)+(1/2sqrt(2)*thin)*dir(-135);
524         penpos2(thick,90+alpha);
525         x2=1/2[x1,x3]-1/4thick; y2=h-15/16thick+thin*widen;
526
527         penpos4(thin,0);
528         z4l=(0,h-thin/2);
529         penpos5(thin,0);
530         z5l=(0,h/2+thin/2);
531
532         penpos6(9/8thick,90);
533         z6r=(thin,y1r+2/16thick);
534         
535         fill z1r{dir(beta)}..{dir(alpha)}z2r..{dir(beta)}z3r
536                 ..z3l{dir(180+beta)}..{dir(180+alpha)}z2l
537                 ..{dir(180+beta)}z1l..z6l{down}..{down}z5r
538                 ..z5l{up}..{up}z4l..z4r{down}..{down}z6r..{right}cycle;
539         penlabels(1,2,3,4,5,6);
540 fet_endchar;
541
542 fet_beginchar("Numeral 8", "eight", "eight")
543         set_char_box(0, 11/15height#*widen, 0, height#);
544         message "w:"&decimal w;
545         message "h:"&decimal h;
546         save alpha; alpha=60;
547         save beta; beta=alpha-15;
548         z1=(w/2,h/2+thick/8);
549         penpos2(14/8 thin,0);
550         z2=(w/3,h/2+thin);
551         penpos3(3/2thin,0);
552         z3l=(0,h/4+thin/2);
553         penpos4(hair,90);
554
555         z4l=(x1 ,0);
556         penpos5(thick,90+90+alpha);
557         z5=z1+w/4*dir(alpha-90);
558         penpos6(thick,90+90+alpha);
559         z6=z1+(w/4-thin/2)*dir(90+alpha);
560         penpos7(hair,90);
561         z7r= (x1 + .02 w ,h);
562         penpos8(3/2thin,0);
563         z8r=(w-thin/2,3/4h+thin/2);
564         penpos9( 13/8 thin,0);
565         z9=(2/3w,h/2);
566         penlabels(1,2,3,4,5,6,7,8,9);
567         save t; t=tense;
568         fill z2r{dir(180+beta)}..z3r{down}..z4r{right}
569                 ..z5r{dir(90+alpha)}..z6r{dir(90+alpha)}
570                 ..tension t..z7r{right}..z8r{down}..z9r{dir(180+beta)}
571                 ..z9l{dir(beta)}..z8l{up}..z7l{left}..z6l{dir(alpha-90)}
572                 ..z5l{dir(alpha-90)}..tension t..z4l{left}..z3l{up}
573                 ..z2l{dir(beta)}..cycle;
574 fet_endchar;
575
576 fet_beginchar("Numeral 9", "nine", "nine")
577         draw_six;
578 %       xy_mirror_char;
579         currentpicture := currentpicture scaled -1;
580         currentpicture := currentpicture shifted (w,h);
581 fet_endchar;
582
583 ligtable "3" : "3" kern 0.1 space#,  "0" kern 0.1 space#; 
584 ligtable "2" : "7" kern 0.15 space#;
585