]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-beugel.mf
* lily/font-metric.cc (get_indexed_char_stencil): Bugfix: get
[lilypond.git] / mf / feta-beugel.mf
1
2 % feta-beugel.mf -- [Staff] braces
3
4 % source file of the Feta (not an acronym for Font-En-Tja)
5 % pretty-but-neat music font
6
7 % (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 %                Jan Nieuwenhuizen <janneke@gnu.org>
9
10 input feta-autometric;
11 input feta-macros;
12
13 staffsize# := 20 pt#;   %% arbitrary.
14
15 input feta-params;
16
17
18 def abc_encode_int (expr i) =
19         if i > 0:
20                 abc_encode_int (i div 26) & char (65 + i mod 26)
21         else:
22                 "A"
23         fi
24 enddef ;
25
26 % we must let the design increase for each
27 % font to make sure that mftrace doesn't jack up the resolution too highly
28 % for the longer braces.
29 fet_beginfont ("feta-braces-" & char (97 + font_count), (font_count + 1) * 15,
30                "fetaBraces");
31
32 mode_setup;
33
34
35
36 save code;
37 code := 64;
38
39
40 def draw_brace (expr height_sharp, width_sharp, slt_sharp) =
41
42         save pendir, height, width, thin, thick, slt;
43         save penangle;
44         height# := height_sharp;
45         width# := width_sharp;
46         slt# := slt_sharp;
47
48 %% +1  is needed because fet_beginchar increments after dumping the strings.
49 fet_beginchar ("brace number " & (decimal (code + 1)),
50   "brace" & abc_encode_int (code - 64),
51   "brace" & abc_encode_int (code - 64))
52
53         set_char_box (0, width#, height#/2, height#/2);
54           
55         define_pixels (height, width, slt);
56         thin = 2 slt;
57         thick = .5 width;
58         
59         z2 = .5 [z1, z3];
60         y3l = y1 + height/2;
61         x3 = x1 + width;
62         y1 =0;
63         x3 = - width / 2;
64
65         pair pendir;
66         pendir = unitvector(x3 - x1, y3l/6 - y1);
67         penangle = angle pendir - 90;
68         penpos3(thin, penangle);
69         penpos2(thick, angle(z3 -z1) -90 );
70         penpos1(2/3 thin, penangle);
71         
72         penlabels(1,2,3);
73         fill z2r ..  simple_serif (z3r, z3l, 90)
74                 .. z2l .. simple_serif (z1l, z1r, 90) ..cycle;
75
76         addto currentpicture also currentpicture yscaled -1;
77 fet_endchar;
78 enddef;
79
80
81
82 save stafflinethickness;
83 save increment;
84
85 linethickness := 0.5pt#;
86 increment := 0.5pt#;
87 y := 10pt#;
88
89
90
91 for i := 0 step 1 until font_count:
92
93   %% We can't store more than 64 (65?) height dimensions in a TFM
94   %% file, so we make small files.
95
96   for j := 0 step 1 until 63:
97     % message "l: "&decimal l;
98     % note: define_pixels (x) multiplies x by hppp,
99     % must never get bigger than infinity
100     y := y + increment;
101
102     if y > infinity/hppp:
103       message "Resolution and/or magnification is too high";
104       error please report: <bug-lilypond@gnu.org>;
105     fi
106
107     % x should be about one staff space, taking brace to have
108     % default height of 3 staffs, this yields height / 3 / 4 = 12
109     % but 15 looks better
110     x := y / 15;
111
112     increment := x / 10;
113     linethickness :=  min (0.5pt#, y/150);
114     if i = font_count:
115       draw_brace (y, x, linethickness);
116     fi
117   endfor;
118 endfor
119   
120 fet_endfont("feta-braces");