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.4 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;
283 fet_beginchar("Upbow", "upbow", "upbow")
286 thick = 1.4 stafflinethickness;
287 wd# = 1.3 staff_space#;
291 set_char_box(wd#/2, wd#/2, 0, ht#);
292 pickup pencircle scaled thick;
300 draw z2 -- z1 -- (z2 xscaled -1);
304 fet_beginchar("Downbow", "downbow", "downbow")
305 save stemthick, beamheight;
309 wd# = 1.5 staff_space#;
310 stemthick = 1.2 stafflinethickness;
311 set_char_box(wd#/2, wd#/2, 0, 4/3 staff_space#);
315 draw_rounded_block((-b,h-beamheight),(w,h),blot_diameter);
316 draw_rounded_block((-b,-d),(-b+stemthick,h-stemthick),stemthick);
317 addto currentpicture also currentpicture xscaled -1;
321 % Inspired by a computer-set version of Auf dem Strom by Baerenreiter.
325 save thin, thick, ball_diam, darkness;
326 save wd, ht, thick_nibangle, ball_nib_thick;
330 wd# = 35/16 staff_space#;
331 ht# = 18/17 staff_space#;
332 darkness = 1.20 stafflinethickness;
334 set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);
339 ball_nib_thick = 2.7 darkness;
340 ball_diam = ball_nib_thick + (h - ball_nib_thick) / 10;
351 penpos1(1.1 thick, thick_nibangle);
352 penpos2(thick, thick_nibangle);
354 penpos4(ball_nib_thick, -90);
357 swoosh := z1l{curl 0} .. z2l .. z3l{up} .. {left}z4l
358 -- z4r .. z3r{down} .. z2r{left} ;
359 fill swoosh .. (swoosh scaled -1) .. cycle;
362 y5r = y4l - ball_diam /2;
365 penpos5(1.6 ball_diam/2, 10);
366 penpos6(ball_diam/2, 150);
368 ploop := z4l{left} .. z5l .. z6l -- cycle;
370 fill ploop scaled -1;
375 fet_beginchar("Reverse turn","reverseturn","reverseturn")
377 currentpicture := currentpicture yscaled -1;
383 fet_beginchar("Turn","turn","turn")
393 % Inspired by a (by now) PD edition of Durand & C'ie edition of
394 % Saint-Saens' Celloconcerto no. 1
396 % FIXME take out hardcoded vars.
397 % FIXME the two loops on the `t' should be smoother (and the left one bigger).
398 % FIXME generic macros for serifs: top of the t and bottom of r
402 fet_beginchar("Trill (`tr')","trill","trill")
404 save start_nib_angle, ascender_extra, ex, hair_thick, fatness,
405 slant_angle, slant, t_fatness, r_fatness, kerning, t_overshoot,
406 uitschieter, bulb_size;
410 ascender_extra# = 1/2 ex#;
411 ascender# = ascender_extra# + ex#;
412 ex# = 1.5 staff_space#;
414 start_nib_angle = 20;
416 define_pixels(ex, ascender_extra, ascender, kerning);
418 t_overshoot = 0.03 ex;
420 t_fatness = 8/10 fatness;
421 r_fatness = .75 fatness;
422 uitschieter = 21/40 ex;
423 hair_thick = blot_diameter;
427 local_copy(transform)(currenttransform);
428 currenttransform := currenttransform slanted slant shifted (- staff_space, 0) ;
433 penpos1(start_nib_wid, start_nib_angle);
436 penpos2(start_nib_wid, start_nib_angle);
438 z3l = (11/10 t_fatness, - t_overshoot);
440 z4l = (13/6 t_fatness, 5/16 ex);
441 penpos4(hair_thick, 180);
443 1.9 [z3l, z3r] = z4r;
447 path t_p, krul_p, r_p;
450 t_p := z1l -- z2l{down} .. tension (1 + .5 slant)
453 .. z4l{up} -- z4r{down}
454 .. z3r{left} .. z2r{up} .. z1r -- cycle;
459 pickup pencircle scaled hair_thick;
461 z5 = (t_fatness/2, 2/3 ex);
463 lft x6 = - uitschieter;
466 z7 = z5 + whatever*dir krul_ang;
469 x7 = 5/10 kerning + x5;
471 penpos7(hair_thick, up_angle + 90);
476 penpos8(2 hair_thick, (up_angle +90)/2);
480 penpos9(r_fatness, 0);
484 penpos10(r_fatness, 0);
486 krul_p := z4{up} .. tension 1.1 .. z5
487 .. tension 1 and .75 .. {down}z6
488 .. tension .85 and 1.1 .. z5 --- z7;
490 r_p := z7l{z7-z5} .. z8l{right} .. z9l{down} --- z10l -- z10r
492 .. z8r{left} .. z7r{z5-z7} -- cycle;
494 set_char_box(staff_space# , staff_space#, 0,ascender#);
497 penpos11(1/4 r_fatness, -20);
500 z13 = (x9 + 2 r_fatness, y11 );
501 penpos13(r_fatness, 180);
502 fill z11r{dir 70} .. z13r{down} -- z13l{up} .. z11l{dir 250} -- cycle;
503 penlabels(range 1 thru 15);
506 draw_bulb(-1, z13r, z13l, bulb_size * r_fatness, 1.5);
511 save radius, thickness, wall;
513 radius# := .5 staff_space#;
515 define_pixels(radius);
516 set_char_box(radius#, radius#, radius#, 2/3 staff_space#);
518 thickness := 1.5 stafflinethickness;
519 pickup pencircle scaled thickness;
529 draw z1{down} .. z2{down} .. z3{left};
530 addto currentpicture also currentpicture xscaled -1;
535 fet_beginchar("left heel", "upedalheel", "upedalheel")
540 fet_beginchar("right heel", "dpedalheel", "dpedalheel")
548 thickness := 1.5 stafflinethickness;
549 ht# := 1.5 staff_space#;
551 define_pixels(ht,wd);
554 set_char_box(wd#, wd#, 0, ht#);
556 pickup pencircle scaled thickness;
568 fet_beginchar("left toe", "upedaltoe", "upedaltoe")
572 fet_beginchar("right toe", "dpedaltoe", "dpedaltoe")
577 fet_beginchar("Flageolet", "flageolet", "flageolet")
578 save height,width,thickness;
579 height#=4/15 staffsize#;
581 thickness#=blot_diameter#;
582 define_pixels(height,width,thickness);
583 set_char_box(width#/2,width#/2,height#/2,height#/2);
585 pickup pencircle scaled thickness;
589 rt x4 - lft x2 =width;
596 draw z1..z2..z3..z4..cycle;
599 fet_beginchar("Segno", "segno", "segno")
600 save thin, thick, ball_diam, darkness, pointheight;
601 save wd, ht, thick_nibangle, ball_nib_thick;
605 ht# = 3 staff_space#;
606 wd# = 2 staff_space#;
607 darkness = 1.20 stafflinethickness;
609 set_char_box(wd#/2, wd#/2, ht#/2, ht#/2);
614 ball_nib_thick = 2.7 darkness;
615 ball_diam = ball_nib_thick + (w - ball_nib_thick) / 10;
616 pointheight = 2 stafflinethickness;
626 penpos1(thick, 2 thick_nibangle);
627 penpos2(thick, thick_nibangle);
629 penpos4(ball_nib_thick, 180-thick_nibangle);
632 swoosh := z1l{curl 0} .. z2l .. z3l{right} .. {down}z4l
633 -- z4r .. z3r{left} .. z2r{down} ;
634 fill swoosh .. (swoosh scaled -1) .. cycle;
638 x5r = x4l - ball_diam /2;
641 penpos5(1.6 ball_diam/2, 100);
642 penpos6(ball_diam/2, 240);
644 ploop := z4l{down} .. z5l .. z6l -- cycle;
646 fill ploop scaled -1;
653 filldraw z7l--z8l{right}--z8r{down}--z7r{right}--cycle;
654 pickup pencircle scaled 2 thin;
655 draw (-x2r,pointheight);
656 draw (x2r,-pointheight);
659 fet_beginchar("Coda", "coda", "coda")
660 save thin, thick, codawidth, codaheight;
661 thin# = 1.2 stafflinethickness#;
662 thick# = 3.5 stafflinethickness#;
663 codawidth# = 2/3 staff_space#;
664 codaheight# = 1 staff_space#;
665 define_pixels(thin, thick, codawidth, codaheight);
667 set_char_box(codawidth#+thick#, codawidth#+thick#,
668 codaheight#+thick#, codaheight#+thick#);
681 halfcoda := z1l{up} .. z2l{right} .. z3l{down} --
682 z3r{up} .. z2r{left} .. z1r{down} .. cycle;
684 fill (halfcoda scaled -1);
686 draw_gridline((0,-h),(0,h),thin);
687 draw_gridline((-w,0),(w,0),thin);
692 save alpha, thick, thin, ht;
694 thin# = 1.2 stafflinethickness#;
695 thick# = 3 stafflinethickness#;
696 ht# = .6staff_space#;
697 define_pixels(thin, thick,ht);
698 set_char_box(0, .5staff_space#, ht#, ht#);
700 penpos1(thick, alpha);
701 penpos2(thick, alpha+90);
702 penpos3(thin, 180-alpha);
703 penpos4(thin, 90-alpha);
710 fill z1l{dir (alpha+90)} .. z2r{dir alpha} .. z1r{dir (alpha-90)} ..
711 z3l{dir (270-alpha)} .. z4l{dir (alpha+180)} ..
712 z3r{dir (90-alpha)} .. cycle;
715 fet_beginchar("Right Comma","rcomma","rcomma");
719 fet_beginchar("Left Comma","lcomma","lcomma");
724 thick#:=1/24designsize;
725 define_blacker_pixels(thick);
727 rthin:=1/8*staff_space;
728 rthick:=2thick+rthin;
733 save ne,nw,se,sw; pair ne,nw,se,sw;
736 se=dir alpha; nw=dir (alpha+180);
737 ne=dir (alpha+90); sw=dir (alpha-90);
738 penpos1(rthin,alpha+90);
739 penpos2(5/4rthick,alpha);
740 penpos4(5/4rthick,alpha);
741 penpos5(rthin,alpha+90);
742 penpos3(3/4rthick,alpha);
744 z1=(width/2, height) - overshoot*se;
745 z2=2[z4,(width/2,height/2)];
750 z5=2[z1,(width/2,height/2)];
752 z7=z4l+1/2rthin*sw+1/2rthin*se;
753 z8=2[z6,(width/2,height/2)];
754 z9=2[z7,(width/2,height/2)];
756 fill z1l{se}..{se}z6..z3l..z7{se}..{se}z5l..z5r{nw}..{nw}z8..z3r..z9{nw}..{nw}z1r.. cycle;
757 penlabels(1,2,3,4,5,6,7,8,9);
760 fet_beginchar("Arpeggio","arpeggio","arpeggio");
761 %draw_staff (-2, 2, 0.0);
762 save height, overshoot, width;
763 height# = staff_space#;
765 overshoot# = 0.25 staff_space#;
766 define_pixels (height,overshoot,width);
767 set_char_box(0, width#, 0, height#);
771 % Extendable Trill symbol.
773 % Rename me to Trill, rename Trill to Tr?
774 fet_beginchar("Trill-element","trill-element","trill-element");
775 save height, overshoot;
776 height# = staff_space#;
778 overshoot# = 0.25 staff_space#;
779 define_pixels (height,overshoot,width);
780 set_char_box(0, height#, 0, width#);
782 currentpicture := currentpicture shifted -(width/2, height/2);
783 currentpicture := currentpicture rotated 90;
784 currentpicture := currentpicture shifted (height/2, width/2);
790 % Arpeggio arrow by Chris Jackson <chris@fluffhouse.org.uk>
793 def draw_arpeggio_arrow =
794 save thinness, height, width, overshoot, se, sw, ne, nw, alpha;
796 height# = staff_space#;
798 overshoot# = 0.25 staff_space#;
799 define_pixels (height,overshoot,width);
800 set_char_box(0, width#, 0, height#);
802 nw = dir (alpha+180);
803 sw = dir (alpha-90); se = dir alpha;
805 penpos1(rthin, alpha+90);
806 penpos2(5/4 rthick, alpha);
807 penpos3(5/4 rthick, 0);
809 z1 = (width/2, height) - overshoot*se; % numbering is consistent with the arpeggio symbol
810 z2 = 2[z4,(width/2,height/2)];
811 z3 = (0.5 width, 0.5 height);
812 z4 = (0.25 staff_space, rthin);
813 z6 = z2l + 1/2rthin*sw;
814 z9 = (width/2, height) + overshoot*se;
815 fill z1l {se}..{se} z6 .. z3l .. z3r.. z9{nw} ..{nw} z1r.. cycle;
817 bot z10 = ( 0.5w, 0 );
818 lft z11 = (-0.3w, 0.8h);
819 rt z12 = ( 1.3w, 0.8h);
820 pickup pencircle scaled 0.5 rthin;
821 filldraw z3 -- z12 {dir -130} .. {dir -110} z10 {dir 110} .. {dir 130} z11 -- cycle;
824 fet_beginchar("Arpeggio arrow down", "arpeggio-arrow--1", "arpeggioarrowdown");
829 fet_beginchar("Arpeggio arrow up", "arpeggio-arrow-1", "arpeggioarrowup");
831 currentpicture := currentpicture scaled -1 shifted (0.8staff_space, staff_space);
842 fet_endgroup("scripts");