]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-noteheads.mf
Merge branch 'master' of git+ssh://git.savannah.gnu.org/srv/git/lilypond
[lilypond.git] / mf / feta-noteheads.mf
1 % Feta (not the Font-En-Tja) music font -- implement noteheads
2 % This file is part of LilyPond, the GNU music typesetter.
3 %
4 % Copyright (C) 1997--2011 Jan Nieuwenhuizen <janneke@gnu.org>
5 % & Han-Wen Nienhuys <hanwen@xs4all.nl>
6 % & Juergen Reuter <reuter@ipd.uka.de>
7 %
8 %
9 % LilyPond is free software: you can redistribute it and/or modify
10 % it under the terms of the GNU General Public License as published by
11 % the Free Software Foundation, either version 3 of the License, or
12 % (at your option) any later version.
13 %
14 % LilyPond is distributed in the hope that it will be useful,
15 % but WITHOUT ANY WARRANTY; without even the implied warranty of
16 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 % GNU General Public License for more details.
18 %
19 % You should have received a copy of the GNU General Public License
20 % along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
21
22 test_outlines := 0;
23
24
25 save remember_pic;
26 picture remember_pic;
27
28
29 % Most beautiful noteheads are pronounced, not circular,
30 % and not even symmetric.
31 % These examples are inspired by [Wanske]; see literature list.
32
33
34
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % NOTE HEAD VARIABLES
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
39 save half_notehead_width, whole_notehead_width;
40 save solfa_noteheight;
41
42 numeric whole_notehead_width;
43 numeric half_notehead_width;
44
45 fet_begingroup ("noteheads");
46
47
48 %
49 % solfa heads should not overlap on chords.
50 %
51 solfa_noteheight# := staff_space# - stafflinethickness#;
52
53 def undraw_inside_ellipse (expr ellipticity, tilt, superness, clearance) =
54 begingroup
55         save pat;
56         path pat;
57
58         pat := superellipse ((ellipticity, 0), (0, 1.0),
59                              (-ellipticity, 0), (0, -1.0),
60                              superness);
61         pat := pat rotated tilt;
62
63         save top_point, right_point;
64         pair top_point, right_point;
65
66         top_point := directionpoint left of pat;
67         right_point := directionpoint up of pat;
68
69         save height, scaling;
70
71         height# = staff_space# + stafflinethickness# - clearance;
72         scaling# = height# / (2 ypart (top_point));
73         define_pixels (scaling);
74         pat := pat scaled scaling shifted (w / 2, .5 (h - d));
75
76         if test_outlines = 1:
77                 draw pat;
78         else:
79                 unfill pat;
80         fi
81 endgroup;
82 enddef;
83
84
85 %
86 % dimensions aren't entirely right.
87 %
88 def draw_longa (expr up) =
89         save stemthick, fudge;
90
91         stemthick# = 2 stafflinethickness#;
92         define_whole_blacker_pixels (stemthick);
93
94         fudge = hround (blot_diameter / 2);
95
96         draw_outside_ellipse (1.80, 0, 0.707, 0);
97         undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
98
99         pickup pencircle scaled stemthick;
100
101         if up:
102                 bot y1 = -d;
103                 top y2 = h;
104                 rt x1 - fudge = 0;
105                 x1 = x2;
106
107                 fudge + lft x3 = w;
108                 x4 = x3;
109                 top y4 = h + 3.0 staff_space;
110                 y3 = y1;
111         else:
112                 bot y1 = -d - 3.0 staff_space;
113                 top y2 = h;
114                 rt x1 - fudge = 0;
115                 x1 = x2;
116
117                 fudge + lft x3 = w;
118                 x4 = x3;
119                 y4 = y2;
120                 bot y3 = -d;
121         fi;
122
123         draw_gridline (z1, z2, stemthick);
124         draw_gridline (z3, z4, stemthick);
125
126         labels (1, 2, 3, 4);
127 enddef;
128
129
130 fet_beginchar ("Longa notehead", "uM2");
131         draw_longa (true);
132
133         draw_staff (-2, 2, 0);
134 fet_endchar;
135
136
137 fet_beginchar ("Longa notehead", "dM2");
138         draw_longa (false);
139
140         draw_staff (-2, 2, 0);
141 fet_endchar;
142
143
144 if test > 0:
145         fet_beginchar ("Longa notehead", "uM2");
146                 draw_longa (true);
147
148                 draw_staff (-2, 2, 0.5);
149         fet_endchar;
150
151
152         fet_beginchar ("Longa notehead", "dM2");
153                 draw_longa (false);
154
155                 draw_staff (-2, 2, 0.5);
156         fet_endchar;
157 fi;
158
159
160 def draw_brevis (expr linecount, line_thickness_multiplier) =
161         save stemthick, fudge;
162
163         stemthick# = line_thickness_multiplier * 2 * stafflinethickness#;
164         define_whole_blacker_pixels (stemthick);
165
166         % Breves of smaller design sizes should have their lines
167         % farther apart (the overlap should be smaller).
168         fudge = hround (blot_diameter *
169                 min (max (-0.15, (0.8 - (20 / (design_size + 4)) + .1 linecount)), 0.3));
170
171         draw_outside_ellipse (1.80, 0, 0.707, 0);
172         undraw_inside_ellipse (1.30, 125, 0.68, 2 stafflinethickness#);
173
174         pickup pencircle scaled stemthick;
175
176         % Breves of smaller design sizes should have their lines longer.
177         line_length := min (max (0.7, (64/60 - (design_size / 60))), 0.85);
178
179         % Line lengths between 0.72 and 0.77 are not nice
180         % because they are neither separate nor connected
181         % when there is an interval of fourth.
182         if line_length < 0.75:
183                 quanted_line_length := min (0.72, line_length);
184         else:
185                 quanted_line_length := max (0.77, line_length);
186         fi;
187
188         bot y1 = -quanted_line_length * staff_space;
189         top y2 = quanted_line_length * staff_space;
190         rt x1 - fudge = 0;
191         x1 = x2;
192
193         fudge + lft x3 = w;
194         x4 = x3;
195         y4 = y2;
196         y3 = y1;
197
198         % Breves of smaller design sizes should have their lines
199         % farther apart.
200         line_distance := (1.95 - 0.008 * design_size) * stemthick;
201         for i := 0 step 1 until linecount - 1:
202                 draw_gridline (z1 - (i * line_distance, 0),
203                                z2 - (i * line_distance, 0),
204                                stemthick);
205                 draw_gridline (z3 + (i * line_distance, 0),
206                                z4 + (i * line_distance, 0),
207                                stemthick);
208         endfor;
209 enddef;
210
211
212 fet_beginchar ("Brevis notehead", "sM1");
213         draw_brevis (1, 1);
214
215         draw_staff (-2, 2, 0);
216 fet_endchar;
217
218
219 if test > 0:
220         fet_beginchar ("Brevis notehead", "sM1");
221                 draw_brevis(1, 1);
222
223                 draw_staff (-2, 2, 0.5);
224         fet_endchar;
225 fi;
226
227
228 fet_beginchar ("Double-lined brevis notehead", "sM1double");
229         draw_brevis (2, 0.8);
230
231         draw_staff (-2, 2, 0);
232 fet_endchar;
233
234
235 if test > 0:
236         fet_beginchar ("Double-lined brevis notehead", "sM1double");
237                 draw_brevis (2, 0.8);
238
239                 draw_staff (-2, 2, 0.5);
240         fet_endchar;
241 fi;
242
243
244 fet_beginchar ("Whole notehead", "s0");
245         draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0, 0.707, 0);
246         undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
247                                0.68, 2 stafflinethickness#);
248
249         whole_notehead_width# := charwd;
250
251         draw_staff (-2, 2, 0);
252 fet_endchar;
253
254
255 if test > 0:
256         fet_beginchar ("Whole notehead", "s0");
257                 draw_outside_ellipse (1.80 - puff_up_factor / 3.0, 0,
258                                       0.707, 0);
259                 undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10,
260                                        0.68, 2 stafflinethickness#);
261
262                 draw_staff (-2, 2, 0.5);
263         fet_endchar;
264 fi;
265
266
267 fet_beginchar ("Half notehead", "s1");
268         draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
269         undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
270
271         half_notehead_width# := charwd;
272
273         draw_staff (-2, 2, 0);
274 fet_endchar;
275
276
277 if test > 0:
278         fet_beginchar ("Half notehead", "s1");
279                 draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34,
280                                       0.66, 0.17);
281                 undraw_inside_ellipse (3.25, 33, 0.81,
282                                        2.5 stafflinethickness#);
283
284                 draw_staff (-2, 2, 0.5);
285         fet_endchar;
286 fi;
287
288
289 fet_beginchar ("Quarter notehead", "s2");
290         draw_quarter_path;
291         draw_staff (-2, 2, 0);
292 fet_endchar;
293
294
295 if test > 0:
296         fet_beginchar ("Quarter notehead", "s2");
297                 draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31,
298                                       0.707, 0);
299
300                 draw_staff (-2, 2, 0.5);
301         fet_endchar;
302 fi;
303
304
305 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306
307
308 fet_beginchar ("Whole diamondhead", "s0diamond");
309         draw_outside_ellipse (1.80, 0, 0.495, 0);
310         undraw_inside_ellipse (1.30, 125, 0.6,
311                                .4 staff_space# + stafflinethickness#);
312
313         draw_staff (-2, 2, 0);
314 fet_endchar;
315
316
317 if test > 0:
318         fet_beginchar ("Whole diamondhead", "s0diamond");
319                 draw_outside_ellipse (1.80, 0, 0.495, 0);
320                 undraw_inside_ellipse (1.30, 125, 0.6,
321                                        .4 staff_space# + stafflinethickness#);
322
323                 draw_staff (-2, 2, 0.5);
324         fet_endchar;
325 fi;
326
327
328 fet_beginchar ("Half diamondhead", "s1diamond");
329         draw_outside_ellipse (1.50, 34, 0.49, 0.17);
330         undraw_inside_ellipse (3.5, 33, 0.80,
331                                .3 staff_space# + 1.5 stafflinethickness#);
332
333         draw_staff (-2, 2, 0);
334 fet_endchar;
335
336
337 if test > 0:
338         fet_beginchar ("Half diamondhead", "s1diamond");
339                 draw_outside_ellipse (1.50, 34, 0.49, 0.17);
340                 undraw_inside_ellipse (3.5, 33, 0.80,
341                                        .3 staff_space#
342                                        + 1.5 stafflinethickness#);
343
344                 draw_staff (-2, 2, 0.5);
345         fet_endchar;
346 fi;
347
348
349 fet_beginchar ("Quarter diamondhead", "s2diamond");
350         draw_outside_ellipse (1.80, 35, 0.495, -0.25);
351
352         draw_staff (-2, 2, 0);
353 fet_endchar;
354
355
356 if test > 0:
357         fet_beginchar ("Quarter diamondhead", "s2diamond");
358                 draw_outside_ellipse (1.80, 35, 0.495, -0.25);
359
360                 draw_staff (-2, 2, 0.5);
361         fet_endchar;
362 fi;
363
364
365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
366
367
368 vardef penposx@# (expr d) =
369 begingroup;
370         save pat;
371         path pat;
372
373         pat = top z@#
374               .. lft z@#
375               .. bot z@#
376               .. rt z@#
377               .. cycle;
378         z@#l = pat intersectionpoint (z@# -- infinity * dir (d + 180));
379         z@#r = pat intersectionpoint (z@# -- infinity * dir (d));
380 endgroup
381 enddef;
382
383
384 %
385 % UGH: xs not declared as argument.
386 %
387 def define_triangle_shape (expr stemdir) =
388         save triangle_a, triangle_b, triangle_c;
389         save triangle_out_a, triangle_out_b, triangle_out_c;
390         save triangle_in, triangle_out;
391         save width, depth, height;
392         save origin, left_up_dir;
393         save exact_left_point, exact_right_point, exact_down_point;
394
395         path triangle_a, triangle_b, triangle_c;
396         path triangle_out_a, triangle_out_b, triangle_out_c;
397         path triangle_in, triangle_out;
398         pair origin, left_up_dir;
399         pair exact_down_point, exact_left_point, exact_right_point;
400
401         save pen_thick;
402         pen_thick# = stafflinethickness# + .1 staff_space#;
403         define_pixels (llap);
404         define_blacker_pixels (pen_thick);
405
406         left_up_dir = llap# * dir (90 + tilt);
407
408         xpart (left_up_dir) * xs - (pen_thick# * xs) / 2 + xpart origin = 0;
409         ypart origin = 0;
410
411         exact_left_point := origin + (left_up_dir xscaled xs);
412         exact_down_point := origin + (left_up_dir rotated 120 xscaled xs);
413         exact_right_point := origin + (left_up_dir rotated 240 xscaled xs);
414
415         height# = ypart (exact_left_point + origin) + pen_thick# / 2;
416         depth# = -ypart (exact_down_point + origin) + pen_thick# / 2;
417         width# = xpart (exact_right_point - exact_left_point)
418                  + pen_thick# * xs;
419
420         set_char_box (0, width#, depth#, height#);
421
422         % Formerly, the shape has simply been drawn with an elliptical pen
423         % (`scaled pen_thick xscaled xs'), but the envelope of such a curve
424         % is of 6th degree.  For the sake of mf2pt1, we approximate it.
425
426         pickup pencircle scaled pen_thick xscaled xs;
427
428         z0 = (hround_pixels (xpart origin), 0);
429
430         z1 = z1' = z0 + llap * dir (90 + tilt) xscaled xs;
431         z2 = z2' = z0 + llap * dir (90 + tilt + 120) xscaled xs;
432         z3 = z3' = z0 + llap * dir (90 + tilt + 240) xscaled xs;
433
434         z12 = caveness [.5[z1, z2], z3];
435         z23 = caveness [.5[z2, z3], z1];
436         z31 = caveness [.5[z3, z1], z2];
437
438         triangle_a = z1 .. z12 .. z2;
439         triangle_b = z2 .. z23 .. z3;
440         triangle_c = z3 .. z31 .. z1;
441
442         penposx1 (angle (direction 0 of triangle_a) - 90);
443         penposx2 (angle (direction 0 of triangle_b) - 90);
444         penposx3 (angle (direction 0 of triangle_c) - 90);
445
446         penposx1' (angle (direction infinity of triangle_c) + 90);
447         penposx2' (angle (direction infinity of triangle_a) + 90);
448         penposx3' (angle (direction infinity of triangle_b) + 90);
449
450         penposx12 (angle (z12 - z0));
451         penposx23 (angle (z23 - z0));
452         penposx31 (angle (z31 - z0));
453
454         z10 = (z0 -- z1) intersectionpoint (z1l .. z12l .. z2'r);
455         z20 = (z0 -- z2) intersectionpoint (z2l .. z23l .. z3'r);
456         z30 = (z0 -- z3) intersectionpoint (z3l .. z31l .. z1'r);
457
458         triangle_in = z10
459                       .. z12l
460                       .. z20
461                       & z20
462                       .. z23l
463                       .. z30
464                       & z30
465                       .. z31l
466                       .. z10
467                       & cycle;
468
469         triangle_out_a = z1r .. z12r .. z2'l;
470         triangle_out_b = z2r .. z23r .. z3'l;
471         triangle_out_c = z3r .. z31r .. z1'l;
472
473         triangle_out = top z1
474                        .. lft z1
475                        .. z1r{direction 0 of triangle_out_a}
476                        & triangle_out_a
477                        & {direction infinity of triangle_out_a}z2'l
478                        .. lft z2
479                        .. bot z2
480                        .. z2r{direction 0 of triangle_out_b}
481                        & triangle_out_b
482                        & {direction infinity of triangle_out_b}z3'l
483                        .. rt z3
484                        .. top z3
485                        .. z3r{direction 0 of triangle_out_c}
486                        & triangle_out_c
487                        & {direction infinity of triangle_out_c}z1'l
488                        .. cycle;
489
490         labels (0, 10, 20, 30);
491         penlabels (1, 1', 2, 2', 3, 3', 12, 23, 31);
492
493         % attachment Y
494         if stemdir = 1:
495                 charwy := ypart exact_right_point;
496                 charwx := xpart exact_right_point + .5 pen_thick# * xs;
497         else:
498                 charwy := -ypart exact_down_point;
499                 charwx := width# - (xpart exact_down_point - .5 pen_thick# * xs);
500         fi
501 enddef;
502
503
504 def draw_whole_triangle_head =
505         save hei, xs;
506         save llap;
507         save tilt;
508
509         tilt = 40;
510         llap# = 3/4 noteheight#;
511
512         xs = 1.5;
513         caveness := 0.1;
514         define_triangle_shape (1);
515         fill triangle_out;
516         unfill triangle_in;
517 enddef;
518
519
520 fet_beginchar ("Whole trianglehead", "s0triangle");
521         draw_whole_triangle_head;
522
523         draw_staff (-2, 2, 0);
524 fet_endchar;
525
526
527 if test > 0:
528         fet_beginchar ("Whole trianglehead", "s0triangle");
529                 draw_whole_triangle_head;
530
531                 draw_staff (-2, 2, 0.5);
532         fet_endchar;
533 fi;
534
535
536 def draw_small_triangle_head (expr dir) =
537         save hei, xs;
538         save llap;
539         save tilt;
540
541         tilt = 40;
542         llap# = 2/3 noteheight#;
543         xs = 1.2;
544         caveness := 0.1;
545         define_triangle_shape (dir);
546
547         pickup feta_fillpen;
548
549         filldraw triangle_out;
550         unfilldraw triangle_in;
551 enddef;
552
553
554 fet_beginchar ("Half trianglehead (downstem)", "d1triangle");
555         draw_small_triangle_head (-1);
556
557         draw_staff (-2, 2, 0);
558 fet_endchar;
559
560
561 fet_beginchar ("Half trianglehead (upstem)", "u1triangle");
562         draw_small_triangle_head (1);
563
564         draw_staff (-2, 2, 0.5);
565 fet_endchar;
566
567
568 def draw_closed_triangle_head (expr dir) =
569         save hei, xs;
570         save llap;
571         save tilt;
572
573         tilt = 40;
574         llap# = 2/3 noteheight#;
575         xs = 1.0;
576         caveness := 0.1;
577         define_triangle_shape (dir);
578         fill triangle_out;
579 enddef;
580
581
582 fet_beginchar ("Quarter trianglehead (upstem)", "u2triangle");
583         draw_closed_triangle_head (1);
584
585         draw_staff (-2, 2, 0);
586 fet_endchar;
587
588
589 fet_beginchar ("Quarter trianglehead (downstem)", "d2triangle");
590         draw_closed_triangle_head (-1);
591
592         draw_staff (-2, 2, 0.5);
593 fet_endchar;
594
595
596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
597 %
598 % Slash heads are for indicating improvisation.  They are
599 % twice as high as normal heads.
600 %
601 def draw_slash (expr hwid_hash) =
602         save exact_height;
603         save ne, nw_dist;
604         pair ne, nw_dist;
605         exact_height = staff_space# + stafflinethickness# / 2;
606
607         set_char_box (0, 2 exact_height / slash_slope + hwid_hash,
608                       exact_height, exact_height);
609
610         charwx := charwd;
611         charwy := charht;
612
613         clearxy;
614
615         d := d - feta_shift;
616
617         pickup pencircle scaled blot_diameter;
618
619         bot y1 = -d;
620         top y2 = h;
621         lft x1 = 0;
622         lft x2 = 2 h / slash_slope;
623
624         rt x3 = w;
625         y3 = y2;
626         y4 = y1;
627         x3 - x2 = x4 - x1;
628
629         ne = unitvector (z3 - z4);
630         nw_dist = (ne rotated 90) * 0.5 blot_diameter;
631
632         fill bot z1{left}
633              .. (z1 + nw_dist){ne}
634              -- (z2 + nw_dist){ne}
635              .. top z2{right}
636              -- top z3{right}
637              .. (z3 - nw_dist){-ne}
638              -- (z4 - nw_dist){-ne}
639              .. bot z4{left}
640              -- cycle;
641
642         if hwid_hash > 2 slash_thick#:
643                 save th;
644
645                 th = slash_thick - blot_diameter;
646                 y6 = y7;
647                 y5 = y8;
648                 y3 - y7 = th;
649                 y5 - y1 = th;
650                 z6 - z5 = whatever * ne;
651                 z8 - z7 = whatever * ne;
652
653                 z5 = z1 + whatever * ne + th * (ne rotated -90);
654                 z8 = z4 + whatever * ne + th * (ne rotated 90);
655
656                 unfill z5
657                        -- z6
658                        -- z7
659                        -- z8
660                        -- cycle;
661         fi
662         labels (range 1 thru 10);
663 enddef;
664
665
666 fet_beginchar ("Whole slashhead", "s0slash");
667         draw_slash (4 slash_thick# + 0.5 staff_space#);
668
669         draw_staff (-2, 2, 0);
670 fet_endchar;
671
672
673 fet_beginchar ("Half slashhead", "s1slash");
674         draw_slash (3.0 slash_thick# + 0.15 staff_space#);
675
676         draw_staff (-2, 2, 0);
677 fet_endchar;
678
679
680 fet_beginchar ("Quarter slashhead", "s2slash");
681         draw_slash (1.5 slash_thick#);
682
683         draw_staff (-2, 2, 0);
684 fet_endchar;
685
686
687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
688 %
689 % `thick' is the distance between the NE/SW parallel lines in the cross
690 % (distance between centres of lines) in multiples of stafflinethickness
691 %
692 def draw_cross (expr thick) =
693         save ne, nw;
694         save ne_dist, nw_dist, rt_dist, up_dist;
695         save crz_in, crz_out;
696         save thickness;
697         pair ne, nw;
698         pair ne_dist, nw_dist, rt_dist, up_dist;
699         path crz_in, crz_out;
700
701         pen_thick# := 1.2 stafflinethickness#;
702         thickness# := thick * stafflinethickness#;
703         define_pixels (thickness);
704         define_blacker_pixels (pen_thick);
705
706         pickup pencircle scaled pen_thick;
707
708         h := h - feta_shift;
709
710         top y3 = h;
711         ne = unitvector ((1, (2 h - pen_thick) / (w - pen_thick)));
712         rt x4 = w / 2;
713         y5 = 0;
714         z4 - z5 = whatever * ne;
715         x6 = 0;
716         z6 - z3 = whatever * ne;
717         z3 - z4 = whatever * (ne yscaled -1);
718
719         z4 - z3 = whatever * (ne) + (ne rotated -90) * thickness;
720
721
722         x1 = charwd / 2 - .5 pen_thick#;
723         z1 = whatever * ne
724              + thick / 2 * stafflinethickness# * (ne rotated -90);
725
726         % labels (1, 2, 3, 4, 5, 6);
727
728         nw = unitvector (z3 - z4);
729
730         up_dist = up * 0.5 pen_thick / cosd (angle (ne));
731         rt_dist = right * 0.5 pen_thick / sind (angle (ne));
732         nw_dist = (ne rotated 90) * 0.5 pen_thick;
733         ne_dist = (nw rotated -90) * 0.5 pen_thick;
734
735         x4' := x4;
736         x5' := x5;
737         y6' := y6;
738
739         x4 := hround (x4' + .5 pen_thick) - .5 pen_thick;
740         x5 := hfloor (x5' + xpart rt_dist) - xpart rt_dist;
741         y6 := vfloor (y6' + ypart up_dist) - ypart up_dist;
742
743         crz_out = (z6 + up_dist)
744                   -- (z3 + nw_dist){ne}
745                   .. (top z3)
746                   .. (z3 + ne_dist){-nw}
747                   -- (z4 + ne_dist){-nw}
748                   .. (rt z4)
749                   .. (z4 - nw_dist){-ne}
750                   -- (z5 + rt_dist);
751         crz_out := crz_out shifted (0, feta_shift)
752                    -- reverse crz_out yscaled -1 shifted (0, -feta_eps);
753         fill crz_out
754              -- reverse crz_out xscaled -1 shifted (-feta_eps, 0)
755              -- cycle;
756
757         if (thick > 1):
758                 x4 := hround (x4' - xpart rt_dist) + xpart rt_dist;
759                 x5 := hceiling (x5' - .5 pen_thick) + .5 pen_thick;
760                 y6 := vfloor (y6' - .5 pen_thick) + .5 pen_thick;
761
762                 crz_in = (bot z6){right}
763                          .. (z6 - nw_dist){ne}
764                          -- (z3 - up_dist)
765                          -- (z4 - rt_dist)
766                          -- (z5 + nw_dist){-ne}
767                          .. {down}(lft z5);
768                 crz_in := crz_in shifted (0, feta_shift)
769                           -- reverse crz_in yscaled -1 shifted (0, -feta_eps);
770                 unfill crz_in
771                        -- reverse crz_in xscaled -1 shifted (-feta_eps, 0)
772                        -- cycle;
773         fi
774
775         % ugh
776         currentpicture := currentpicture shifted (hround (w / 2), 0);
777
778         charwx := charwd;
779         charwy := y1 + feta_shift;
780
781         z12 = (charwx * hppp, y1 * vppp);
782
783         labels (12);
784 enddef;
785
786
787 fet_beginchar ("Whole Crossed notehead", "s0cross");
788         save wid, hei;
789
790         wid# := black_notehead_width# + 4 stafflinethickness#;
791         hei# := noteheight# + stafflinethickness#;
792
793         set_char_box (0, wid#, hei# / 2, hei# / 2);
794
795         draw_cross (3.75);
796
797         remember_pic := currentpicture;
798
799         draw_staff (-2, 2, 0);
800 fet_endchar;
801
802
803 if test > 0:
804         fet_beginchar ("Whole Crossed notehead", "s0cross");
805                 save wid, hei;
806
807                 wid# := black_notehead_width# + 4 stafflinethickness#;
808                 hei# := noteheight# + stafflinethickness#;
809
810                 set_char_box (0, wid#, hei# / 2, hei# / 2);
811
812                 currentpicture := remember_pic;
813
814                 draw_staff (-2, 2, 0.5);
815         fet_endchar;
816 fi;
817
818
819 fet_beginchar ("Half Crossed notehead", "s1cross");
820         save wid, hei;
821
822         wid# := black_notehead_width# + 2 stafflinethickness#;
823         hei# := noteheight# + stafflinethickness# / 2;
824
825         set_char_box (0, wid#, hei# / 2, hei# / 2);
826
827         draw_cross (3.0);
828
829         remember_pic := currentpicture;
830
831         draw_staff (-2, 2, 0);
832 fet_endchar;
833
834
835 if test > 0:
836         fet_beginchar ("Half Crossed notehead", "s1cross");
837                 save wid, hei;
838
839                 wid# := black_notehead_width# + 2 stafflinethickness#;
840                 hei# := noteheight# + stafflinethickness# / 2;
841
842                 set_char_box (0, wid#, hei# / 2, hei# / 2);
843
844                 currentpicture := remember_pic;
845
846                 draw_staff (-2, 2, 0.5);
847         fet_endchar;
848 fi;
849
850
851 fet_beginchar ("Crossed notehead", "s2cross");
852         wid# := black_notehead_width#;
853         hei# := noteheight#;
854         set_char_box (0, wid#, hei# / 2, hei# / 2);
855
856         draw_cross (1.0);
857
858         remember_pic := currentpicture;
859
860         draw_staff (-2, 2, 0);
861 fet_endchar;
862
863
864 if test > 0:
865         fet_beginchar ("Crossed notehead", "s2cross");
866                 wid# := black_notehead_width#;
867                 hei# := noteheight#;
868                 set_char_box (0, wid#, hei# / 2, hei# / 2);
869
870                 currentpicture := remember_pic;
871
872                 draw_staff (-2, 2, 0.5);
873         fet_endchar;
874 fi;
875
876
877 fet_beginchar ("X-Circled notehead", "s2xcircle");
878         save wid, hei;
879         save cthick, cxd, cyd, dy;
880
881         wid# := black_notehead_width# * sqrt (sqrt2);
882         hei# := noteheight# * sqrt (sqrt2);
883
884         set_char_box (0, wid#, hei# / 2, hei# / 2);
885
886         d := d - feta_space_shift;
887
888         cthick# := (1.2 + 1/4) * stafflinethickness#;
889         define_blacker_pixels (cthick);
890
891         cxd := w - cthick;
892         cyd := h + d - cthick / 2;
893
894         dy = .5 (h - d);
895
896         pickup pencircle scaled cthick;
897
898         fill fullcircle xscaled (cxd + cthick)
899                         yscaled (cyd + cthick)
900                         shifted (w / 2, dy);
901         unfill fullcircle xscaled (cxd - cthick)
902                           yscaled (cyd - cthick)
903                           shifted (w / 2, dy);
904
905         xpos := .5 cxd / sqrt2;
906         ypos := .5 cyd / sqrt2;
907
908         pickup penrazor scaled cthick rotated (angle (xpos, ypos) + 90);
909         draw (-xpos + w / 2, -ypos + dy)
910              -- (xpos + w / 2, ypos + dy);
911
912         pickup penrazor scaled cthick rotated (angle (xpos, -ypos) + 90);
913         draw (-xpos + w / 2, ypos + dy)
914              -- (xpos + w / 2, -ypos + dy);
915
916         charwx := charwd;
917         charwy := 0;
918
919         z12 = (charwx * hppp, charwy * vppp);
920         labels (12);
921
922         remember_pic := currentpicture;
923
924         draw_staff (-2, 2, 0);
925 fet_endchar;
926
927
928 if test > 0:
929         fet_beginchar ("X-Circled notehead", "s2xcircle");
930                 save wid, hei;
931                 save cthick, cxr, cyr;
932
933                 wid# := black_notehead_width# * sqrt (sqrt2);
934                 hei# := noteheight# * sqrt (sqrt2);
935
936                 set_char_box (0, wid#, hei# / 2, hei# / 2);
937
938                 currentpicture := remember_pic;
939
940                 draw_staff (-2, 2, 0.5);
941         fet_endchar;
942 fi;
943
944
945 %%%%%%%%
946 %
947 % SOLFA SHAPED NOTES
948 %
949 %
950 % Note: For whole and half notes, the `fill' curve (p_out) is offset from
951 %       the points that specify the outer geometry, because we need to add
952 %       the rounding.  In contrast, the inner curve is not offset, because
953 %       there is no rounding.
954 %
955 %       This means that to get a line of thick_factor * pen_thickness,
956 %       we need to offset the inner curve by
957 %
958 %         (thick_factor - 0.5) * pen_thickness
959 %
960 %       or by
961 %
962 %         (2 * thick_factor - 1) * half_pen_thickness
963 %
964 save solfa_pen_thick;
965 solfa_pen_thick# = 1.3 stafflinethickness#;
966 define_blacker_pixels (solfa_pen_thick);
967
968 save solfa_pen_radius;
969 solfa_pen_radius = 0.5 solfa_pen_thick;
970
971 save solfa_base_notewidth;
972 solfa_base_notewidth# := black_notehead_width#;
973
974 solfa_whole_width := 1.0;
975 solfa_half_width := 1.0;
976 solfa_quarter_width := 1.0;
977
978
979 %%% Do head
980 %
981 % Triangle with base parallel to staff lines.
982 %
983
984 def draw_do_head (expr width_factor, dir, thickness_factor) =
985         save p_in, p_out;
986         save left_dist, right_dist, bottom_dist;
987         path p_in, p_out;
988         pair left_dist, right_dist, bottom_dist;
989
990         set_char_box (0, width_factor * solfa_base_notewidth#,
991                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
992
993         bottom_thick_factor := 2 * thickness_factor - 1;
994         % no different thickness for left side if we want uniform thickness
995         if thickness_factor = 1:
996                 left_thick_factor := 1;
997         else:
998                 left_thick_factor := 0.7 * bottom_thick_factor;
999         fi
1000
1001         save pen_radius;
1002         pen_radius := min (solfa_pen_radius,
1003                            (h + d) / (3 * (1 + bottom_thick_factor)));
1004
1005         pickup pencircle scaled (2 * pen_radius);
1006
1007         bot y1 = -d;
1008         y1 = y2;
1009         lft x1 = 0;
1010         rt x2 = w;
1011         top y3 = h;
1012         x3 = .5 [x1, x2];
1013
1014         left_dist = (unitvector (z3 - z1) rotated 90) * pen_radius;
1015         right_dist = (unitvector (z2 - z3) rotated 90) * pen_radius;
1016         bottom_dist = (0,1) * pen_radius;
1017
1018         save pa, pb, pc;
1019         path pa, pb, pc;
1020         save point_a, point_b, point_c;
1021         pair point_a, point_b, point_c;
1022
1023         pa := (z1 - left_thick_factor * left_dist)
1024               -- (z3 - left_thick_factor * left_dist);
1025         pb := (z1 + bottom_thick_factor * bottom_dist)
1026               -- (z2 + bottom_thick_factor * bottom_dist);
1027         pc := (z2 - right_dist)
1028               -- (z3 - right_dist);
1029
1030         point_a := pa intersectionpoint pb;
1031         point_b := pb intersectionpoint pc;
1032         point_c := pc intersectionpoint pa;
1033
1034         p_in := point_a
1035                 -- point_b
1036                 -- point_c
1037                 -- cycle;
1038
1039         p_out := bot z1
1040                  -- bot z2{right}
1041                  .. rt z2{up}
1042                  .. (z2 + right_dist){z3 - z2}
1043                  -- (z3 + right_dist){z3 - z2}
1044                  .. top z3{left}
1045                  .. (z3 + left_dist){z1 - z3}
1046                  -- (z1 + left_dist){z1 - z3}
1047                  .. lft z1{down}
1048                  .. {right}cycle;
1049
1050         labels (1, 2, 3);
1051
1052         charwx := charwd;
1053         charwy := -chardp + 0.5 stafflinethickness#;
1054         if dir = -1:
1055                 charwy := -charwy;
1056         fi;
1057 enddef;
1058
1059 save do_weight;
1060 do_weight := 2;
1061
1062
1063 fet_beginchar ("Whole dohead", "s0do");
1064         draw_do_head (solfa_whole_width, 1, do_weight);
1065         fill p_out;
1066         unfill p_in;
1067 fet_endchar;
1068
1069
1070 fet_beginchar ("Half dohead", "d1do");
1071         draw_do_head (solfa_half_width, -1, do_weight);
1072         fill p_out;
1073         unfill p_in;
1074 fet_endchar;
1075
1076
1077 fet_beginchar ("Half dohead", "u1do");
1078         draw_do_head (solfa_half_width, 1, do_weight);
1079         fill p_out;
1080         unfill p_in;
1081 fet_endchar;
1082
1083
1084 fet_beginchar ("Quarter dohead", "d2do");
1085         draw_do_head (solfa_quarter_width, -1, do_weight);
1086         fill p_out;
1087 fet_endchar;
1088
1089
1090 fet_beginchar ("Quarter dohead", "u2do");
1091         draw_do_head (solfa_quarter_width, 1, do_weight);
1092         fill p_out;
1093 fet_endchar;
1094
1095
1096 fet_beginchar ("Whole thin dohead", "s0doThin");
1097         draw_do_head (solfa_whole_width, 1, 1);
1098         fill p_out;
1099         unfill p_in;
1100 fet_endchar;
1101
1102
1103 fet_beginchar ("Half thin dohead", "d1doThin");
1104         draw_do_head (solfa_half_width, -1, 1);
1105         fill p_out;
1106         unfill p_in;
1107 fet_endchar;
1108
1109
1110 fet_beginchar ("Half thin dohead", "u1doThin");
1111         draw_do_head (solfa_half_width, 1, 1);
1112         fill p_out;
1113         unfill p_in;
1114 fet_endchar;
1115
1116
1117 fet_beginchar ("Quarter thin dohead", "d2doThin");
1118         draw_do_head (solfa_quarter_width, -1, 1);
1119         fill p_out;
1120 fet_endchar;
1121
1122
1123 fet_beginchar ("Quarter thin dohead", "u2doThin");
1124         draw_do_head (solfa_quarter_width, 1, 1);
1125         fill p_out;
1126 fet_endchar;
1127
1128
1129 %
1130 % re - flat top, curved bottom:
1131 %
1132 %   (0,h/2) {dir -90}
1133 %   .. (w/2,-h/2)
1134 %   .. {dir 90} (w,h/2)
1135 %   -- cycle;
1136 %
1137 % (broader along the base and with more vertical sides for half and
1138 % whole notes)
1139 %
1140 % Note: According to some shape-note singers, there should be no size
1141 %       differences for half and whole notes, contrary to the comment above.
1142 %       Consequently, we have made them all the same width.
1143 %
1144 % stem attachment: h/2
1145 %
1146 def draw_re_head (expr width_factor, dir, thickness_factor) =
1147         save p_in, p_out;
1148         path p_in, p_out;
1149
1150         set_char_box (0, width_factor * solfa_base_notewidth#,
1151                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1152
1153         save offset;
1154         offset = (2 * thickness_factor - 1);
1155
1156         save curve_start;
1157         curve_start = 0.7;
1158
1159         save pen_radius;
1160
1161         pen_radius := min (solfa_pen_radius,
1162                            (h + d) * (1-curve_start) / (1+ offset));
1163
1164         pickup pencircle scaled (2 * pen_radius);
1165
1166         lft x1 = 0;
1167         top y1 = h;
1168         x2 = x1;
1169         y2 = curve_start [y3, y1];
1170         bot y3 = -d;
1171         x3 = .5 [x2, x4];
1172         rt x4 = w;
1173         y4 = y2;
1174         y5 = y1;
1175         x5 = x4;
1176
1177         labels (range 1 thru 5);
1178
1179         p_in := (z1 + pen_radius * (1, -1 * offset))
1180                 -- rt z2{down}
1181                 .. ((top z3) + (0, offset * pen_radius))
1182                 .. lft z4{up}
1183                 -- (z5 + pen_radius * (-1, -1 * offset))
1184                 -- cycle;
1185
1186         p_out := lft z1
1187                  -- lft z2{down}
1188                  .. bot z3
1189                  .. rt z4{up}
1190                  -- rt z5{up}
1191                  .. top z5{left}
1192                  -- top z1{left}
1193                  .. {down}cycle;
1194
1195         charwx := charwd;
1196         charwy := curve_start [-chardp, charht];
1197
1198         if dir = -1:
1199                 charwy := -charwy;
1200         fi;
1201 enddef;
1202
1203
1204 save re_weight;
1205 re_weight := 2;
1206
1207 fet_beginchar ("Whole rehead", "s0re");
1208         draw_re_head (solfa_whole_width, 1, re_weight);
1209         fill p_out;
1210         unfill p_in;
1211 fet_endchar;
1212
1213
1214 fet_beginchar ("Half up rehead", "u1re");
1215         draw_re_head (solfa_half_width, 1, re_weight);
1216         fill p_out;
1217         unfill p_in;
1218 fet_endchar;
1219
1220
1221 fet_beginchar ("Half down rehead", "d1re");
1222         draw_re_head (solfa_half_width, -1, re_weight);
1223         fill p_out;
1224         unfill p_in;
1225 fet_endchar;
1226
1227
1228 fet_beginchar ("Quarter up rehead", "u2re");
1229         draw_re_head (solfa_quarter_width, 1, re_weight);
1230         fill p_out;
1231 fet_endchar;
1232
1233
1234 fet_beginchar ("Quarter down rehead", "d2re");
1235         draw_re_head (solfa_quarter_width, -1, re_weight);
1236         fill p_out;
1237 fet_endchar;
1238
1239
1240 fet_beginchar ("Whole thin rehead", "s0reThin");
1241         draw_re_head (solfa_whole_width, 1, 1);
1242         fill p_out;
1243         unfill p_in;
1244 fet_endchar;
1245
1246
1247 fet_beginchar ("Half up thin rehead", "u1reThin");
1248         draw_re_head (solfa_half_width, 1, 1);
1249         fill p_out;
1250         unfill p_in;
1251 fet_endchar;
1252
1253
1254 fet_beginchar ("Half down thin rehead", "d1reThin");
1255         draw_re_head (solfa_half_width, -1, 1);
1256         fill p_out;
1257         unfill p_in;
1258 fet_endchar;
1259
1260
1261 fet_beginchar ("Quarter thin rehead", "u2reThin");
1262         draw_re_head (solfa_quarter_width, 1, 1);
1263         fill p_out;
1264 fet_endchar;
1265
1266
1267 fet_beginchar ("Quarter thin rehead", "d2reThin");
1268         draw_re_head (solfa_quarter_width, -1, 1);
1269         fill p_out;
1270 fet_endchar;
1271
1272
1273 %%%% mi head -- diamond shape
1274 %
1275 % two versions, depending on whether the `strong' lines are on the nw & se
1276 % or the ne & sw
1277 %
1278 def draw_mi_head (expr width_factor, thickness_factor, mirror) =
1279         save path_out, path_in;
1280         save ne_dist, se_dist, ne, se;
1281         save path_a, path_b, path_c, path_d;
1282         path path_out, path_in;
1283         pair ne_dist, se_dist, ne, se;
1284         path path_a, path_b, path_c, path_d;
1285         save inner_path;
1286         path inner_path;
1287
1288         set_char_box (0, width_factor * solfa_base_notewidth#,
1289                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1290
1291         save offset;
1292         offset := 2 * thickness_factor - 1;
1293
1294         save note_diagonal;
1295
1296         note_diagonal := w / 2 ++ (h + d) / 2;
1297
1298         save pen_radius;
1299
1300         pen_radius := min (solfa_pen_radius,
1301                            .3 * note_diagonal / (1 + offset));
1302
1303         pickup pencircle scaled (2 * pen_radius);
1304
1305         lft x1 = 0;
1306         y1 = 0;
1307         bot y2 = -d;
1308         x2 = .5 [x1, x3];
1309         rt x3 = w;
1310         x4 = x2;
1311         y3 = y1;
1312         top y4 = h;
1313
1314         % inner sides are parallel to outer sides
1315         z6 - z5 = whatever * (z2 - z1);
1316         z8 - z7 = whatever * (z4 - z3);
1317         z8 - z5 = whatever * (z4 - z1);
1318         z7 - z6 = whatever * (z3 - z2);
1319
1320         ne = unitvector (z4 - z1);
1321         se = unitvector (z2 - z1);
1322
1323         ne_dist = (ne rotated 90) * pen_radius;
1324         se_dist = (se rotated 90) * pen_radius;
1325
1326         path_a := (z1 + se_dist)
1327                   -- (z2 + se_dist);
1328         path_b := (z2 + (ne_dist * offset))
1329                   -- (z3 + (ne_dist * offset));
1330         path_c := (z3 - se_dist)
1331                   -- (z4 - se_dist);
1332         path_d := (z4 - (ne_dist * offset))
1333                   -- (z1 - (ne_dist * offset));
1334
1335         z5 = path_a intersectionpoint path_d;
1336         z7 = path_b intersectionpoint path_c;
1337
1338         labels (range 1 thru 8);
1339
1340         inner_path := z5
1341                       -- z6
1342                       -- z7
1343                       -- z8
1344                       -- cycle;
1345
1346         if mirror:
1347                 path_in := inner_path;
1348         else:
1349                 path_in := inner_path reflectedabout (z2, z4);
1350         fi
1351
1352         path_out := lft z1 {down}
1353                     .. (z1 - se_dist){se}
1354                     -- (z2 - se_dist){se}
1355                     .. bot z2 {right}
1356                     .. (z2 - ne_dist){ne}
1357                     -- (z3 - ne_dist){ne}
1358                     .. rt z3 {up}
1359                     .. (z3 + se_dist){-se}
1360                     -- (z4 + se_dist){-se}
1361                     .. top z4 {left}
1362                     .. (z4 + ne_dist){-ne}
1363                     -- (z1 + ne_dist){-ne}
1364                     .. cycle;
1365 enddef;
1366
1367
1368 save mi_weight, mi_width;
1369 mi_weight := 2;
1370 mi_width := 1.2;
1371
1372 fet_beginchar ("Whole mihead", "s0mi");
1373         draw_mi_head (mi_width * solfa_whole_width, mi_weight, false);
1374         fill path_out;
1375         unfill path_in;
1376 fet_endchar;
1377
1378
1379 fet_beginchar ("Half mihead", "s1mi");
1380         draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1381         fill path_out;
1382         unfill path_in;
1383 fet_endchar;
1384
1385
1386 fet_beginchar ("Quarter mihead", "s2mi");
1387         draw_mi_head (mi_width * solfa_quarter_width, mi_weight, false);
1388         fill path_out;
1389 fet_endchar;
1390
1391
1392 fet_beginchar ("Whole mirror mihead", "s0miMirror");
1393         draw_mi_head (mi_width * solfa_whole_width, mi_weight, true);
1394         fill path_out;
1395         unfill path_in;
1396 fet_endchar;
1397
1398
1399 fet_beginchar ("Half  mirror mihead", "s1miMirror");
1400         draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1401         fill path_out;
1402         unfill path_in;
1403 fet_endchar;
1404
1405
1406 fet_beginchar ("Quarter mirror mihead", "s2miMirror");
1407         draw_mi_head (mi_width * solfa_quarter_width, mi_weight, true);
1408         fill path_out;
1409 fet_endchar;
1410
1411
1412 fet_beginchar ("Whole thin mihead", "s0miThin");
1413         draw_mi_head (mi_width * solfa_whole_width, 1, false);
1414         fill path_out;
1415         unfill path_in;
1416 fet_endchar;
1417
1418
1419 fet_beginchar ("Half thin mihead", "s1miThin");
1420         draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1421         fill path_out;
1422         unfill path_in;
1423 fet_endchar;
1424
1425
1426 fet_beginchar ("Quarter thin mihead", "s2miThin");
1427         draw_mi_head (mi_width * solfa_quarter_width, 1, false);
1428         fill path_out;
1429 fet_endchar;
1430
1431
1432 %%%% fa head
1433 %
1434 % Right triangle, hypotenuse from nw to se corner.  Stem attaches on
1435 % vertical side in direction of horizontal side.
1436 %
1437 def draw_fa_head (expr width_factor, thickness_factor) =
1438         set_char_box (0, width_factor * solfa_base_notewidth#,
1439                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1440
1441         save p_down_in, p_down_out, p_up_in, p_up_out, nw_dist, nw;
1442         path p_down_in, p_down_out, p_up_in, p_up_out;
1443         save path_a, path_b, path_c;
1444         path path_a, path_b, path_c;
1445         pair nw_dist, nw;
1446
1447         save offset;
1448         offset := 2 * thickness_factor - 1;
1449
1450         save pen_radius;
1451         pen_radius := min (solfa_pen_radius,
1452                            .33 * (h + d) / (1 + offset));
1453
1454         pickup pencircle scaled (2 * pen_radius);
1455
1456         lft x1 = 0;
1457         top y1 = h;
1458
1459         rt x2 = w;
1460         y2 = y1;
1461         bot y3 = -d;
1462         x3 = x2;
1463
1464         y4 = y3;
1465         x4 = x1;
1466
1467         labels (1, 2, 3, 4);
1468
1469         nw = unitvector (z1 - z3);
1470         nw_dist = (nw rotated 90) * pen_radius;
1471
1472         path_a := (z1 - (0,1) * offset * pen_radius)
1473                   -- (z2 - (0,1) * offset * pen_radius);
1474         path_b := (z2 - (1,0) * pen_radius)
1475                   -- (z3 - (1,0) * pen_radius);
1476         path_c := (z3 - nw_dist)
1477                   -- (z1 - nw_dist);
1478
1479         p_up_in := (path_a intersectionpoint path_b)
1480                    -- (path_b intersectionpoint path_c)
1481                    -- (path_c intersectionpoint path_a)
1482                    -- cycle;
1483
1484         p_up_out := lft z1{down}
1485                     .. (z1 + nw_dist){-nw}
1486                     -- (z3 + nw_dist){-nw}
1487                     .. bot z3{right}
1488                     .. rt z3{up}
1489                     -- rt z2{up}
1490                     .. top z2{left}
1491                     -- top z1{left}
1492                     .. cycle;
1493
1494         p_down_in := p_up_in rotated 180 shifted (w, 0);
1495         p_down_out := p_up_out rotated 180 shifted (w, 0);
1496
1497         charwy := 0.0;
1498         charwx := charwd;
1499 enddef;
1500
1501 save fa_weight;
1502 fa_weight := 1.75;
1503
1504 fet_beginchar ("Whole fa up head", "u0fa");
1505         draw_fa_head (solfa_whole_width, fa_weight);
1506         fill p_up_out;
1507         unfill p_up_in;
1508 fet_endchar;
1509
1510
1511 fet_beginchar ("Whole fa down head", "d0fa");
1512         draw_fa_head (solfa_whole_width, fa_weight);
1513         fill p_down_out;
1514         unfill p_down_in;
1515 fet_endchar;
1516
1517
1518 fet_beginchar ("half fa up head", "u1fa");
1519         draw_fa_head (solfa_half_width, fa_weight);
1520         fill p_up_out;
1521         unfill p_up_in;
1522 fet_endchar;
1523
1524
1525 fet_beginchar ("Half fa down head", "d1fa");
1526         draw_fa_head (solfa_half_width, fa_weight);
1527         fill p_down_out;
1528         unfill p_down_in;
1529 fet_endchar;
1530
1531
1532 fet_beginchar ("Quarter fa up head", "u2fa");
1533         draw_fa_head (solfa_quarter_width, fa_weight);
1534         fill p_up_out;
1535 fet_endchar;
1536
1537
1538 fet_beginchar ("Quarter fa down head", "d2fa");
1539         draw_fa_head (solfa_quarter_width, fa_weight);
1540         fill p_down_out;
1541 fet_endchar;
1542
1543
1544 fet_beginchar ("Whole thin fa up head", "u0faThin");
1545         draw_fa_head (solfa_whole_width, 1);
1546         fill p_up_out;
1547         unfill p_up_in;
1548 fet_endchar;
1549
1550
1551 fet_beginchar ("Whole thin fa down head", "d0faThin");
1552         draw_fa_head (solfa_whole_width, 1);
1553         fill p_down_out;
1554         unfill p_down_in;
1555 fet_endchar;
1556
1557
1558 fet_beginchar ("half thin fa up head", "u1faThin");
1559         draw_fa_head (solfa_half_width, 1);
1560         fill p_up_out;
1561         unfill p_up_in;
1562 fet_endchar;
1563
1564
1565 fet_beginchar ("Half thin fa down head", "d1faThin");
1566         draw_fa_head (solfa_half_width, 1);
1567         fill p_down_out;
1568         unfill p_down_in;
1569 fet_endchar;
1570
1571
1572 fet_beginchar ("Quarter thin fa up head", "u2faThin");
1573         draw_fa_head (solfa_quarter_width, 1);
1574         fill p_up_out;
1575 fet_endchar;
1576
1577
1578 fet_beginchar ("Quarter thin fa down head", "d2faThin");
1579         draw_fa_head (solfa_quarter_width, 1);
1580         fill p_down_out;
1581 fet_endchar;
1582
1583
1584
1585 %%%% sol head
1586 %
1587 % Note: sol head is the same shape as a standard music head, and doesn't
1588 %       vary from style to style.  However, width is constant with duration,
1589 %       so we can't just use the standard note font.
1590 %
1591 def draw_sol_head (expr filled) =
1592         draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17);
1593         if not filled:
1594           undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#);
1595         fi
1596         draw_staff (-2, 2, 0);
1597 enddef;
1598
1599 fet_beginchar ("Whole solhead", "s0sol");
1600         draw_sol_head ( false);
1601 fet_endchar;
1602
1603
1604 fet_beginchar ("Half solhead", "s1sol");
1605         draw_sol_head ( false);
1606 fet_endchar;
1607
1608
1609 fet_beginchar ("Quarter solhead", "s2sol");
1610         draw_sol_head ( true);
1611 fet_endchar;
1612
1613
1614 %%%% la head
1615 %
1616 %   Rectangle head
1617 %
1618 def draw_la_head (expr width_factor, thickness_factor) =
1619         set_char_box (0, width_factor * solfa_base_notewidth#,
1620                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1621         save p_in, p_out;
1622         path p_in, p_out;
1623
1624         save offset;
1625         offset := 2 * thickness_factor - 1;
1626
1627         save pen_radius;
1628         pen_radius := min (solfa_pen_radius,
1629                            .35 * (h + d) / (1 + offset));
1630
1631         pickup pencircle scaled (2 * pen_radius);
1632
1633         lft x1 = 0;
1634         top y1 = h;
1635
1636         rt x2 = w;
1637         y2 = y1;
1638         bot y3 = -d;
1639         x3 = x2;
1640
1641         y4 = y3;
1642         x4 = x1;
1643
1644         labels (range 1 thru 4);
1645
1646         p_in := (z1 + pen_radius * (1, -offset))
1647                 -- (z2 + pen_radius * (-1, -offset))
1648                 -- (z3 + pen_radius * (-1, offset))
1649                 -- (z4 + pen_radius * (1, offset))
1650                 -- cycle;
1651
1652         p_out := top z1
1653                  -- top z2{right}
1654                  .. rt z2{down}
1655                  -- rt z3{down}
1656                  .. bot z3{left}
1657                  -- bot z4{left}
1658                  .. lft z4{up}
1659                  -- lft z1{up}
1660                  .. cycle;
1661 enddef;
1662
1663
1664 save la_weight;
1665 la_weight := 2;
1666
1667 fet_beginchar ("Whole lahead", "s0la");
1668         draw_la_head (solfa_whole_width, la_weight);
1669         fill p_out;
1670         unfill p_in;
1671 fet_endchar;
1672
1673
1674 fet_beginchar ("Half lahead", "s1la");
1675         draw_la_head (solfa_half_width, la_weight);
1676         fill p_out;
1677         unfill p_in;
1678 fet_endchar;
1679
1680
1681 fet_beginchar ("Quarter lahead", "s2la");
1682         draw_la_head (solfa_quarter_width, la_weight);
1683         fill p_out;
1684 fet_endchar;
1685
1686
1687 fet_beginchar ("Whole thin lahead", "s0laThin");
1688         draw_la_head (solfa_whole_width, 1);
1689         fill p_out;
1690         unfill p_in;
1691 fet_endchar;
1692
1693
1694 fet_beginchar ("Half thin lahead", "s1laThin");
1695         draw_la_head (solfa_half_width, 1);
1696         fill p_out;
1697         unfill p_in;
1698 fet_endchar;
1699
1700
1701 fet_beginchar ("Quarter lahead", "s2laThin");
1702         draw_la_head (solfa_quarter_width, 1);
1703         fill p_out;
1704 fet_endchar;
1705
1706
1707 %%%% ti head
1708 %
1709 %   `Snow-cone', V with rounded top.
1710 %
1711 def draw_ti_head (expr width_factor, dir, thickness_factor) =
1712         set_char_box (0, width_factor * solfa_base_notewidth#,
1713                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1714         save p_in, p_out, p_top, p_top_in;
1715         path p_in, p_out, p_top, p_top_in;
1716         save cone_height;
1717         cone_height = 0.64;
1718
1719         save offset;
1720         offset := 2 * thickness_factor - 1;
1721
1722         save pen_radius;
1723         pen_radius := min (solfa_pen_radius,
1724                            .4 * (h + d) / (1 + offset));
1725
1726         pickup pencircle scaled (2 * pen_radius);
1727
1728         x1 = .5 [x2, x4];
1729         bot y1 = -d;
1730         lft x2 = 0;
1731         y2 = cone_height [y1, y3];
1732         rt x4 = w;
1733         y4 = y2;
1734         x3 = x1;
1735         top y3 = h;
1736         x5 = x1;
1737         y5 = y1 + offset * pen_radius;
1738
1739         labels (range 1 thru 4);
1740
1741         save nw_dist, sw_dist, nw, sw;
1742         pair nw_dist, sw_dist, nw, sw;
1743
1744         nw = unitvector (z2 - z1);
1745         sw = unitvector (z1 - z4);
1746
1747         nw_dist = (nw rotated 90) * pen_radius;
1748         sw_dist = (sw rotated 90) * pen_radius;
1749
1750         p_top := (z2 + nw * pen_radius)
1751                  .. (top z3){right}
1752                  .. (z4 - sw * pen_radius);
1753
1754         p_top_in := (z2 - nw * offset * pen_radius)
1755                     .. (z3 - (0,1) * pen_radius) {right}
1756                     .. (z4 + sw * offset * pen_radius);
1757
1758         save path_a, path_b;
1759         path path_a, path_b;
1760         path_a := z2
1761                   -- z5;
1762         path_b := z5
1763                   -- z4;
1764
1765         z6 = path_a intersectionpoint p_top_in;
1766         z7 = path_b intersectionpoint p_top_in;
1767
1768         p_in := z5
1769                 -- z6
1770                 .. bot z3
1771                 .. z7
1772                 -- cycle;
1773
1774         p_out := bot z1
1775                  .. (z1 + nw_dist)
1776                  -- (z2 + nw_dist)
1777                  .. lft z2
1778                  .. (z2 + nw * pen_radius){direction 0 of p_top}
1779                  & p_top
1780                  & {direction infinity of p_top}(z4 - sw * pen_radius)
1781                  .. rt z4
1782                  .. (z4 + sw_dist)
1783                  -- (z1 + sw_dist)
1784                  .. cycle;
1785
1786         charwx := charwd;
1787         charwy := cone_height [-chardp, charht];
1788         if dir = -1:
1789                 charwy := -charwy;
1790         fi;
1791 enddef;
1792
1793
1794 save ti_weight;
1795 ti_weight := 2;
1796
1797 fet_beginchar ("Whole up tihead", "s0ti");
1798         draw_ti_head (solfa_whole_width, 1, ti_weight);
1799         fill p_out;
1800         unfill p_in;
1801 fet_endchar;
1802
1803
1804 fet_beginchar ("Half up tihead", "u1ti");
1805         draw_ti_head (solfa_half_width, 1, ti_weight);
1806         fill p_out;
1807         unfill p_in;
1808 fet_endchar;
1809
1810
1811 fet_beginchar ("Half down tihead", "d1ti");
1812         draw_ti_head (solfa_half_width, -1, ti_weight);
1813         fill p_out;
1814         unfill p_in;
1815 fet_endchar;
1816
1817
1818 fet_beginchar ("Quarter up tihead", "u2ti");
1819         draw_ti_head (solfa_quarter_width, 1, ti_weight);
1820         fill p_out;
1821 fet_endchar;
1822
1823
1824 fet_beginchar ("Quarter down tihead", "d2ti");
1825         draw_ti_head (solfa_quarter_width, -1, ti_weight);
1826         fill p_out;
1827 fet_endchar;
1828
1829
1830 fet_beginchar ("Whole thin up tihead", "s0tiThin");
1831         draw_ti_head (solfa_whole_width, 1, 1);
1832         fill p_out;
1833         unfill p_in;
1834 fet_endchar;
1835
1836
1837 fet_beginchar ("Half thin up tihead", "u1tiThin");
1838         draw_ti_head (solfa_half_width, 1, 1);
1839         fill p_out;
1840         unfill p_in;
1841 fet_endchar;
1842
1843
1844 fet_beginchar ("Half thin down tihead", "d1tiThin");
1845         draw_ti_head (solfa_half_width, -1, 1);
1846         fill p_out;
1847         unfill p_in;
1848 fet_endchar;
1849
1850
1851 fet_beginchar ("Quarter thin up tihead", "u2tiThin");
1852         draw_ti_head (solfa_quarter_width, 1, 1);
1853         fill p_out;
1854 fet_endchar;
1855
1856
1857 fet_beginchar ("Quarter thin down tihead", "d2tiThin");
1858         draw_ti_head (solfa_quarter_width, -1, 1);
1859         fill p_out;
1860 fet_endchar;
1861
1862
1863 %%%%%%   Funk shape note heads
1864 %
1865 %  Funk heads are narrower than Aiken and Sacred Harp, so we need a new
1866 %  width.
1867 %
1868 funk_notehead_width := 0.75;
1869
1870
1871 %%%%%%   Funk do head
1872 %          Parabolic on one side, vertical line on other
1873 %          Has up and down shapes for *all* notes
1874 %
1875 def draw_Funk_do_head (expr width_factor, thickness_factor) =
1876         set_char_box (0, width_factor * solfa_base_notewidth#,
1877                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1878
1879         save offset;
1880         offset := 2 * thickness_factor - 1;
1881
1882         save pen_radius;
1883         pen_radius := min (solfa_pen_radius,
1884                            .3 * (h + d) / (1 + offset));
1885
1886         pickup pencircle scaled (2 * pen_radius);
1887
1888         rt x1 = w;
1889         bot y1 = -d;
1890
1891         lft x2 = 0;
1892         y2 = 0.5 [y1, y3];
1893
1894         x3 = x1;
1895         top y3 = h;
1896
1897         x4 = x1 - pen_radius;
1898         y4 = y1 + offset * pen_radius;
1899
1900         y5 = y2;
1901         x5 = x2 + pen_radius;
1902
1903         x6 = x4;
1904         y6 = y3 - offset * pen_radius;
1905
1906         save p_up_in, p_up_out, p_down_in, p_down_out;
1907         path p_up_in, p_up_out, p_down_in, p_down_out;
1908
1909         p_down_in := z4{left}
1910                      ... z5{up}
1911                      ... z6{right}
1912                      -- cycle;
1913
1914         p_down_out := bot z1{left}
1915                       .. lft z2{up}
1916                       .. top z3{right}
1917                       .. rt z3{down}
1918                       -- rt z1{down}
1919                       .. cycle;
1920
1921         p_up_in := p_down_in rotated 180 shifted (w,0);
1922         p_up_out := p_down_out rotated 180 shifted (w,0);
1923
1924 enddef;
1925
1926
1927 save funk_do_weight;
1928 funk_do_weight := 1.7;
1929
1930 fet_beginchar ("Whole up Funk dohead", "u0doFunk");
1931         draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1932         fill p_up_out;
1933         unfill p_up_in;
1934 fet_endchar;
1935
1936
1937 fet_beginchar ("Whole down Funk dohead", "d0doFunk");
1938         draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1939         fill p_down_out;
1940         unfill p_down_in;
1941 fet_endchar;
1942
1943
1944 fet_beginchar ("Half up Funk dohead", "u1doFunk");
1945         draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1946         fill p_up_out;
1947         unfill p_up_in;
1948 fet_endchar;
1949
1950
1951 fet_beginchar ("Half down Funk dohead", "d1doFunk");
1952         draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1953         fill p_down_out;
1954         unfill p_down_in;
1955 fet_endchar;
1956
1957
1958 fet_beginchar ("Quarter up Funk dohead", "u2doFunk");
1959         draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1960         fill p_up_out;
1961 fet_endchar;
1962
1963
1964 fet_beginchar ("Quarter down Funk dohead", "d2doFunk");
1965         draw_Funk_do_head (funk_notehead_width, funk_do_weight);
1966         fill p_down_out;
1967 fet_endchar;
1968
1969
1970 %%%%%%  Funk re head
1971 %       Arrowhead shape.
1972 %       Has up and down shapes for *all* notes
1973 %
1974 def draw_Funk_re_head (expr width_factor, thickness_factor) =
1975         set_char_box (0, width_factor * solfa_base_notewidth#,
1976                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
1977
1978         save offset;
1979         offset := 2 * thickness_factor - 1;
1980
1981         save pen_radius;
1982         pen_radius := min (solfa_pen_radius,
1983                            .3 * (h + d) / (1 + offset));
1984
1985         pickup pencircle scaled (2 * pen_radius);
1986
1987         save curve_in;
1988         curve_in := 0.9;
1989
1990         lft x1 = 0;
1991         y1 := 0.5 [y2, y4];
1992
1993         rt x2 = w;
1994         top y2 = h;
1995
1996         x3 := curve_in [x1, x2];
1997         y3 := y1;
1998
1999         x4 = x2;
2000         bot y4 = -d;
2001
2002         z6 = lft z3;
2003
2004         save ne, se, ne_perp, se_perp;
2005         pair ne, se, ne_perp, se_perp;
2006
2007         ne := unitvector (z2 - z1);
2008         se := unitvector (z4 - z1);
2009         ne_perp := ne rotated 90;
2010         se_perp := se rotated 90;
2011
2012         save path_a, path_b, path_c, path_d;
2013         path path_a, path_b, path_c, path_d;
2014         save arrow_a_perp, arrow_b_perp;
2015         pair arrow_a_perp, arrow_b_perp;
2016
2017
2018         path_d := z2 .. z3{down} .. z4;
2019         arrow_a_perp = unitvector (direction 0 of path_d rotated 90)
2020                        * pen_radius;
2021         arrow_b_perp = unitvector (direction 2 of path_d rotated 90)
2022                        * pen_radius;
2023
2024         path_b := (z1 + se_perp * pen_radius)
2025                   -- z4 + se_perp * offset * pen_radius;
2026         path_a := (z1 - ne_perp * pen_radius)
2027                   -- z2 - ne_perp * offset * pen_radius;
2028         path_c := z2 - arrow_a_perp
2029                   .. z6{down}
2030                   .. z4 - arrow_b_perp;
2031
2032         z5 = path_a intersectionpoint path_b;
2033         z7 = path_a intersectionpoint path_c;
2034         z8 = path_b intersectionpoint path_c;
2035
2036         save p_up_in, p_down_in, p_up_out, p_down_out;
2037         path p_up_in, p_down_in, p_up_out, p_down_out;
2038
2039         p_down_in := z5
2040                      -- z7
2041                      .. z6{down}
2042                      .. z8
2043                      -- cycle;
2044
2045         p_down_out := lft z1{up}
2046                       .. (z1 + ne_perp * pen_radius){ne}
2047                       -- (z2 + ne_perp * pen_radius){ne}
2048                       .. top z2 {right}
2049                       .. rt z2{down}
2050                       .. (z2 + arrow_a_perp)
2051                       .. rt z3{down}
2052                       .. (z4 + arrow_b_perp)
2053                       .. rt z4{down}
2054                       .. bot z4 {left}
2055                       .. z4 - se_perp * pen_radius
2056                       -- z1 - se_perp * pen_radius
2057                       .. cycle;
2058
2059         p_up_in := p_down_in rotated 180 shifted (w, 0);
2060         p_up_out := p_down_out rotated 180 shifted (w, 0);
2061
2062 enddef;
2063
2064
2065 save funk_re_weight;
2066 funk_re_weight = 1.7;
2067
2068 fet_beginchar ("Whole up Funk rehead", "u0reFunk");
2069         draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2070         fill p_up_out;
2071         unfill p_up_in;
2072 fet_endchar;
2073
2074
2075 fet_beginchar ("Whole down Funk rehead", "d0reFunk");
2076         draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2077         fill p_down_out;
2078         unfill p_down_in;
2079 fet_endchar;
2080
2081
2082 fet_beginchar ("Half up Funk rehead", "u1reFunk");
2083         draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2084         fill p_up_out;
2085         unfill p_up_in;
2086 fet_endchar;
2087
2088
2089 fet_beginchar ("Half down Funk rehead", "d1reFunk");
2090         draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2091         fill p_down_out;
2092         unfill p_down_in;
2093 fet_endchar;
2094
2095
2096 fet_beginchar ("Quarter up Funk rehead", "u2reFunk");
2097         draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2098         fill p_up_out;
2099 fet_endchar;
2100
2101
2102 fet_beginchar ("Quarter down Funk rehead", "d2reFunk");
2103         draw_Funk_re_head (funk_notehead_width, funk_re_weight);
2104         fill p_down_out;
2105 fet_endchar;
2106
2107
2108 %%%%%%  Funk mi head
2109 %       Diamond shape
2110 %       Has up and down shapes for all hollow notes
2111 %
2112 save funk_mi_width, funk_mi_weight;
2113 funk_mi_width := 1.2;
2114 funk_mi_weight := 1.9;
2115
2116 fet_beginchar ("Whole up Funk mihead", "u0miFunk");
2117         draw_mi_head (funk_mi_width * funk_notehead_width,
2118                       funk_mi_weight, false);
2119         fill path_out;
2120         unfill path_in;
2121 fet_endchar;
2122
2123
2124 fet_beginchar ("Whole down Funk mihead", "d0miFunk");
2125         draw_mi_head (funk_mi_width * funk_notehead_width,
2126                       funk_mi_weight, true);
2127         fill path_out;
2128         unfill path_in;
2129 fet_endchar;
2130
2131
2132 fet_beginchar ("Half up Funk mihead", "u1miFunk");
2133         draw_mi_head (funk_mi_width * funk_notehead_width,
2134                       funk_mi_weight, false);
2135         fill path_out;
2136         unfill path_in;
2137 fet_endchar;
2138
2139
2140 fet_beginchar ("Half down Funk mihead", "d1miFunk");
2141         draw_mi_head (funk_mi_width * funk_notehead_width,
2142                       funk_mi_weight, true);
2143         fill path_out;
2144         unfill path_in;
2145 fet_endchar;
2146
2147
2148 fet_beginchar ("Quarter Funk mihead", "s2miFunk");
2149         draw_mi_head (funk_mi_width * funk_notehead_width,
2150                       funk_mi_weight, false);
2151         fill path_out;
2152 fet_endchar;
2153
2154
2155 %%%%%%  Funk fa
2156 %       Triangle shape
2157 %       Does it rotate for whole notes?
2158 %       Same as other shape note systems
2159 %       Need special notes because of special width
2160 %
2161 save funk_fa_weight;
2162 funk_fa_weight := 1.9;
2163
2164 fet_beginchar ("Whole up Funk fahead", "u0faFunk");
2165         draw_fa_head (funk_notehead_width, funk_fa_weight);
2166         fill p_up_out;
2167         unfill p_up_in;
2168 fet_endchar;
2169
2170
2171 fet_beginchar ("Whole down Funk fahead", "d0faFunk");
2172         draw_fa_head (funk_notehead_width, funk_fa_weight);
2173         fill p_down_out;
2174         unfill p_down_in;
2175 fet_endchar;
2176
2177
2178 fet_beginchar ("Half up Funk fahead", "u1faFunk");
2179         draw_fa_head (funk_notehead_width, funk_fa_weight);
2180         fill p_up_out;
2181         unfill p_up_in;
2182 fet_endchar;
2183
2184
2185 fet_beginchar ("Half down Funk fahead", "d1faFunk");
2186         draw_fa_head (funk_notehead_width, funk_fa_weight);
2187         fill p_down_out;
2188         unfill p_down_in;
2189 fet_endchar;
2190
2191
2192 fet_beginchar ("Quarter up Funk fahead", "u2faFunk");
2193         draw_fa_head (funk_notehead_width, funk_fa_weight);
2194         fill p_up_out;
2195 fet_endchar;
2196
2197
2198 fet_beginchar ("Quarter down Funk fahead", "d2faFunk");
2199         draw_fa_head (funk_notehead_width, funk_fa_weight);
2200         fill p_down_out;
2201 fet_endchar;
2202
2203
2204 %%%%%%  Funk sol head is the same as the others
2205 %       Need special character because of skinnier head
2206 %
2207 def draw_Funk_sol_head (expr filled) =
2208 begingroup
2209         save noteheight;
2210         noteheight# := solfa_noteheight#;
2211         draw_outside_ellipse (1.2, 34, 0.71, 0.);
2212         if not filled:
2213           undraw_inside_ellipse (1.9, 33, 0.74, 5.5 stafflinethickness#);
2214         fi
2215         draw_staff (-2, 2, 0);
2216 endgroup
2217 enddef;
2218
2219
2220 fet_beginchar ("Whole Funk solhead", "s0solFunk");
2221         draw_Funk_sol_head ( false);
2222 fet_endchar;
2223
2224
2225 fet_beginchar ("Half Funk solhead", "s1solFunk");
2226         draw_Funk_sol_head ( false);
2227 fet_endchar;
2228
2229
2230 fet_beginchar ("Quarter Funk solhead", "s2solFunk");
2231         draw_Funk_sol_head ( true);
2232 fet_endchar;
2233
2234
2235 %%%%%%  Funk la head
2236 %       Rectangle head
2237 %       Same as for other shape notes
2238 %       Smaller width requires special characters
2239 %
2240 save funk_la_weight;
2241 funk_la_weight := 1.9;
2242
2243 fet_beginchar ("Whole Funk lahead", "s0laFunk");
2244         draw_la_head (funk_notehead_width, funk_notehead_width);
2245         fill p_out;
2246         unfill p_in;
2247 fet_endchar;
2248
2249
2250 fet_beginchar ("Half Funk lahead", "s1laFunk");
2251         draw_la_head (funk_notehead_width, funk_notehead_width);
2252         fill p_out;
2253         unfill p_in;
2254 fet_endchar;
2255
2256
2257 fet_beginchar ("Quarter Funk lahead", "s2laFunk");
2258         draw_la_head (funk_notehead_width, funk_notehead_width);
2259         fill p_out;
2260 fet_endchar;
2261
2262
2263 %%%%%%  Funk ti head
2264 %       `Sideways snow cone'.
2265 %       Rotates for all notes.
2266 %
2267 def draw_Funk_ti_head (expr width_factor, thickness_factor) =
2268         set_char_box (0, width_factor * solfa_base_notewidth#,
2269                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2270         save cone_width;
2271         cone_width = 0.8;
2272
2273         save offset;
2274         offset := 2 * thickness_factor - 1;
2275
2276         save pen_radius;
2277         pen_radius := min (solfa_pen_radius,
2278                            .33 * (h + d) / (1 + offset));
2279
2280         pickup pencircle scaled (2 * pen_radius);
2281
2282         lft x1 = 0;
2283         y1 = .5 [y2, y4];
2284
2285         x2 = cone_width [x1, x3];
2286         top y2 = h;
2287
2288         rt x3 = w;
2289         y3 = y1;
2290
2291         x4 = x2;
2292         bot y4 = -d;
2293
2294         save nw_dist, sw_dist, ne, se;
2295         pair nw_dist, sw_dist, ne, se;
2296
2297         ne = unitvector (z2 - z1);
2298         se = unitvector (z4 - z1);
2299
2300         nw_dist = (ne rotated 90) * pen_radius ;
2301         sw_dist = (se rotated -90) * pen_radius;
2302
2303         save path_a, path_b;
2304         path path_a, path_b;
2305         path_a := z1 - nw_dist
2306                   -- z2 - offset * nw_dist;
2307         path_b := z1 - sw_dist
2308                   -- z4 - offset * sw_dist;
2309
2310         save path_right, path_right_in;
2311         path path_right, path_right_in;
2312         path_right := (z2 + ne * pen_radius)
2313                       .. (rt z3){down}
2314                       .. (z4 + se * pen_radius);
2315
2316         path_right_in := (z2 - ne * pen_radius)
2317                          .. lft z3{down}
2318                          .. (z4 - se * pen_radius);
2319
2320         z5 = path_a intersectionpoint path_b;
2321         z6 = path_a intersectionpoint path_right_in;
2322         z7 = path_b intersectionpoint path_right_in;
2323
2324         save p_up_in, p_down_in, p_up_out, p_down_out;
2325         path p_up_in, p_down_in, p_up_out, p_down_out;
2326
2327         p_down_in := z5
2328                      -- z6
2329                      .. lft z3
2330                      .. z7
2331                      -- cycle;
2332
2333         p_down_out := lft z1
2334                       .. (z1 + nw_dist)
2335                       -- (z2 + nw_dist)
2336                       .. top z2
2337                       .. (z2 + ne * pen_radius){direction 0 of path_right}
2338                       & path_right
2339                       & {direction infinity of path_right}(z4 + se * pen_radius)
2340                       .. bot z4
2341                       .. (z4 + sw_dist)
2342                       -- (z1 + sw_dist)
2343                       .. cycle;
2344
2345         p_up_in := p_down_in rotated 180 shifted (w, 0);
2346         p_up_out := p_down_out rotated 180 shifted (w, 0);
2347 enddef;
2348
2349
2350 save funk_ti_weight;
2351 funk_ti_weight := 1.6;
2352
2353 fet_beginchar ("Whole up Funk tihead", "u0tiFunk");
2354         draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2355         fill p_up_out;
2356         unfill p_up_in;
2357 fet_endchar;
2358
2359
2360 fet_beginchar ("Whole down Funk tihead", "d0tiFunk");
2361         draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2362         fill p_down_out;
2363         unfill p_down_in;
2364 fet_endchar;
2365
2366
2367 fet_beginchar ("Half up Funk tihead", "u1tiFunk");
2368         draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2369         fill p_up_out;
2370         unfill p_up_in;
2371 fet_endchar;
2372
2373
2374 fet_beginchar ("Half down Funk tihead", "d1tiFunk");
2375         draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2376         fill p_down_out;
2377         unfill p_down_in;
2378 fet_endchar;
2379
2380
2381 fet_beginchar ("Quarter up Funk tihead", "u2tiFunk");
2382         draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2383         fill p_up_out;
2384 fet_endchar;
2385
2386
2387 fet_beginchar ("Quarter down Funk tihead", "d2tiFunk");
2388         draw_Funk_ti_head (funk_notehead_width, funk_ti_weight);
2389         fill p_down_out;
2390 fet_endchar;
2391
2392
2393 %%%%%%   Walker shape note heads
2394 %
2395 % Walker heads are narrow like Funk heads, so use funk_notehead_width.
2396 %
2397
2398 %%%%%%   Walker do head
2399 %
2400 % Trapezoid, with largest side on stem side
2401 %
2402 def draw_Walker_do_head (expr width_factor, dir, thickness_factor) =
2403         set_char_box (0, width_factor * solfa_base_notewidth#,
2404                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2405
2406         pickup pencircle scaled solfa_pen_thick;
2407
2408         save offset;
2409         offset := 2 * thickness_factor - 1;
2410
2411         % adjust width so stem can be centered
2412         if .5w <> good.x .5w: change_width; fi
2413
2414         save scaling;
2415
2416         scaling# = charwd / w;
2417
2418         save inset;
2419         inset := 0.25;
2420
2421         x1 = inset [x4, x3];
2422         top y1 = h;
2423
2424         x2 = inset [x3, x4];
2425         y2 = y1;
2426
2427         bot y3 = -d;
2428         rt x3 = w;
2429
2430         y4 = y3;
2431         lft x4 = 0;
2432
2433         labels (range 1 thru 4);
2434
2435         save left_dir, left_perp, right_dir, right_perp;
2436         pair left_dir, left_perp, right_dir, right_perp;
2437
2438         left_dir = unitvector(z1 - z4);
2439         left_perp = (left_dir rotated 90) * solfa_pen_radius;
2440         right_dir = unitvector(z3 - z2);
2441         right_perp = (right_dir rotated 90) * solfa_pen_radius;
2442
2443         save path_a, path_b, path_c, path_d;
2444         path path_a, path_b, path_c, path_d;
2445
2446         path_a := (z4 - left_perp)
2447                   -- (z1 - left_perp);
2448         path_b := (z1 - (0, offset*solfa_pen_radius))
2449                   -- (z2 - (0, offset*solfa_pen_radius));
2450         path_c := (z2 - right_perp)
2451                   -- (z3 - right_perp);
2452         path_d := (z3 + (0, offset*solfa_pen_radius))
2453                   -- (z4 + (0, offset*solfa_pen_radius));
2454
2455         save p_in, p_out;
2456         path p_in, p_out;
2457
2458         p_in := (path_a intersectionpoint path_b)
2459                 -- (path_b intersectionpoint path_c)
2460                 -- (path_c intersectionpoint path_d)
2461                 -- (path_d intersectionpoint path_a)
2462                 -- cycle;
2463
2464         p_out := top z1{right}
2465                  -- top z2{right}
2466                  .. z2 + right_perp {right_dir}
2467                  -- z3 + right_perp {right_dir}
2468                  .. bot z3{left}
2469                  -- bot z4{left}
2470                  .. z4 + left_perp {left_dir}
2471                  .. z1 + left_perp {left_dir}
2472                  .. cycle;
2473
2474         charwx := scaling# * (w/2 + solfa_pen_radius);
2475         charwy := scaling# * y2 ;
2476
2477         if dir = 1:
2478                 p_in := p_in rotated 180 shifted (w,0);
2479                 p_out := p_out rotated 180 shifted (w,0);
2480         fi;
2481 enddef;
2482
2483
2484 save walker_do_weight;
2485 walker_do_weight := 1.5;
2486
2487 fet_beginchar ("Whole Walker dohead", "s0doWalker");
2488         draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2489         fill p_out;
2490         unfill p_in;
2491 fet_endchar;
2492
2493
2494 fet_beginchar ("Half up Walker dohead", "u1doWalker");
2495         draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2496         fill p_out;
2497         unfill p_in;
2498 fet_endchar;
2499
2500
2501 fet_beginchar ("Half down Walker dohead", "d1doWalker");
2502         draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2503         fill p_out;
2504         unfill p_in;
2505 fet_endchar;
2506
2507
2508 fet_beginchar ("Quarter up Walker dohead", "u2doWalker");
2509         draw_Walker_do_head (funk_notehead_width, 1, walker_do_weight);
2510         fill p_out;
2511 fet_endchar;
2512
2513
2514 fet_beginchar ("Quarter down Walker dohead", "d2doWalker");
2515         draw_Walker_do_head (funk_notehead_width, 0, walker_do_weight);
2516         fill p_out;
2517 fet_endchar;
2518
2519
2520 %%%%%%   Walker re head
2521 %          Parabolic on one side, shallow parabola on other
2522 %          Has up and down shapes for *all* notes
2523 %
2524 def draw_Walker_re_head (expr width_factor, thickness_factor) =
2525         set_char_box (0, width_factor * solfa_base_notewidth#,
2526                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2527
2528         save offset;
2529         offset := 2 * thickness_factor - 1;
2530
2531         save pen_radius;
2532         pen_radius := min (solfa_pen_radius,
2533                            .3 * (h + d) / (1 + offset));
2534
2535         pickup pencircle scaled (2 * pen_radius);
2536
2537         save dish_factor;
2538         dish_factor := 0.20;
2539
2540         rt x1 = w;
2541         bot y1 = -d;
2542
2543         lft x2 = 0;
2544         y2 = 0.5 [y1, y3];
2545
2546         top y3 = h;
2547         x3 = x1;
2548
2549         x4 = dish_factor [x1, x2];
2550         y4 = y2;
2551
2552         x5 = x1;
2553         y5 = y1 + offset * pen_radius;
2554
2555         y6 = y2;
2556         x6 = x2 + pen_radius;
2557
2558         x7 = x3;
2559         y7 = y3 - offset * pen_radius;
2560
2561         y8 = y4;
2562         x8 = x4 - pen_radius;
2563
2564         save path_a, path_d;
2565         path path_a, path_d;
2566
2567         save p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2568         pair p_a_start_dir, p_a_end_dir, p_a_start_perp, p_a_end_perp;
2569
2570         path_a := z3 .. z4{down} .. z1;
2571
2572         p_a_start_dir := unitvector(direction 0 of path_a);
2573         p_a_end_dir := unitvector(direction infinity of path_a);
2574         p_a_start_perp := (p_a_start_dir rotated 90) * pen_radius;
2575         p_a_end_perp := (p_a_end_dir rotated 90) * pen_radius;
2576
2577         path_d := (z3 - p_a_start_perp){p_a_start_dir}
2578                   .. z4 {down}
2579                   ..(z1 - p_a_end_perp){p_a_end_dir};
2580
2581         save path_b, path_c;
2582         path path_b, path_c;
2583
2584         path_b := z5 {left} .. z6{up};
2585         path_c := z7 {left} .. z6{down};
2586
2587         z9 = path_d intersectionpoint path_b;
2588         z10 = path_d intersectionpoint path_c;
2589
2590         labels (range 1 thru 4);
2591
2592         save p_up_in, p_up_out, p_down_in, p_down_out;
2593         path p_up_in, p_up_out, p_down_in, p_down_out;
2594
2595         p_down_in := z6{up}
2596                      ... {right} z10 {p_a_start_dir}
2597                      .. z8{down}
2598                      .. {p_a_end_dir} z9 {left}
2599                      ... cycle;
2600
2601         p_down_out := lft z2{up}
2602                       .. top z3{right}
2603                       .. rt z3
2604                       .. (z3 + p_a_start_perp){p_a_start_dir}
2605                       .. rt z4{down}
2606                       .. (z1 + p_a_end_perp) {p_a_end_dir}
2607                       .. rt z1
2608                       .. bot z1 {left}
2609                       .. cycle;
2610
2611         p_up_in := p_down_in rotated 180 shifted (w,0);
2612         p_up_out := p_down_out rotated 180 shifted (w,0);
2613 enddef;
2614
2615
2616 save walker_re_weight;
2617 walker_re_weight := 1.2;
2618
2619 fet_beginchar ("Whole Walker rehead", "s0reWalker");
2620         draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2621         fill p_down_out;
2622         unfill p_down_in;
2623 fet_endchar;
2624
2625
2626 fet_beginchar ("Half up Walker rehead", "u1reWalker");
2627         draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2628         fill p_up_out;
2629         unfill p_up_in;
2630 fet_endchar;
2631
2632
2633 fet_beginchar ("Half down Walker rehead", "d1reWalker");
2634         draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2635         fill p_down_out;
2636         unfill p_down_in;
2637 fet_endchar;
2638
2639
2640 fet_beginchar ("Quarter up Walker rehead", "u2reWalker");
2641         draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2642         fill p_up_out;
2643 fet_endchar;
2644
2645
2646 fet_beginchar ("Quarter down Walker rehead", "d2reWalker");
2647         draw_Walker_re_head (funk_notehead_width, walker_re_weight);
2648         fill p_down_out;
2649 fet_endchar;
2650
2651
2652 %%%%%%  Walker mi head
2653 %       Diamond shape
2654 %       Symmetric for all hollow notes
2655 %
2656 save walker_mi_width, walker_mi_weight;
2657 walker_mi_width := 1.2;
2658 walker_mi_weight := 1.5;
2659
2660 fet_beginchar ("Whole Walker mihead", "s0miWalker");
2661         draw_mi_head (walker_mi_width * funk_notehead_width,
2662                       walker_mi_weight, true);
2663         fill path_out;
2664         unfill path_in;
2665 fet_endchar;
2666
2667
2668 fet_beginchar ("Half Walker mihead", "s1miWalker");
2669         draw_mi_head (walker_mi_width * funk_notehead_width,
2670                       walker_mi_weight, true);
2671         fill path_out;
2672         unfill path_in;
2673 fet_endchar;
2674
2675
2676 fet_beginchar ("Quarter Walker mihead", "s2miWalker");
2677         draw_mi_head (walker_mi_width * funk_notehead_width,
2678                       walker_mi_weight, true);
2679         fill path_out;
2680 fet_endchar;
2681
2682
2683 %%%%%%  Walker fa
2684 %       Triangle shape
2685 %       Does not rotate for whole notes
2686 %       Whole rotation is different from Funk, so special notes
2687
2688 %%%%%%  Funk sol head is the same as the others
2689 %       Need special character because of skinnier head
2690 %
2691 save walker_fa_weight;
2692 walker_fa_weight := 1.5;
2693
2694 fet_beginchar ("Whole Walker fahead", "s0faWalker");
2695         draw_fa_head (funk_notehead_width, walker_fa_weight);
2696         fill p_down_out;
2697         unfill p_down_in;
2698 fet_endchar;
2699
2700
2701 fet_beginchar ("Half up Walker fahead", "u1faWalker");
2702         draw_fa_head (funk_notehead_width, walker_fa_weight);
2703         fill p_up_out;
2704         unfill p_up_in;
2705 fet_endchar;
2706
2707
2708 fet_beginchar ("Half down Walker fahead", "d1faWalker");
2709         draw_fa_head (funk_notehead_width, walker_fa_weight);
2710         fill p_down_out;
2711         unfill p_down_in;
2712 fet_endchar;
2713
2714
2715 fet_beginchar ("Quarter up Walker fahead", "u2faWalker");
2716         draw_fa_head (funk_notehead_width, walker_fa_weight);
2717         fill p_up_out;
2718 fet_endchar;
2719
2720
2721 fet_beginchar ("Quarter down Walker fahead", "d2faWalker");
2722         draw_fa_head (funk_notehead_width, walker_fa_weight);
2723         fill p_down_out;
2724 fet_endchar;
2725
2726
2727 %%%%%%  Walker sol
2728 %       Same as Funk, no special notes
2729 %
2730
2731 %%%%%%  Walker la head
2732 %       Rectcangle head
2733 %       Lighter weight requires separate notes
2734 %
2735 save walker_la_weight;
2736 walker_la_weight := 1.5;
2737
2738 fet_beginchar ("Whole Walker lahead", "s0laWalker");
2739         draw_la_head (funk_notehead_width, walker_la_weight);
2740         fill p_out;
2741         unfill p_in;
2742 fet_endchar;
2743
2744
2745 fet_beginchar ("Half Funk lahead", "s1laWalker");
2746         draw_la_head (funk_notehead_width, walker_la_weight);
2747         fill p_out;
2748         unfill p_in;
2749 fet_endchar;
2750
2751
2752 fet_beginchar ("Quarter Funk lahead", "s2laWalker");
2753         draw_la_head (funk_notehead_width, walker_la_weight);
2754         fill p_out;
2755 fet_endchar;
2756
2757
2758 %%%%%%  Walker ti head
2759 %       Triangular arrowhead
2760 %       Rotates for all but whole notes
2761 %
2762 def draw_Walker_ti_head (expr width_factor, thickness_factor) =
2763         set_char_box (0, width_factor * solfa_base_notewidth#,
2764                       0.5 solfa_noteheight#, 0.5 solfa_noteheight#);
2765
2766         save offset;
2767         offset := 2 * thickness_factor - 1;
2768
2769         save pen_radius;
2770         pen_radius := min (solfa_pen_radius,
2771                            .3 * (h + d) / (1 + offset));
2772
2773         pickup pencircle scaled (2 * pen_radius);
2774
2775         lft x1 = 0;
2776         y1 = .5 [y2, y3];
2777
2778         rt x2 = w;
2779         top y2 = h;
2780
2781         x3 = x2;
2782         bot y3 = -d;
2783
2784
2785         labels (range 1 thru 4);
2786
2787         save nw_dist, sw_dist, ne, se;
2788         pair nw_dist, sw_dist, ne, se;
2789
2790         ne = unitvector (z2 - z1);
2791         se = unitvector (z3 - z1);
2792
2793         nw_dist = (ne rotated 90) * pen_radius ;
2794         sw_dist = (se rotated -90) * pen_radius;
2795
2796
2797         save path_a, path_b, path_c;
2798         path path_a, path_b, path_c;
2799         path_a := z2 - nw_dist * offset
2800                   -- z1 - nw_dist * offset;
2801         path_b := z3 - sw_dist * offset
2802                   -- z1 - sw_dist * offset;
2803         path_c := z2 + left * pen_radius
2804                   -- z3 + left * pen_radius;
2805
2806         z4 = path_a intersectionpoint path_b;
2807         z5 = path_a intersectionpoint path_c;
2808         z6 = path_b intersectionpoint path_c;
2809
2810         save p_up_in, p_down_in, p_up_out, p_down_out;
2811         path p_up_in, p_down_in, p_up_out, p_down_out;
2812
2813         p_down_in := z4
2814                      -- z5
2815                      -- z6
2816                      -- cycle;
2817
2818         p_down_out := lft z1{up}
2819                       .. (z1 + nw_dist){ne}
2820                       -- (z2 + nw_dist){ne}
2821                       .. top z2{right}
2822                       .. rt z2 {down}
2823                       -- rt z3 {down}
2824                       .. bot z3 {left}
2825                       .. (z3 + sw_dist){- se}
2826                       .. (z1 + sw_dist){- se}
2827                       .. cycle;
2828
2829         p_up_in := p_down_in rotated 180 shifted (w, 0);
2830         p_up_out := p_down_out rotated 180 shifted (w, 0);
2831 enddef;
2832
2833
2834 save walker_ti_weight;
2835 walker_ti_weight := 1.4;
2836
2837 fet_beginchar ("Whole Walker tihead", "s0tiWalker");
2838         draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2839         fill p_down_out;
2840         unfill p_down_in;
2841 fet_endchar;
2842
2843
2844 fet_beginchar ("Half up Walker tihead", "u1tiWalker");
2845         draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2846         fill p_up_out;
2847         unfill p_up_in;
2848 fet_endchar;
2849
2850
2851 fet_beginchar ("Half down Walker tihead", "d1tiWalker");
2852         draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2853         fill p_down_out;
2854         unfill p_down_in;
2855 fet_endchar;
2856
2857
2858 fet_beginchar ("Quarter up Walker tihead", "u2tiWalker");
2859         draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2860         fill p_up_out;
2861 fet_endchar;
2862
2863
2864 fet_beginchar ("Quarter down Walker tihead", "d2tiWalker");
2865         draw_Walker_ti_head (funk_notehead_width, walker_ti_weight);
2866         fill p_down_out;
2867 fet_endchar;
2868
2869 fet_endgroup ("noteheads");
2870
2871
2872 %
2873 % we derive black_notehead_width# from the quarter head,
2874 % so we have to define black_notehead_width (pixel qty)
2875 % after the black_notehead_width# itself.
2876 %
2877 % Let's keep it outside the group as well.
2878 %
2879
2880 define_pixels (black_notehead_width);