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