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