1 % -*- Fundamental -*- (emacs-20 mf mode mucks
2 % feta-schrift.mf -- implement scripts
4 % source file of the Feta (defintively not an abbreviation for Font-En-Tja)
7 % (c) 1997 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 % Jan Nieuwenhuizen <janneke@gnu.org>
12 fet_begingroup("scripts")
15 save alpha, radius, crook_thinness, crook_fatness, dot_radius;
17 % [Wanske] and some Baerenreiter editions
18 % suggest ca 80 degrees iso half-circle
21 radius# = 1.25 staff_space#;
22 crook_thinness# = 1.5stafflinethickness#;
23 crook_fatness# = 4 stafflinethickness#;
25 radius# + crook_fatness#/2 = h#;
26 radius# + crook_thinness#/2 = w#;
27 set_char_box(w#, w#, crook_thinness#/2, h#);
29 define_pixels(radius, crook_thinness, crook_fatness);
30 dot_radius = round (4/6 crook_fatness);
33 penpos1(crook_thinness, 0);
34 penpos2(crook_fatness, -90);
38 fill z1l{dir (-alpha-90)}..{dir (90-alpha)}z1r..
39 {right}z2r -- z2l{left} .. cycle;
41 addto currentpicture also
42 currentpicture xscaled -1;
44 pickup pencircle scaled 2dot_radius;
46 bot y4 = - crook_thinness/2;
50 fet_beginchar("fermata up", "ufermata", "ufermata")
55 fet_beginchar("fermata down", "dfermata", "dfermata")
61 % Thumbs are used in cello music.
62 % TODO : thumbs should look like the finger-font and should be placed in
63 % the same way in the score.
66 fet_beginchar("Thumb", "thumb", "thumb")
67 save thin, height, width, thick;
69 height# = staff_space#;
70 thin = 1.2 stafflinethickness;
72 set_char_box(width#/2, width#/2, height#/2, height#/2);
79 penstroke z1e{up} .. {left}z2e;
80 addto currentpicture also currentpicture xscaled -1;
81 addto currentpicture also currentpicture yscaled -1;
86 draw_brush(z3,1.4*thin, z4,0.9*thick);
90 % FIXME: rounded endings
92 % `\accent' is TeX reserved.
93 fet_beginchar("> accent", "sforzato", "sforzatoaccent")
94 set_char_box(.9 staff_space#, .9 staff_space#, .5 staff_space#, .5 staff_space#);
95 save thickness, diminish;
97 thickness = 3/2 stafflinethickness;
98 pickup pencircle scaled thickness;
100 % prevent blobs at crossing lines
106 y2 = .25 thickness* diminish;
110 z3 = whatever [z1, z4];
112 penpos2(thickness*(2 - diminish)/2 , 90);
113 penpos1(thickness, 90);
114 penpos3(thickness, 90);
117 draw (z1 .. z3) yscaled -1;
119 penstroke z3e .. z2e;
120 penstroke (z3e .. z2e) yscaled -1;
126 % Hmm, changed 1.5 to 1.4 to avoid problems with "random" placement of
127 % the dots because of quantization effects for almost integer values. /MB
131 % Hmm. Should not meddle with darkness of font. Check out the
132 % correct value for radius. Maybe we'd better change padding --hwn
134 fet_beginchar("staccato dot", "staccato", "staccato")
136 radius# = 1.4 stafflinethickness#;
137 define_whole_pixels(radius);
138 pickup pencircle scaled 2 radius;
140 set_char_box(radius#, radius#, radius#, radius#);
143 def draw_staccatissimo =
145 height# = .8 staff_space#;
146 radius# = 2 stafflinethickness#;
147 define_whole_pixels(radius);
148 define_pixels(height);
150 draw_brush((0,0), stafflinethickness, (0, height),2 radius);
151 set_char_box(radius#,radius#, blot_diameter#/2, height# + radius#);
154 fet_beginchar("staccatissimo/martellato up", "ustaccatissimo",
160 % FIXEM: scale labels too.
162 fet_beginchar("staccatissimo/martellato down", "dstaccatissimo", "dstaccatissimo")
167 fet_beginchar("portato/single tenuto", "tenuto", "tenuto")
169 thick# = 1.6 stafflinethickness#;
170 define_whole_pixels(thick);
172 set_char_box(.6 staff_space#, .6 staff_space#, thick#/2,thick#/2);
173 pickup pencircle scaled thick;
174 draw_rounded_block((-b,-thick/2),(w,thick/2),thick);
179 % Portato by Heikki Junes <heikki.junes@hut.fi>
184 thick# = 1.4 stafflinethickness#;
185 radius# = 1.4 stafflinethickness#;
186 define_whole_pixels(thick,radius);
188 set_char_box(.6 staff_space#, .6 staff_space#, thick#/2,.5 staff_space#+ radius#);
189 draw_rounded_block((-b,-thick/2),(w,thick/2),thick);
191 pickup pencircle scaled 2 radius;
196 fet_beginchar("portato/tenuto with staccato", "uportato",
202 fet_beginchar("portato/tenuto with staccato", "dportato",
210 save fat_factor, thinness;
211 set_char_box(staff_space#/2, staff_space#/2, 0, 1.1 staff_space#);
214 thinness = stafflinethickness;
216 pickup pencircle scaled thinness;
224 z1 - z4 = whatever * (charwd, -charht);
225 z4 = fat_factor [z3, z5];
227 filldraw z1 -- z2 -- z3 -- z4 -- cycle;
231 fet_beginchar("marcato up", "umarcato", "umarcato")
238 % The down marcato char (not very much used).
239 % Contrary to what some MF/TeX `gurus' believe
240 % it is *point*-symmetric with the "up" version
241 fet_beginchar("marcato down", "dmarcato", "dmarcato")
248 % used in french horn music todo
250 % TODO: too light at 20pt
251 fet_beginchar("open (unstopped)", "open", "ouvert")
252 save thin, height, width, thick;
253 height# = 5/4 width#;
254 height# = staff_space#;
255 thin = 1.2 stafflinethickness;
257 set_char_box(width#/2, width#/2, height#/2, height#/2);
264 penstroke z1e{up} .. {left}z2e;
265 addto currentpicture also currentpicture xscaled -1;
266 addto currentpicture also currentpicture yscaled -1;
270 fet_beginchar("plus (stopped)", "stopped", "plusstop")
272 thick = 2 stafflinethickness;
273 size# = 1.1 staff_space#;
275 set_char_box(size#/2, size#/2, size#/2, size#/2);
276 draw_rounded_block((-b,-thick/2),(w,thick/2),thick);
277 addto currentpicture also currentpicture rotated 90;
282 % A vee with tapered insides to prevent visual blotting
285 def draw_vee (expr width, height, thickness) =
291 pickup pencircle scaled thickness;
299 penpos3(thickness, 0);
300 penpos4(thickness * diminish, 0);
308 penstroke z3e .. z4e;
309 addto currentpicture also currentpicture xscaled -1;
313 fet_beginchar("Upbow", "upbow", "upbow")
314 save ht, wd, thick, diminish;
316 thick = 1.4 stafflinethickness;
317 wd# = 1.3 staff_space#;
319 set_char_box(wd#/2, wd#/2, 0, ht#);
320 draw_vee (wd, ht, thick);
324 fet_beginchar("Downbow", "downbow", "downbow")
325 save stemthick, beamheight;
329 wd# = 1.5 staff_space#;
330 stemthick = 1.2 stafflinethickness;
331 set_char_box(wd#/2, wd#/2, 0, 4/3 staff_space#);
335 draw_rounded_block((-b,h-beamheight),(w,h),blot_diameter);
336 draw_rounded_block((-b,-d),(-b+stemthick,h-stemthick),stemthick);
337 addto currentpicture also currentpicture xscaled -1;
341 % Inspired by a computer-set version of Auf dem Strom by Baerenreiter.
345 save thin, thick, ball_diam, darkness;
346 save wd, ht, thick_nibangle, ball_nib_thick;
350 wd# = 35/16 staff_space#;
351 ht# = 18/17 staff_space#;
352 darkness = 1.20 stafflinethickness;
354 set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);
359 ball_nib_thick = 2.7 darkness;
360 ball_diam = ball_nib_thick + (h - ball_nib_thick) / 10;
371 penpos1(1.1 thick, thick_nibangle);
372 penpos2(thick, thick_nibangle);
374 penpos4(ball_nib_thick, -90);
377 swoosh := z1l{curl 0} .. z2l .. z3l{up} .. {left}z4l
378 -- z4r .. z3r{down} .. z2r{left} ;
379 fill swoosh .. (swoosh scaled -1) .. cycle;
382 y5r = y4l - ball_diam /2;
385 penpos5(1.6 ball_diam/2, 10);
386 penpos6(ball_diam/2, 150);
388 ploop := z4l{left} .. z5l .. z6l -- cycle;
390 fill ploop scaled -1;
395 fet_beginchar("Reverse turn","reverseturn","reverseturn")
397 currentpicture := currentpicture yscaled -1;
403 fet_beginchar("Turn","turn","turn")
413 % Inspired by a (by now) PD edition of Durand & C'ie edition of
414 % Saint-Saens' Celloconcerto no. 1
416 % FIXME take out hardcoded vars.
417 % FIXME the two loops on the `t' should be smoother (and the left one bigger).
418 % FIXME generic macros for serifs: top of the t and bottom of r
422 fet_beginchar("Trill (`tr')","trill","trill")
424 save start_nib_angle, ascender_extra, ex, hair_thick, fatness,
425 slant_angle, slant, t_fatness, r_fatness, kerning, t_overshoot,
426 uitschieter, bulb_size;
430 ascender_extra# = 1/2 ex#;
431 ascender# = ascender_extra# + ex#;
432 ex# = 1.4 staff_space#;
434 start_nib_angle = 20;
436 define_pixels(ex, ascender_extra, ascender, kerning);
438 t_overshoot = 0.03 ex;
440 t_fatness = 0.78 fatness;
441 t_width = 1.9 t_fatness;
442 r_fatness = 0.78 fatness;
443 uitschieter = 0.48 ex;
444 hair_thick = blot_diameter;
445 r_flare = 0.45 r_fatness;
446 r_width = 2 r_fatness + 0.25 kerning;
451 local_copy(transform)(currenttransform);
452 currenttransform := currenttransform slanted slant shifted (- staff_space, 0) ;
456 % try to position in such a way that the center is the visual
459 x1l = 0.2 staff_space;
460 x1r - x1l = t_fatness;
461 penpos1(start_nib_wid, start_nib_angle);
464 penpos2(start_nib_wid, start_nib_angle);
466 z3l = (x2l + 0.5 t_width, - t_overshoot);
468 z4l = (x2l + t_width, 0.23 ex);
469 penpos4(whatever, 200);
470 x4l - x4r = hair_thick;
472 x3r = 0.5 [x4r, x2r];
473 % 1.7 [x3l, x3r] = x4r;
474 y3r - y3l = 0.6 t_fatness;
478 path t_p, krul_p, r_p;
480 z5 = (x2l + t_fatness/2, 2/3 ex);
481 % penpos5(hair_thick, );
483 t_p := z1r{dir (angle(z1l-z1r) + 30)} .. z1l{-dir (angle(z1r-z1l) - 45)}
485 .. tension (1 + .5 slant)
488 .. z4l{up} -- z4r{down}
490 .. tension (1.5 + .7 slant)
491 .. z2r{up} .. z1r -- cycle;
496 pickup pencircle scaled hair_thick;
498 lft x6 = x2l - uitschieter;
499 y6 = y5 ; % - 1/20 ex;
501 z7 = z5 + whatever*dir krul_ang;
504 x7 = 5/10 kerning + x5;
506 penpos7(hair_thick, up_angle + 90);
511 penpos9(r_fatness, 0);
514 y10 = -0.3 stafflinethickness;
515 penpos10(r_fatness, 0);
523 r_p := z7l{z7-z5} .. z9l{down} --- simple_serif (z10l, z10r, -30)
525 .. z7r{z5-z7} -- cycle;
528 set_char_box(.85 staff_space# , .85 staff_space#, 0,ascender#);
531 penpos11(1/4 r_fatness, -4);
534 z13l = (x9l + r_width, y11 - stafflinethickness );
535 penpos13(r_flare, 180);
537 z15 = z13r - (bulb_size * r_fatness,0);
538 z14 = 0.5 [z13l, z15] - (0,bulb_size* r_fatness);
539 z16 = 0.5 [z13l, z15] + (0,bulb_size* r_fatness);
542 fill z11r{up} .. tension 0.94 .. z13r{down} -- z15{down}
543 .. tension 1.0 .. z13l{up}
544 .. z11l{down} -- cycle;
546 fill z15{up} .. tension 1.06 .. z13l{down} .. z14 .. cycle;
550 penlabels(range 1 thru 15);
556 save radius, thickness, wall;
558 radius# := .5 staff_space#;
560 define_pixels(radius);
561 set_char_box(radius#, radius#, radius#, 2/3 staff_space#);
563 thickness := 1.5 stafflinethickness;
564 pickup pencircle scaled thickness;
574 draw z1{down} .. z2{down} .. z3{left};
575 addto currentpicture also currentpicture xscaled -1;
580 fet_beginchar("left heel", "upedalheel", "upedalheel")
585 fet_beginchar("right heel", "dpedalheel", "dpedalheel")
593 thickness := 1.5 stafflinethickness;
594 ht# := 1.5 staff_space#;
596 define_pixels(ht,wd);
599 set_char_box(wd#, wd#, 0, ht#);
600 draw_vee (wd, ht, thickness);
603 fet_beginchar("left toe", "upedaltoe", "upedaltoe")
607 fet_beginchar("right toe", "dpedaltoe", "dpedaltoe")
612 fet_beginchar("Flageolet", "flageolet", "flageolet")
613 save height,width,thickness;
614 height#=4/15 staffsize#;
616 thickness#=blot_diameter#;
617 define_pixels(height,width,thickness);
618 set_char_box(width#/2,width#/2,height#/2,height#/2);
620 pickup pencircle scaled thickness;
624 rt x4 - lft x2 =width;
631 draw z1..z2..z3..z4..cycle;
634 fet_beginchar("Segno", "segno", "segno")
635 save thin, thick, ball_diam, darkness, pointheight;
636 save wd, ht, thick_nibangle, ball_nib_thick;
640 ht# = 3 staff_space#;
641 wd# = 2 staff_space#;
642 darkness = 1.20 stafflinethickness;
644 set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);
649 ball_nib_thick = 2.7 darkness;
650 ball_diam = ball_nib_thick + (w - ball_nib_thick) / 10;
651 pointheight = 2 stafflinethickness;
661 penpos1(thick, 2 thick_nibangle);
662 penpos2(thick, thick_nibangle);
664 penpos4(ball_nib_thick, 180-thick_nibangle);
667 swoosh := z1l{curl 0} .. z2l .. z3l{right} .. {down}z4l
668 -- z4r .. z3r{left} .. z2r{down} ;
669 fill swoosh .. (swoosh scaled -1) .. cycle;
673 x5r = x4l - ball_diam /2;
676 penpos5(1.6 ball_diam/2, 100);
677 penpos6(ball_diam/2, 240);
679 ploop := z4l{down} .. z5l .. z6l -- cycle;
681 fill ploop scaled -1;
688 filldraw z7l--z8l{right}--z8r{down}--z7r{right}--cycle;
689 pickup pencircle scaled 2 thin;
690 draw (-x2r,pointheight);
691 draw (x2r,-pointheight);
694 fet_beginchar("Coda", "coda", "coda")
695 save thin, thick, codawidth, codaheight;
696 thin# = 1.2 stafflinethickness#;
697 thick# = 3.5 stafflinethickness#;
698 codawidth# = 2/3 staff_space#;
699 codaheight# = 1 staff_space#;
700 define_pixels(thin, thick, codawidth, codaheight);
702 set_char_box(codawidth#+thick#, codawidth#+thick#,
703 codaheight#+thick#, codaheight#+thick#);
716 halfcoda := z1l{up} .. z2l{right} .. z3l{down} --
717 z3r{up} .. z2r{left} .. z1r{down} .. cycle;
719 fill (halfcoda scaled -1);
721 draw_gridline((0,-h),(0,h),thin);
722 draw_gridline((-w,0),(w,0),thin);
727 save alpha, thick, thin, ht;
729 thin# = 1.2 stafflinethickness#;
730 thick# = 3 stafflinethickness#;
731 ht# = .6staff_space#;
732 define_pixels(thin, thick,ht);
733 set_char_box(0, .5staff_space#, ht#, ht#);
735 penpos1(thick, alpha);
736 penpos2(thick, alpha+90);
737 penpos3(thin, 180-alpha);
738 penpos4(thin, 90-alpha);
745 fill z1l{dir (alpha+90)} .. z2r{dir alpha} .. z1r{dir (alpha-90)} ..
746 z3l{dir (270-alpha)} .. z4l{dir (alpha+180)} ..
747 z3r{dir (90-alpha)} .. cycle;
750 fet_beginchar("Right Comma","rcomma","rcomma");
754 fet_beginchar("Left Comma","lcomma","lcomma");
759 thick#:=1/24designsize;
760 define_blacker_pixels(thick);
762 rthin:=1/8*staff_space;
763 rthick:=2thick+rthin;
768 save ne,nw,se,sw; pair ne,nw,se,sw;
771 se=dir alpha; nw=dir (alpha+180);
772 ne=dir (alpha+90); sw=dir (alpha-90);
773 penpos1(rthin,alpha+90);
774 penpos2(5/4rthick,alpha);
775 penpos4(5/4rthick,alpha);
776 penpos5(rthin,alpha+90);
777 penpos3(3/4rthick,alpha);
779 z1=(width/2, height) - overshoot*se;
780 z2=2[z4,(width/2,height/2)];
785 z5=2[z1,(width/2,height/2)];
787 z7=z4l+1/2rthin*sw+1/2rthin*se;
788 z8=2[z6,(width/2,height/2)];
789 z9=2[z7,(width/2,height/2)];
791 fill z1l{se}..{se}z6..z3l..z7{se}..{se}z5l..z5r{nw}..{nw}z8..z3r..z9{nw}..{nw}z1r.. cycle;
792 penlabels(1,2,3,4,5,6,7,8,9);
795 fet_beginchar("Arpeggio","arpeggio","arpeggio");
796 %draw_staff (-2, 2, 0.0);
797 save height, overshoot, width;
798 height# = staff_space#;
800 overshoot# = 0.25 staff_space#;
801 define_pixels (height,overshoot,width);
802 set_char_box(0, width#, 0, height#);
806 % Extendable Trill symbol.
808 % Rename me to Trill, rename Trill to Tr?
809 fet_beginchar("Trill-element","trill-element","trillelement");
810 save height, overshoot;
811 height# = staff_space#;
813 overshoot# = 0.25 staff_space#;
814 define_pixels (height,overshoot,width);
815 set_char_box(0, height#, 0, width#);
817 currentpicture := currentpicture shifted -(width/2, height/2);
818 currentpicture := currentpicture rotated 90;
819 currentpicture := currentpicture shifted (height/2, width/2);
825 % Arpeggio arrow by Chris Jackson <chris@fluffhouse.org.uk>
828 def draw_arpeggio_arrow =
829 save thinness, height, width, overshoot, se, sw, ne, nw, alpha;
831 height# = staff_space#;
833 overshoot# = 0.25 staff_space#;
834 define_pixels (height,overshoot,width);
835 set_char_box(0, width#, 0, height#);
837 nw = dir (alpha+180);
838 sw = dir (alpha-90); se = dir alpha;
840 penpos1(rthin, alpha+90);
841 penpos2(5/4 rthick, alpha);
842 penpos3(5/4 rthick, 0);
844 z1 = (width/2, height) - overshoot*se; % numbering is consistent with the arpeggio symbol
845 z2 = 2[z4,(width/2,height/2)];
846 z3 = (0.5 width, 0.5 height);
847 z4 = (0.25 staff_space, rthin);
848 z6 = z2l + 1/2rthin*sw;
849 z9 = (width/2, height) + overshoot*se;
850 fill z1l {se}..{se} z6 .. z3l .. z3r.. z9{nw} ..{nw} z1r.. cycle;
852 bot z10 = ( 0.5w, 0 );
853 lft z11 = (-0.3w, 0.8h);
854 rt z12 = ( 1.3w, 0.8h);
855 pickup pencircle scaled 0.5 rthin;
856 filldraw z3 -- z12 {dir -130} .. {dir -110} z10 {dir 110} .. {dir 130} z11 -- cycle;
859 fet_beginchar("Arpeggio arrow down", "arpeggio-arrow--1", "arpeggioarrowdown");
864 fet_beginchar("Arpeggio arrow up", "arpeggio-arrow-1", "arpeggioarrowup");
866 currentpicture := currentpicture scaled -1 shifted (0.8staff_space, staff_space);
877 fet_endgroup("scripts");