1 % feta-nummer-code.mf -- implement bold Orator numerals
3 % part of LilyPond's pretty-but-neat music font
5 % source file of the Feta (not the Font-En-Tja) music font
7 % (c) 1997--2007 Jan Nieuwenhuizen <janneke@gnu.org>
10 height# := number_design_size;
11 space# := number_design_size / 2;
13 font_x_height height#;
14 font_normal_space space#;
20 % ugh. b and h are reused.
26 fatten := number_design_size * h + b;
31 widen := number_design_size * h + b;
34 thick# := 7/30 height# * fatten;
35 thin# := thick# / 4 * fatten + max (.1 (height# / 10 - 1), 0);
37 %% sqrt (.8 * blot_diameter# * thin#);
40 flare# := 9/8 thick# + .75 (height# / 10 - 1);
45 kuulleke# := thick# * number_design_size * h + b;
47 foot_width# := 9/4 thick#;
51 % These numbers were taken from a part that that the EJE violas played
52 % 1997 -- Probably Mendelssohn's ouverture `Heimkehr aus der Fremde'.
57 % TODO all the invocation of flare_path are weird --
58 % the horizontal tangents should be more at the center of the
62 define_pixels (height, thick, thick, thin, hair, flare);
63 define_pixels (foot_top, foot_width);
64 define_pixels (kuulleke);
68 % Yet Another Bulb Routine with smooth inside curve.
70 % alpha = start direction.
71 % beta = which side to turn to
72 % flare = diameter of the bulb
73 % line = diameter of line attachment
74 % direction = is ink on left or right side (1 or -1)
77 % move_away_to = amount left (for 2)
78 % turn_to = amount down (for 2)
81 def number_flare_path (expr pos, alpha, beta, line, flare,
82 move_away_to, turn_to, taille, taille_ratio,
90 % z5 = z2 + 0.43 * flare * dir (alpha - 1.5 beta);
92 z4 = (0.75 - taille) [z2r, z2l] + whatever * dir (alpha - beta);
93 z4 = (taille_ratio * taille) [z3l, z3r] + whatever * dir (alpha);
96 z2r = z1r + move_away_to * dir (alpha)
97 + (line + turn_to) * dir (alpha + beta);
98 z3r = 0.5 [z2l, z2r] + 0.5 * flare * dir (alpha + beta);
100 penpos1 (line, 180 + beta + alpha);
101 penpos2 (flare, alpha);
102 penpos3 (flare, alpha + beta);
104 penlabels (1, 2, 3, 4, 5);
106 res := z1r{dir (alpha)}
107 .. z2r{dir (180 + alpha - beta)}
108 .. z3r{dir (alpha + 180)}
109 .. z2l{dir (alpha - beta)}
111 %%% Two versions of the curve: one with z4, the other with z5.
112 % .. z5{dir (alpha - beta / 2)}
114 .. z4{dir (180 + alpha + beta)}
115 .. z1l{dir (alpha + 180)};
129 def calc_kuulleke (expr w, alpha) =
133 beta = (alpha - 90) / 2;
134 gamma = (90 + alpha) / 2;
136 penpos1 (w / cosd (alpha), alpha);
137 penpos2 (hair, 90 + beta);
138 penpos3 (hair, gamma - 90);
140 z2 = z1l + (1/2 hair / tand ((alpha + 90) / 2)) * dir (beta);
141 z3 = z1r - (1/2 hair / tand ((90 - alpha) / 2)) * dir (gamma);
142 z4 = z1 + kuulleke * dir (alpha - 90);
147 % should make generic macro?
149 def draw_foot (expr xpos) =
154 penpos2 (foot_width, 0);
158 z1= (xpos, foot_top);
164 penlabels (1, 2, 3, 4);
182 save before, after, u, v;
185 set_char_box (0, .68 height# * widen, 0, height#);
187 message "w:" & decimal w;
188 message "h:" & decimal h;
191 z2 = (w / 2, h / 2 + thin - hair / 2);
193 penpos3 (15/16 thick, 0);
204 penpos7 (thick, 180);
208 penpos10 (thick, 180);
211 penlabels (range 1 thru 10);
219 .. number_flare_path (z6r, 0, -90, hair, flare,
220 w - x6r - hair / 2, .16 h,
223 (u, v) = before intersectiontimes after;
226 fill subpath (u, infinity) of before
227 ..tension outer_t.. z3r{down}
228 ..tension outer_t.. z4r{left}
229 .. subpath (0, v) of after
233 ..tension t.. z3l{down}
234 ..tension t.. z4l{left}
235 ..tension t.. z10l{up}
241 dot_diam# = 7/8 flare#;
242 define_pixels (dot_diam);
247 fet_beginchar ("Plus", "plus");
248 set_char_box (0, .5 height#, -0.25 height#, 0.75 height#);
250 save hthick, vthick, size, outer_hsize, outer_vsize;
252 hthick# = vthick# = 2 linethickness#;
253 size# = 1.1 staff_space#;
254 define_whole_blacker_pixels (vthick);
255 define_whole_vertical_blacker_pixels (hthick);
257 outer_hsize = hround ((b + w - vthick) / 2);
258 outer_vsize = vround ((h + d - hthick) / 2);
260 centerx := hround (w / 2);
261 centery := vround ((h - d) / 2);
263 z1 = (centerx - hthick / 2, -d);
264 z2 = (centerx + hthick / 2, h);
268 draw_rounded_block (z1, z2, hthick);
269 draw_rounded_block ((0, centery - vthick / 2),
270 (w, (centery + vthick / 2)),
277 fet_beginchar ("Numeral comma", "comma");
281 set_char_box (0, dot_diam#, 3/2 dot_diam#, dot_diam#);
283 pat := (dot_diam / 2, 0)
284 .. (dot_diam, dot_diam / 2)
285 .. (dot_diam / 2, dot_diam)
289 pos = ypart (((w / 3, 0) -- (w / 3, dot_diam / 2))
290 intersectiontimes pat);
291 z0 = point pos of pat;
294 penpos1 (thin, alpha + 90);
296 z1l = (w / 2, -1.5 h + hair);
301 % include z0 to assist removal of overlaps
302 fill subpath (0,3) of pat
305 filldraw z1l{dir (alpha)}
307 -- z0{direction pos of pat}
308 ..tension 0.95.. {dir (180 + alpha)}z1r
316 fet_beginchar ("Numeral dash", "hyphen");
317 set_char_box (0, height# / 3, 0, height#);
319 draw_rounded_block ((-b, h / 3 - thin / 2),
320 (w, h / 3 + thin / 2), thin);
324 fet_beginchar ("Numeral dot", "period");
325 set_char_box (0, dot_diam#, 0, dot_diam#);
327 pickup pencircle scaled dot_diam;
329 drawdot (dot_diam / 2, dot_diam / 2);
337 fet_beginchar ("Numeral 0", "zero");
338 set_char_box (0, 11/15 height# * widen, 0, height#);
340 message "w:" & decimal w;
341 message "h:" & decimal h;
344 penpos2 (thick, 180);
362 penlabels (1, 2, 3, 4);
372 fet_beginchar ("Numeral 1", "one");
373 save alpha, beta, gamma;
375 % set_char_box (0, 19/30 height# * widen, 0, height#);
376 set_char_box (0, 1/2 foot_width# + 3/2 thick# + 1/2 hair#,
379 message "w:" & decimal w;
380 message "h:" & decimal h;
383 calc_kuulleke (thick, alpha);
384 z1 = (3/2 thick, height);
390 beta = angle (z1l - z6);
392 penpos7 (thin, beta - 90);
395 penpos8 (thin / cosd (beta), -90);
398 penpos9 (thin, beta - 90);
399 z9r = z8r + (thin / cosd (beta)) * down;
401 penlabels (range 1 thru 9);
403 gamma = angle (length (z1r - z1), 2 kuulleke);
405 fill z2r{dir (alpha - gamma)}
407 .. {dir (alpha + gamma)}z3l
416 .. {dir (alpha - gamma)}z2r
418 .. {dir (180 + beta)}z9l
419 -- z7r{dir (180 + beta)}
420 .. {dir (beta)}cycle;
426 fet_beginchar ("Numeral 2", "two");
428 save alpha, beta, gamma, theta;
429 save flare_start_distance;
433 set_char_box (0, 22/30 height# * widen, 0, height#);
435 message "w:" & decimal w;
436 message "h:" & decimal h;
445 penpos1 (hair, 90 + beta);
446 z1 = (0, 0) + (1/2 sqrt (2) * hair) * dir (45);
448 penpos3 (hair,90 + gamma);
449 z3 = (w, thick) + (1/2 sqrt (2) * hair) * dir (-135);
451 penpos2 (thick, 90 + alpha - 15);
453 y2 = 10/16 thick / widen;
455 tolerance := epsilon;
457 % Find proper tension to exactly touch the x axis.
458 % Later on we directly use `bow'.
460 bow := z3l{dir (180 + gamma)}
461 ..tension t.. {dir (180 + alpha -5)}z2l;
462 ypart (directionpoint left of bow) < 0
465 % the return value of `solve' is stored in a dummy variable
466 t = solve f (0.8, 1.2);
469 ..tension 0.9.. {dir (alpha + 10)}z2r
472 .. {dir (180 + beta)}z1l
476 z4r = (w - thin / 2, .71 h);
482 penlabels (range 1 thru 6);
486 pat := z1l{dir (beta)}
487 ..tension t.. z4r{up}
488 .. number_flare_path (z5r, 180, 90, hair, 1.05 flare,
489 x5r - 1/2 hair, .21 h, 0.006, 0.4, 1)
491 ..tension t.. {dir (180 + beta)}z1r
494 % pickup pencircle scaled 1;
502 % TODO: should widen a bit. The right edge of the 3 bumps into next glyph in
505 fet_beginchar ("Numeral 3", "three");
506 set_char_box (0, 2/3 height# * widen, 0, height#);
508 message "w:" & decimal w;
509 message "h:" & decimal h;
513 % flare_start = 0.25;
518 % z1l = (17/16 thick, h);
520 penpos2 (7/8 thick, 180);
522 y2l = 3/4 h + thick * 3/32;
525 z3 = (w / 2, h / 2 + 1/8 thick);
528 z4 = (5/8 thick + 1/2 thin, y3);
532 y5r = 17/64 h + thick / 16;
538 penpos7 (3/2 thin, 90);
542 penlabels (range 1 thru 7);
544 save alpha, t, outer_t;
549 % pickup pencircle scaled 1;
551 fill number_flare_path (z1l, 180, 90, hair, 7/8 flare, x1l - .5 hair,
552 .16 h, 0.06, 1.5, -1)
553 ..tension outer_t.. z2l{down}
554 ..tension outer_t.. z7r{dir (180 + alpha)}
556 ..tension outer_t.. z5r{down}
557 ..tension outer_t.. number_flare_path (z6r, 180, -90, hair,
558 flare, x6l, .18 h, 0.06,
561 ..tension t.. z3l{left}
565 ..tension t.. z2r{up}
570 fet_beginchar ("Numeral 4", "four");
571 save alpha, beta, gamma;
573 set_char_box (0, 4/5 height# * widen, 0, height#);
575 message "w:" & decimal w;
576 message "h:" & decimal h;
579 calc_kuulleke (3/2 thick, alpha);
581 z1r = (w - 3/4 thick, height);
582 z5 = (thin, 1/4 height + thin);
584 beta = angle (z3r - z5);
593 penpos8 (thin, -alpha);
596 penlabels (range 1 thru 8);
598 gamma = angle (length (z1r - z1), 2 kuulleke);
600 fill z2r{dir (alpha - gamma)}
602 .. {dir (alpha + gamma)}z3l
603 .. {dir (180 + beta)}z3r
608 ..tension 0.8 and 2.. z8l{dir (beta)}
615 calc_kuulleke (thick, alpha);
617 z1r = (w - 3/4 thick, height - (3/2 thin) / cosd (alpha));
622 gamma := angle (length (z1r - z1), 2 kuulleke);
624 fill z2r{dir (alpha - gamma)}
626 .. {dir (alpha + gamma)}z3l
633 penlabels (1, 2, 3, 4, 5);
639 fet_beginchar ("Numeral 5", "five");
640 save alpha, beta, gamma, delta;
641 save inner_t, outer_t;
645 set_char_box (0, 27/40 height# * widen, 0, height#);
647 message "w:" & decimal w;
648 message "h:" & decimal h;
651 calc_kuulleke (w - thin, alpha);
653 z1 = (w / 2 + 1/8 thick, h);
656 z5l = (x1l, h - 15/16 thick);
658 penpos6 (hair, 90 - 45);
659 z6 = z5r + 1/2 hair * dir (-45);
662 z7l = (x1l, h / 2 + thin - hair);
664 penlabels (range 1 thru 7);
666 gamma = angle (length (z1r - z1), 2 kuulleke);
668 pat := z2r{dir (alpha - gamma)}
670 .. {dir (alpha + gamma)}z3l
680 delta = 180 + beta + 10;
681 z8r = (x7r, y7r - 1/16 thick + thin);
682 z8l = directionpoint dir (delta) of
683 subpath (6, 7) of pat;
685 % include intersection point to improve overlap removal
686 fill subpath (0, 6) of pat
688 .. subpath (7, length (pat)) of pat
693 x9 = .36 [x8r, x10r];
697 y10r = 1/2 [y9r, y11r];
699 penpos11 (hair, -90);
703 penlabels (range 8 thru 12);
708 fill z8r {dir (beta)}
710 ..tension outer_t.. z10r{down}
711 .. number_flare_path (z11r, 180, -90, hair, flare, x11l,
714 ..tension inner_t.. z10l{up}
715 ..tension inner_t.. z9l{left}
721 fet_beginchar ("Numeral 6", "six");
726 fet_beginchar ("Numeral 7", "seven");
728 save alpha, beta, gamma, delta;
734 set_char_box (0, 11/15 height# * widen - thin#, 0, height#);
735 overshoot_x = .75 thin;
737 message "w:" & decimal w;
738 message "h:" & decimal h;
742 penpos1 (3/2 thick, 180 + alpha);
743 penpos2 (hair, 180 + alpha - 45);
744 penpos3 (hair, 180 + alpha + 45);
746 z2 = z1l + (1/4 sqrt (2) * hair) * dir (alpha - 135);
747 z3 = z1r + (1/4 sqrt (2) * hair) * dir (alpha - 45);
748 z4 = z1 + kuulleke * dir (alpha - 90);
753 penpos5 (thin, 90 + beta);
754 z5 = (w, h) + (1/2 sqrt (2) * thin) * dir (-135) + (overshoot_x, 0);
756 gamma = angle (length (z1r - z1), 2 kuulleke);
761 fill z3l{dir (alpha - gamma)}
763 .. {dir (alpha + gamma)}z2r
764 .. z2l{dir (beta + delta)}
766 .. z5l{dir (180 + beta)}
767 .. {dir (delta - 90)}z3r
770 penlabels (1, 2, 3, 4, 5);
772 alpha := -45 * widen;
774 penpos11 (1/2 thick, 90);
775 z11 = (3/2 thin, h - (thick + thin) / 2);
777 penpos13 (thin, 90 + beta);
780 penpos12 (thick, 90 + alpha);
781 x12 = 1/2 [x11, x13] - 1/4 thick;
782 y12 = h - 15/16 thick + thin * widen;
785 z14l = (0, h - thin / 2);
788 z15l = (0, h / 2 + thin / 2);
790 penpos16 (9/8 thick, 90);
791 z16r = (thin, y11r + 2/16 thick);
793 tolerance := epsilon;
795 % Find proper tension to exactly touch the x axis.
796 % Later on we directly use `bow'.
798 bow := z11r{dir (beta)}
799 ..tension t.. {dir (alpha)}z12r;
800 ypart (directionpoint right of bow) > h
803 % the return value of `solve' is stored in a dummy variable
804 t = solve f (0.8, 1.2);
808 -- z13l{dir (180 + beta)}
809 .. {dir (180 + alpha)}z12l
810 .. {dir (180 + beta)}z11l
817 ..tension 1.5.. {dir (beta)}cycle;
819 penlabels (range 11 thru 16);
823 fet_beginchar ("Numeral 8", "eight");
826 set_char_box (0, 11/15 height# * widen, 0, height#);
828 message "w:" & decimal w;
829 message "h:" & decimal h;
834 z1 = (w / 2, h / 2 + thick / 8);
836 penpos2 (14/8 thin, 0);
837 z2 = (w / 3, h / 2 + thin);
839 penpos3 (3/2 thin, 0);
840 z3l = (0, h / 4 + thin / 2);
845 penpos5 (thick, 90 + 90 + alpha);
846 z5 = z1 + w / 4 * dir (alpha - 90);
848 penpos6 (thick, 90 + 90 + alpha);
849 z6 = z1 + (w / 4 - thin / 2) * dir (90 + alpha);
852 z7r = (x1 + .02 w, h);
854 penpos8 (3/2 thin, 0);
855 z8r = (w - thin / 2, 3/4 h + thin / 2);
857 penpos9 (13/8 thin, 0);
860 penlabels (range 1 thru 9);
865 fill z2r{dir (180 + beta)}
868 .. z5r{dir (90 + alpha)}
869 -- z6r{dir (90 + alpha)}
870 ..tension t.. z7r{right}
872 .. {dir (180 + beta)}z9r
876 .. {dir (alpha - 90)}z6l
877 -- z5l{dir (alpha - 90)}
878 ..tension t.. z4l{left}
885 fet_beginchar ("Numeral 9", "nine");
889 currentpicture := currentpicture scaled -1;
890 currentpicture := currentpicture shifted (w, h);
899 "7" kern 0.15 space#;