lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Metafont optional parameters


From: Owen Lamb
Subject: Re: Metafont optional parameters
Date: Mon, 1 Jun 2020 12:52:44 -0700

Thank you, Werner and Han-Wen!

Han-Wen, I decided to go for your first solution, which is now committed. I
figured that eventually the argument won't have to be optional anyway, so
it would probably look cleaner in the end to have another argument in an
already-existing macro than to have a whole other macro sitting on the side.

Werner, in case you were wondering what I had previously:

In the definition for fet_beginchar in feta-autometric.mf, I declared
string ... smuflcode; at line 242 (these being the line numbers from before
today's commit). I then declared the default value to be smuflcode := "0"; at
line 245.

Then, as a test example, I added the following two lines to
feta-noteheads.mf the beginning of the fet_beginchar ("Whole notehead",
"s0"); definition at lines 242-243:
string smuflcode;
smuflcode := "E0A2";
This redefined smuflcode for this character as the SMuFL whole note code
point, but it took two lines, which would have added up to a lot of
repetitive code if it were used at every character definition. (I had tried
it without the seemingly redundant string type declaration, but compiling
gave me an error.)

This worked, i.e. the code could output the assigned SMuFL code (or the
default 0) correctly with the other character properties in the log
file for python to read (see feta-autometric.mf, line 89). It was just
repetitive, is all. Now, I've replaced this system with a mandatory third
argument, as Han-Wen suggested, which you can see in my latest commit.

I suppose in the future it would be nice to know how to make optional
arguments in MF, but I only ever meant to use them here temporarily, so no
harm done. Does this all sound good?

--Owen

On Sun, May 31, 2020 at 1:31 AM Han-Wen Nienhuys <hanwenn@gmail.com> wrote:

> On Sun, May 31, 2020 at 12:41 AM Owen Lamb <owendlamb@gmail.com> wrote:
> >
> > Hi all,
> >
> > I'd like to add an optional parameter for smuflcode to fet_beginchar, so
> > that I don't have to take two lines redeclaring the variable in every
> > glyph. Ideally, it won't have to be optional once every character has it,
> > but in the meantime, it would help with testing individual characters'
> new
> > encodings.
>
> > I wasn't able to find whether MF supports optional parameters, only that
> > certain built-in functions have them. Does anyone with MF experience know
> > if it does, and, if so, how to put one in?
>
> I don't understand what you mean with  "two lines". I see two options:
>
> 1) just make the smuflcode apply everywhere, and not bother with
> variable args. Use your editor's search & replace to change
> fet_beginchar everywhere inserting the "0" as needed. Since you're
> using strings, you can also use magic code (eg. "undef") which is
> easier to grep for afterwards.
>
> 2) set the smuflcode to "undef" in the fet_beginchar() macro, and
> provide a set_smufl_code() macro that allows an override. You only
> insert the override in the chars for which you define a smufl code.
>
> --
> Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]