X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mf%2Ffeta-macros.mf;h=89458e3c3dbb7e69358eed3f70813507bb988e98;hb=97a0169312a260933246ab224e4f8b0969871dd5;hp=d50946054dc381e80351dd181c3f4bad553b51ee;hpb=71dd5f6c45009b85d2f9232d31370ee81cf21f5a;p=lilypond.git diff --git a/mf/feta-macros.mf b/mf/feta-macros.mf index d50946054d..89458e3c3d 100644 --- a/mf/feta-macros.mf +++ b/mf/feta-macros.mf @@ -1,7 +1,27 @@ +% Feta (not the Font-En-Tja) music font -- auxiliary macros for both feta and parmesan fonts +% This file is part of LilyPond, the GNU music typesetter. +% +% Copyright (C) 1997--2015 Han-Wen Nienhuys +% +% The LilyPond font is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version, or under the SIL Open Font License. +% +% LilyPond is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with LilyPond. If not, see . + + % % debugging % + def print_penpos (suffix $) = message "z" & str$ & "l = (" & decimal x.$.l & ", " &decimal y.$.l & ");" @@ -31,13 +51,15 @@ def treq = enddef; -def draw_staff (expr first, last, offset) = +def draw_staff_if_debugging (expr first, last) = if test <> 0: pickup pencircle scaled stafflinethickness; for i := first step 1 until last: - draw (-staff_space, (i + offset) * staff_space) - .. (4 staff_space, (i + offset) * staff_space); + draw (-staff_space, + (i + stafflines_y_offset) * staff_space_rounded) + -- (4 staff_space, + (i + stafflines_y_offset) * staff_space_rounded); endfor; fi; enddef; @@ -55,8 +77,10 @@ def draw_staff_outline (expr first, last, offset) = pickup pencircle scaled 2; for i := first step 1 until last: - p := (-staff_space, (i + offset) * staff_space) - .. (4 staff_space, (i + offset) * staff_space); + p := (-staff_space, + (i + offset) * staff_space_rounded) + -- (4 staff_space, + (i + offset) * staff_space_rounded); draw p shifted (0, .5 stafflinethickness); draw p shifted (0, -.5 stafflinethickness); @@ -137,7 +161,7 @@ def make_pen_stack = enddef; -def del_pen_stack= +def del_pen_stack = save save_pen_stack, pen_stack_idx; enddef; @@ -161,6 +185,36 @@ def soft_penstroke text t = enddef; +def soft_start_penstroke text t = + forsuffixes e = l, r: + path_.e := t; + endfor; + + if cycle path_.l: + cyclestroke_; + else: + fill path_.l + -- reverse path_.r + ..tension1.5.. cycle; + fi; +enddef; + + +def soft_end_penstroke text t = + forsuffixes e = l, r: + path_.e := t; + endfor; + + if cycle path_.l: + cyclestroke_; + else: + fill path_.l + ..tension1.5.. reverse path_.r + -- cycle; + fi; +enddef; + + % % Make a round path segment going from P to Q. 2*A is the angle that the % path should take. @@ -178,31 +232,33 @@ enddef; def draw_rounded_block (expr bottom_left, top_right, roundness) = begingroup; - save round; + save size; save x, y; - round = floor min (roundness, - xpart (top_right - bottom_left), - ypart (top_right - bottom_left)); - - pickup pencircle scaled round; + % Originally, there was `floor' instead of `round', but this is + % not correct because pens use `round' also. + size = round min (roundness, + xpart (top_right - bottom_left), + ypart (top_right - bottom_left)); - z2 + (round / 2, round / 2) = top_right; - z4 - (round / 2, round / 2) = bottom_left; + z2 + (size / 2, size / 2) = top_right; + z4 - (size / 2, size / 2) = bottom_left; y3 = y2; y4 = y1; x2 = x1; x4 = x3; - fill bot z1 - .. rt z1 - --- rt z2 - .. top z2 - --- top z3 - .. lft z3 - --- lft z4 - .. bot z4 - --- cycle; + pickup pencircle scaled size; + + fill bot z1{right} + .. rt z1{up} + -- rt z2{up} + .. top z2{left} + -- top z3{left} + .. lft z3{down} + -- lft z4{down} + .. bot z4{right} + -- cycle; endgroup; enddef; @@ -221,10 +277,10 @@ def draw_square_block (expr bottom_left, top_right) = y2 = ypart top_right; fill (x1, y1) - --- (x2, y1) - --- (x2, y2) - --- (x1, y2) - --- cycle; + -- (x2, y1) + -- (x2, y2) + -- (x1, y2) + -- cycle; enddef; @@ -284,34 +340,44 @@ enddef; % line = diameter of line attachment % direction = is ink on left or right side (1 or -1) % +% Note that `currentpen' must be set correctly -- only circular pens +% are supported properly. def flare_path (expr pos, alpha, beta, line, flare, direction) = begingroup; + save thick; + + thick = pen_top + pen_bot; + clearxy; - penpos1 (line, 180 + beta + alpha); - z1r = pos; + penpos1' (line - thick, 180 + beta + alpha); + top z1'r = pos; - penpos2 (flare, 180 + beta + alpha); - z2 = z3; + penpos2' (flare - thick, 180 + beta + alpha); + z2' = z3'; - penpos3 (flare, 0 + alpha); - z3l = z1r + (1/2 + 0.43) * flare * dir (alpha + beta); + penpos3' (flare - thick, 0 + alpha); + rt x3'l = hround (x1'r + + (1/2 + 0.43) * flare * xpart dir (alpha + beta)); + bot y2'l = vround (y1'r + + (1 + 0.43) * flare * ypart dir (alpha + beta)); - z4 = z2r - line * dir (alpha); + rt x4' = x2'r - line * xpart dir (alpha); + y4' = y2'r - line * ypart dir (alpha); - penlabels (1, 2, 3, 4); + penlabels (1', 2', 3', 4'); save t, p; t = 0.833; path p; - p := z1r{dir (alpha)} - .. z3r{dir (180 + alpha - beta)} - .. z2l{dir (alpha + 180)} - .. z3l{dir (180 + alpha + beta)} - ..tension t.. z4{dir (180 + alpha + beta)} - .. z1l{dir (alpha + 180)}; + p := z1'r{dir (alpha)} + .. z3'r{dir (180 + alpha - beta)} + .. z2'l{dir (alpha + 180)} + .. z3'l{dir (180 + alpha + beta)} + ..tension t.. z4'{dir (180 + alpha + beta)} + .. z1'l{dir (alpha + 180)}; if direction <> 1: p := reverse p; @@ -392,7 +458,8 @@ enddef; def draw_bulb (expr turndir, zl, zr, bulb_rad, radius_factor)= begingroup; - save rad, ang; + save rad, ang, pat; + path pat; clearxy; @@ -404,16 +471,39 @@ begingroup; rad = bulb_rad; - z1' = z0' + radius_factor* rad * dir (ang + turndir * 100); + z1' = z0' + radius_factor * rad * dir (ang + turndir * 100); z2' = z0' + rad * dir (ang + turndir * 300); labels (0', 1', 2'); - fill zr{dir (ang + turndir * 90)} - .. z1' - .. z2' + pat = zr{dir (ang + turndir * 90)} + .. z1' + .. z2' + .. cycle; + + % avoid grazing outlines + fill subpath (0, 2.5) of pat -- cycle; endgroup enddef; + pi := 3.14159; + + +% +% To get symmetry at low resolutions we need to shift some points and +% paths, but not if mf2pt1 is used. +% + +if known miterlimit: + vardef hfloor primary x = x enddef; + vardef vfloor primary y = y enddef; + vardef hceiling primary x = x enddef; + vardef vceiling primary y = y enddef; +else: + vardef hfloor primary x = floor x enddef; + vardef vfloor primary y = (floor y.o_)_o_ enddef; + vardef hceiling primary x = ceiling x enddef; + vardef vceiling primary y = (ceiling y.o_)_o_ enddef; +fi;