Debian Codegraph @

texmf-dist/doc/latex/lilyglyphs/documentation/lilyglyphs.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 % %
3 % This file is part of the 'lilyglyphs' LaTeX package. %
4 % ========== %
5 % %
6 % https://github.com/openlilylib/lilyglyphs %
7 % http://www.openlilylib.org/lilyglyphs %
8 % %
9 % Copyright 2012-2020 Urs Liska and others, [email protected] %
10 % %
11 % 'lilyglyphs' is free software: you can redistribute it and/or modify %
12 % it under the terms of the LaTeX Project Public License, either %
13 % version 1.3 of this license or (at your option) any later version. %
14 % You may find the latest version of this license at %
15 % http://www.latex-project.org/lppl.txt %
16 % more information on %
17 % http://latex-project.org/lppl/ %
18 % and version 1.3 or later is part of all distributions of LaTeX %
19 % version 2005/12/01 or later. %
20 % %
21 % This work has the LPPL maintenance status 'maintained'. %
22 % The Current Maintainer of this work is Urs Liska (see above). %
23 % %
24 % This work consists of the files listed in the file 'manifest.txt' %
25 % which can be found in the 'license' directory. %
26 % %
27 % This program is distributed in the hope that it will be useful, %
28 % but WITHOUT ANY WARRANTY; without even the implied warranty of %
29 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. %
30 % %
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32
33 \documentclass[oneside]{scrreprt}
34 \usepackage{lilyglyphsStyle}
35 \usepackage{lilyglyphsManualFonts}
36 \usepackage{paralist}
37 \begin{document}
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 % Title page
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42
43 \title{\lilyglyphs[scale=1.5]\\~\\
44 \normalsize Version 0.2.3}
45 \author{Urs Liska}
46
47 \maketitle
48
49 \pagebreak
50
51 \section*{Quick Start}
52 \lilyglyphs{} enables \LaTeX{} to include arbitrary notational elements from the LilyPond%
53 \footnote{\url{http://www.lilypond.org}}
54 notation software like characters in continuous text.
55 As it uses \package{fontspec} to access glyphs from an OpenType font \lilyglyphs{} works with \hologo{XeLaTeX} or \hologo{LuaLaTeX} exclusively.
56
57 If you have obtained the package as part of a \TeX{} distribution the following Minimal Working Example should get you going in a minute and show if everything works correctly.
58 If you have downloaded the package please refer to \fref{sec:installation} for a few more preliminary installation steps.
59
60 \medskip
61
62 \begin{lstlisting}[language={[LaTeX]TeX}]
63 \documentclass{article} % Should work with any documentclass
64 \usepackage{fontspec} % Is necessary to access OpenType fonts
65 \usepackage{lilyglyphs} % Currently there are no package options available
66 \begin{document}
67 \flatflat{} or \clefGInline. % Predefined commands,
68 % Use {} to allow trailing whitespace
69 \lilyGlyph[scale=1.2, raise=.5]{timesig.neomensural64}
70 % Access "Emmentaler" glyphs by their name
71 % Generic commands have one mandatory
72 % and one optional (placement) argument.
73 \twoBeamedQuavers % Commands that include images instead of font glyphs.
74 \end{document}
75 \end{lstlisting}
76
77 \medskip
78 In the text you can use predefined commands like \flatflat{} or \clefGInline.
79 Commands without the pair of curly braces swallow any trailing whitespace -- use these before punctuations or to combine symbols.
80 For the available predefined commands consult the reference in \fref{chap:list_predefined_commands}.
81
82 Glyphs that are part of LilyPond's \emmentaler{} font but not covered by a predefined command yet can be accessed through the generic command \cmd{lilyGlyph\{GLYPHNAME\}}, the glyph names being listed in \url{http://www.lilypond.org/doc/v2.16/Documentation/notation/the-feta-font.html}
83 or in the file \dir{the-feta-font-2-16-2.html} located in the the \dir{documentation} directory of the package.
84 As an example take this neomensural time signature \lilyGlyph[scale=1.2, raise=.5]{timesig.neomensural64}.
85 Other symbols can be included as image files \twoBeamedQuavers[scale=.95], but from the author's perspective this doesn't make a difference.
86
87 All commands accept an optional argument containing \texttt{key=value} pairs.
88 Currently two keys are supported:
89 \texttt{scale} multiplies the size of the glyph by the given factor while \texttt{raise} shifts it vertically by the given amount interpreted as \emph{ex}.
90 Glyphs accessed individually generally need these options, see the neomensural time signature in the example.
91
92 Apart from the Emmentaler glyphs \lilyglyphs{} can include any notational construct that LilyPond can produce.
93 Please refer to \fref{sec:generic_access_commands} to learn about the \emph{generic access commands} and to \fref{sec:generating_commands_image} for detailed instructions how to create custom commands.
94
95 \lilyglyphs{} elements \tiny automatically \halfNoteRest{} \normalsize or manually \huge \halfNoteRest{} \normalsize scale with the \halfNoteRest{} text size commands.
96
97 \tableofcontents
98 \vfill
99
100 \pagebreak
101
102 \vfill
103 %\input{copyright-notice.inp}
104
105 \chapter{Introduction}
106 \label{chap:introduction}
107
108 \lilyglyphs{} came into existence when I looked for a way to include arbitrary notational elements in the continuous text of \LaTeX{} documents.
109 Unfortunately all packages I could find were quite restricted in the number of available symbols and/or their flexibility in scaling with the text size.
110 Moreover no solution came near the beauty of the engraving of LilyPond%
111 \footnote{\url{http://www.lilypond.org}}.
112 Therefore I decided to “roll my own” package and make the notation font and notational elements of LilyPond available to \LaTeX{} documents.
113
114 LilyPond is a promising competitor in producing the most beautiful musical engraving on the market, and one of the foundations of this beauty is its \emmentaler{} font.
115 \lilyglyphs{} accesses the Emmentaler font through the \package{fontspec} package and inserts its glyphs in the continuous text applying sophisticated control over scaling and spacing.
116 Therefore it relies on a \LaTeX{} engine supporting \package{fontspec}.
117 It was written using \hologo{XeLaTeX}, but thanks to the contribution of Dave Bellows%
118 \footnote{\url{http://www.davebellows.com}}
119 it now also works with \hologo{LuaLaTeX}%
120 \footnote{Principally it is possible to extend the functionality so it would also work with plain \LaTeX{} by accessing non-OpenType variants of the font, but as the package maintainer has neither experience nor active interest in this area this will only be implemented if there are volunteers who join us.}.
121
122 The Emmentaler font only provides a subset of LilyPond's notational capabilities, as LilyPond draws many symbols itself.
123 After some experiments with drawing such elements in \LaTeX{} it became clear that this approach isn't really maintainable -- and especially wouldn't provide a sufficient output quality.
124 Therefore this kind of elements is included through small \textsc{pdf} image files that have explicitely been created with LilyPond.
125
126 Great care has been taken to make the notational elements scale well with the surrounding text font size.
127 Each single element can be scaled and vertically shifted, but the settings can also be done per document to accomodate for unusual body fonts that might not match too well with \lilyglyphs.
128
129 \medskip
130 The coverage of glyphs is far from being comprehensive, but the package is already very usable for real-world documents.
131 Any Emmentaler glyph that isn't covered yet by a predefined command can be accessed by its name.
132 Other -- image based -- commands (for example arbitrarily complex musical expressions) can be added through a process that has been made as simple as possible (although it involves using external software such as LilyPond and possibly Python).
133 Details about extending \lilyglyphs{} with additional commands can be found in \fref{chap:python_scripts}.
134
135
136 As the number of possible commands seems endless we would be extremely happy about any contribution of new material.
137 But there are also technical details with regard to \LaTeX{} programming where additional competence would be highly welcome.
138 You may have a look at the issue tracker%
139 \footnote{\url{https://github.com/openlilylib/lilyglyphs/issues}}
140 to get an idea where you could help.
141
142 \bigskip
143
144 Originally \lilyglyphs{} was a project on its own but by now it is part of a rather large family of projects around engraving musical scores with LilyPond and typesetting texts with \LaTeX: openLilyLib%
145 \footnote{\url{http://www.openlilylib.org}}.
146 If you have come here mainly as a \LaTeX{} document author you should also have a look at the \package{musicexamples} package%
147 \footnote{\url{http://www.openlilylib.org/musicexamples}}.
148 If you are also interested in LilyPond itself you might find the tutorials section, \package{lilylib} and \package{lilypond-doc} interesting too.
149 A few more projects are still in the planning phase, and you can always see the current state of affairs at our Github starting page%
150 \footnote{\url{https://github.com/openlilylib}}.
151 \lilyglyphs{} is developed in the \dir{lilyglyphs} directory of this project site, there you can inspect the source, clone or fork the repository, and submit issue reports.
152 If you are interested in participating in the development of \lilyglyphs, don't hesitate to contact us directly\footnote{\url{mailto:[email protected]}}.
153
154 \section{Installation}
155 \label{sec:installation}
156
157 \paragraph{Installation Options}
158 There are several ways to get \lilyglyphs{} up and running: As part of a \TeX{} distribution, as a download from CTAN%
159 \footnote{http://www.ctan.org/pkg/lilyglyphs}
160 or through its development repository on GitHub%
161 \footnote{\url{https://github.com/openlilylib/lilyglyphs}},
162 which is the recommended way if you're familiar with Git.
163 If it's contained in your distribution you should be able to simply \emph{use} the package and start typing, e.\,g. with the example given in the “Quick Start” at the beginning of this manual.
164 Otherwise there are a few steps of manual installation.
165
166 \lilyglyphs{} is known to need fairly recent versions of \package{fontspec} and \hologo{LuaLaTeX}.
167 So if you haven't got \lilyglyphs{} through your \LaTeX{} distribution you may have to take care that you use a sufficiently current distribution.
168
169 \textbf{\textsf{Note:}} If you have installed the package through a distribution you can still use one of the following installation methods because both will actually \emph{hide} the distribution installation.
170 One advantage of this approach is that you can access this manual conveniently using \texttt{texdoc lilylgyphs}.
171 But if you want to use the included Python scripts you should be careful to run the correct versions of them.
172
173 \paragraph{CTAN Download}
174 If you've downloaded the package from CTAN you should extract the archive to a location in the \dir{tex/latex/} directory of your \textsc{texmfhome} (e.\.g. \dir{\textasciitilde/texmf/} on Linux or \dir{\textasciitilde/Library/texmf/} on Mac OS X).
175
176 \paragraph{GitHub Download}
177 If you're familiar with Git the recommended way to use \lilyglyphs{} is to create a fork of the GitHub repository (assuming you already have a Github account).
178 Inside the same \dir{tex/latex/} dir run \texttt{git clone [email protected]:YOURUSERNAME/lilyglyphs.git} -- please don't provide an alternative destination name because the package should actually reside in a directory called \dir{lilyglyphs/}.
179 Then \texttt{cd} into that directory and add the original repository with \texttt{git remote add upstream [email protected]:openlilylib/lilyglyphs.git}.
180 From now on you will refer to your fork as \texttt{origin} and to the official repository as \texttt{upstream}.
181
182 The most immediate advantage of using \lilyglyphs{} through the Git repository is that it is the easiest way to keep the package up to date.
183 Each time someone adds new commands to the package they will be instantly available through the repository while regular releases will happen much less frequently.
184 And if updates should somehow break syntax in existing documents you can easily (and temporarily) check out the earlier version of the package you had used when originally writing your documents.
185 Another advantage of the repository version is that you have “direct access” to extending the package with predefined commands in a way that makes it easy for us to incorporate your contribution in the official package.
186
187 \paragraph{Font Considerations}
188 If you install \lilyglyphs{} manually you will have to make the included \emmentaler{} OpenType font available for \LaTeX.
189 Copy the complete \dir{fonts/} folder from the package directory to \dir{TEXMFHOME/fonts/opentype} (creating these subdirectories if they aren't already present on your system) and rename it to a more explicit name such as ‘emmentaler’ or ‘lilyglyphs’.
190 An even better way would be not to copy the files but rather create a symlink to it with \texttt{cd TEXMFHOME/fonts/opentype} and \texttt{ln -s /path/to/lilyglyphs/fonts emmentaler} \todo{check on Windows}.
191 That way no manual adjustments have to be made when \lilyglyphs{} is updated and might bring new versions of the font files with it.\\
192 \textbf{\textsf{Note:}} the package probably won't work with \hologo{XeLaTeX} if you also have installed \emmentaler{} as a system font.\\
193 \textbf{\textsf{Note:}} If you create a link instead of a copy you have to make sure that there is at least one regular file or subdirectory in the directory beside the link.
194 Otherwise \hologo{LuaLaTeX} won't find the font, which is a limitation in the \texttt{kpathsea} library.
195 The easiest way is to simply add an empty \dir{dummy/} subdir.
196
197 \medskip
198 If you experience any issues with this or other topics during installation please give us feedback so we can improve documentation .
199
200 \section{License}
201 \label{sec:license}
202
203 \lilyglyphs{} is distributed under the \LaTeX{} Project Public License version 1.3 or (at your option) any later version of this license.
204 You may find the latest version of this license at \url{http://www.latex-project.org/lppl.txt}, and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later.
205 A full copy of the license is enclosed in the file \dir{/license/COPYING.LPPL} of the package.
206 The file \dir{/license/MANIFEST} contains a list of all files affected by this licensing.
207
208 The package is currently maintained by its original author Urs Liska, but its \textsc{lppl} status is simply ‘maintained’.
209
210 \medskip
211 \lilyglyphs{} contains the \emmentaler{} OpenType font developed provided by the LilyPond project (\url{http://www.lilypond.org}).
212 It is redistributed unmodified under the SIL Open Font License, Version 1.1.
213 For details see \dir{/otf/LICENSE.OFL} and \dir{/otf/FONTLOG}.
214
215 \chapter{Usage}
216 \label{chap:usage}
217
218 As mentioned in the Quick Start at the beginning of this document you have to activate \lilyglyphs{} with \cmd{usepackage\{fontspec\}} \cmd{usepackage\{lilyglyphs\}}.
219 This will give you access to the predefined commands and some generic access commands.
220
221 \section{Usage of Predefined Commands}
222 \label{sec:usage_predefined_commands}
223 A number of predefined commands is available for immediate use.
224 To use them you just have to enter the command to print the corresponding musical element, e.\,g. \cmd{lilyTimeC} for a \lilyTimeC.
225 A complete reference of these commands is available in \fref{chap:list_predefined_commands}, along with any specific comments that might be necessary.
226
227 As you will see later there are some commands that take arguments and many that don't.
228 Commands without mandatory arguments behave like e.\,g. the well-known \cmd{LaTeX} command in that they swallow any whitespace entered after them.
229 So in order to allow a space to be printed afterwards you have to supply a pair of curly braces, like \cmd{flat\{\} and more} to print “\,\flat{}\ and more”.
230 Commands with arguments don't need this special treatment, so you can simply write a space character after them or not like \cmd{lilyDynamics\{mf\} or \textbackslash lilyDynamics\{pp\}.} to achieve \lilyDynamics{mf} or \lilyDynamics{pp}.
231
232 \section{Generic Access Commands}
233 \label{sec:generic_access_commands}
234
235 There is a wealth of conceivable musical symbols and only a limited number of predefined commands.
236 Even when this package will become more and more comprehensive there will always be cases that haven't been covered yet.
237 For these cases \lilyglyphs{} provides four generic access commands:
238 \begin{itemize*}
239 \item \cmd{lilyGlyph}
240 \item \cmd{lilyGlyphByNumber}
241 \item \cmd{lilyText}
242 \item \cmd{lilyImage}.
243 \end{itemize*}
244
245 They all accept one mandatory and one optional argument, the mandatory one being the content to be printed.
246 This content has to be given in a form specific to the respective command.
247
248 \paragraph*{\cmd{lilyGlyph}} expects the OpenType glyph name.
249 You can look up the glyph names in the Appendix of LilyPond's \emph{Notation Reference}\footnote{\url{http://www.lilypond.org/doc/v2.16/Documentation/notation/the-feta-font}} or in the somewhat reduced html page provided in the \dir{/documentation} directory of the package download.\\
250 Please note that many Emmentaler glyphs, especially articulations, are aligned to their center because that's what they are used like in a score.
251 So don't be surprise if you need considerable extra space before such glyphs.
252 This isn't a bug but rather a characteristic of using the glyphs in a different context than they were designed for.
253
254 \paragraph*{\cmd{lilyGlyphByNumber}} expects the Unicode code number of the glyph.
255 You will generally not want to use this as the code positions aren't guaranteed to stay the same with new versions of the fonts.
256 There may be some uses for numerical access however, e.\,g. if you want to iterate over a range of glyphs.
257
258 \paragraph*{\cmd{lilyText}} expects ordinary text as its argument.
259 In fact it just switches the font to Emmentaler and then writes the string given as the argument.
260 This only works for Dynamics letters, numbers and the glyphs \lilyText[scale=2]{+ - , .} -- as these glyphs are located at their ordinary \textsc{ascii} character position in the font.
261 But you can also enter any spacing commands (like \cmd{hspace} or plain spaces) to control the spacing between glyphs.
262 But keep in mind that this may result in line breaking inside your expression.
263 If you need to prevent this you can surround your expression by an \cmd{mbox}.\\
264 (There is a special command provided -- \cmd{lilyDynamics} -- which is essentially a wrapper around \cmd{lilyText} and presets the character size to a suitable default.)
265
266 \paragraph*{\cmd{lilyImage}} expects the basename of an image file your \TeX{} system can process.
267 It then includes this file using the same optional argument mechanism as the other commands.
268 What sets this command apart from simply including an image is that it automatically scales the image relative to the current text font size, with being printed at its original size at \cmd{normalsize}.
269 You have to take care yourself that \LaTeX{} finds and can handle the image file.
270 While this command has originally been created to print images generated by LilyPond you can actually print \emph{any} image, e.\,g. scanned images from autographs, taking advantage of \lilyglyphs' infrastructure, for example the optional arguments described in the following section.
271
272 \section{The Optional Argument: Layout Adjustment}
273 \label{sec:optional_argument}
274 The generic access commands as well as the predefined commands allow an optional argument to be passed.
275 This can contain a list of comma-separated options in \texttt{<key=value>} form that influence the appearance of the glyphs. Currently there are the \texttt{scale} and \texttt{raise} options.
276
277 \paragraph*{\texttt{scale}}
278 changes the size of the glyph.
279 As the Emmentaler glyphs are designed for a totally different purpose they often don't fit very well in the context of continuous text.
280 \texttt{scale} is given as a factor by which the default size is multiplied.
281 With Emmentaler glyphs this has to be a positive number, otherwise you will get an error.
282 But glyphs printed by \cmd{lilyImage} (or predefined commands based on it) can also be scaled negatively.
283 This results in an image that is rotated around the center of the bottom line of the original.
284 You will therefore have to add an appropriate \texttt{raise} value (try e.\,g. 2 as a starting point).
285 You will have to take some care about the horizontal spacing, as such a flipped image seems to use it with inverted direction.
286 But you can safely put extra horizontal space after the image, and it is a valid and practical way to create two symbols from one image file.
287
288 \paragraph*{\texttt{raise}}
289 changes the vertical placement of the glyph.
290 The majority of glyphs is placed too low by default, so they need a positive \texttt{raise} value.
291 \texttt{raise} is given as a decimal value without units, which is interpreted as \emph{ex}, or x-height.
292 As there is no \emph{x} in a musical font, this is somewhat arbitrary, but it is a natural unit to scale with the surrounding font size.
293 Usually you may start trying \texttt{raise} values between 0 and 0.5.
294
295 \bigskip
296 These layout adjustments can be made at three different stages: at design time (of predefined commands), globally (per document), and at command invocation.
297
298 \paragraph*{At design time}
299 a designer of a predefined command has already selected the optimal default values so the command will work out-of-the-box in most cases.
300
301 \paragraph*{Globally}
302 the layout adjustments default to values that leave the glyphs unaltered (i.\,e. \texttt{scale=1} and \texttt{raise=0}).
303 A document author can override these defaults at any time with \cmd{lilyGlobalOptions\{<options>\}}.
304 This may for example be necessary if you use a text font which doesn't harmonize well with \lilyglyphs' default settings, for example because of its unusual x-height.
305 You can use this command at the beginning of the document to modify the appearance for the whole document, or you can change its settings multiple times throughout the document.
306 This is what you generally have to do when using \cmd{lilyGlyph} for printing individual glyphs from Emmentaler.
307
308 \paragraph*{At command invocation}
309 you can pass the layout adjustment options for the specific instance of the glyph.
310
311 \bigskip
312 The values that finally affect the layout of any given glyphs take all three stages into account.
313 By passing an option at command invocation you don't set absolute values, but modify the values already present.
314 The effective \texttt{scale} value is \mbox{\texttt{designtime * global * invocation}}, the effective \texttt{raise} is \mbox{\texttt{designtime + global + invocation}}.
315 So passing a \texttt{scale=1.1} will always slightly increase the glyph's size, no matter what settings are already in effect.
316
317 \textit{Technically speaking \lilyglyphs{} applies a fourth layer of scaling with image files.
318 It calculates a last scaling factor by multiplying the result of the above considerations with the ratio of the current font size versus the size of the \cmd{normalsize} font.}
319
320
321 \section{Example: Define a Custom Command}
322 \label{sec:example}
323 Now it's time for an example that actually uses the generic access commands to print symbols provided by the Emmentaler font.
324 It will walk you through the process up to defining a ‘local’ predefined command.
325
326 We want to print the \emph{fermata} sign which isn't implemented yet as a predefined command.
327 In the documentation we have looked up the name of the glyph: \texttt{scripts.ufermata}, so you can print it with \cmd{lilyGlyph\{scripts.ufermata\}}: \lilyGlyph{scripts.ufermata}.
328 While this gives us the right glyph its appearance isn't really what we're after yet and we want to adjust its size and placement.
329 This is done with the optional argument described in the previous subsection.
330
331 First we increase the size of the glyph with the \texttt{scale} argument. We find that a scaling factor of 1.4 seems suitable:
332 \cmd{lilyGlyph[scale=1.4]\{scripts.ufermata\}} -- \lilyGlyph[scale=1.4]{scripts.ufermata}
333
334 As you can see the glyph is -- as most Emmentaler glyphs are -- placed too low, so you have to add the \texttt{raise} argument. A value of 0.3 seems fine -- remember, the raise argument is interpreted as \emph{ex}, but you don't write down the unit.\\
335 \cmd{lilyGlyph[scale=1.4,raise=0.3]\{scripts.ufermta\}} -- \lilyGlyph[scale=1.4,raise=0.6]{scripts.ufermata}
336
337 You can now further see that the glyph is placed too far to the left -- which is a good example of the behaviour described earlier with the \cmd{lilyGlyph} command.
338 In fact it seems the point in the middle of the fermata is placed where we would expect the glyph to start.
339 So you have to add some leading space, which might be practical to be entered in \emph{ex}:\\
340 \cmd{hspace\{1ex\}}\cmd{lilyGlyph[scale=1.4,raise=0.3]\{scripts.ufermta\}} -- \hspace{1ex}\lilyGlyph[scale=1.4,raise=0.3]{scripts.ufermata}
341
342 \medskip
343 If you want you can now simply enclose this definition in a \cmd{newcommand} to be able to reuse it.
344 \cmd{newcommand\{\textbackslash fermata\}\{hspace\{1ex\}}\cmd{lilyGlyph[scale=1.4,raise=0.3]\{scripts.ufermta\}}.
345 After this you can enter your tweaked symbol by simply writing \cmd{fermata}.
346 However you are encouraged to create such a command the way we define predefined commands in \lilyglyphs{} itself.
347 This way it will gain the flexibility of the predefined commands, and it will be easier to be incorporated in the package itself.
348 See our instructions on how to create predefined commands the \lilyglyphs{} way in \fref{sec:howto_predefined_commands}.
349 If you manage to write a command that you find useful for others also please submit it to us -- or even better: if you figured out how to create commands in general, please join us.
350 As mentioned earlier the number of possible commands is huge, and the value of the package will increase with each step towards a comprehensive coverage.
351
352 \section{Dotted symbols}
353 \label{sec:dotted_symbols}
354 There are commands that are accompanied by \cmd{...Dotted} versions.
355 While they can be used like any other commands there are some caveats because they are technically different from normal commands, actually appending a dot to normal commands.
356
357 If you use significant scaling factors for the commands you have to check carefully whether the gap and the position of the dot scale and move well.
358 Unfortunately one can't influence the parameters of the dot independently.
359 We have worked hard to enable the designer of a command to create rules how to scale the gap, but you still may run into problems here.
360 In such a case you will have to either change the predefined command in the library or just create the dotted symbol from scratch.
361
362 Immediately after having used a dotted symbol you can arbitrarily add more dots with the \cmd{lilyPrintMoreDots} command.
363 This command uses the existing dot settings (scale and raise) and prints another dot.
364 By default it has a gap of 0.25\,ex, but you can override this by passing a number as an optional argument, which is interpreted as \emph{ex}.
365
366 For example if you take the command \cmd{halfNoteRestDotted}, which prints a dotted half note rest: \halfNoteRestDotted{} you can easily add more dots through \cmd{halfNoteRestDotted\textbackslash lilyPrintMoreDots}: \halfNoteRestDotted\lilyPrintMoreDots.
367
368 Please note that you should only call \cmd{lilyPrintMoreDots} immediately after calling a \cmd{...Dotted} command. Otherwise you may get surprising results or even errors because the underlying key-value variables are inititialized wrongly or not at all.
369
370 \section{Optical size}
371 \label{sec:optical_size}
372 The \emmentaler{} fonts come in a set of eight “optical sizes”.
373 These are variations of the font originally designed to be used at different point sizes.
374 Generally you can assume that fonts for larger sizes offer more detail and give a somewhat lighter appearance, while fonts for smaller point sizes give more weight on the paper but less detail to be readable at small sizes.
375
376 \lilyglyphs{} gives you the option to access the available font versions, but it may make more sense to appreciate them as “weights” -- although this is technically speaking or even conceptionally incorrect.
377 The eight optical sizes of the Emmentaler font are: 11, 13, 14, 16, 18, 20, 23, 26.
378 If you conceive these as weights you would somehow order them from black (11) to light (26).
379 You can switch the used optical size at any time in a document using the command \cmd{lilyOpticalSize}, giving the number as an option.
380 You could for example use this feature to adapt the LilyPond glyphs to a darker or lighter default text font.
381 Be sure to supply a number corresponding to a font actually available on your system.
382 Maybe this will someday also be available as an option to select for a single glyph, but for now you have to switch twice: before and after the glyph.
383
384 The optical size used by \lilyglyphs{} defaults to 16.
385
386 \paragraph*{Known issues and warnings:}
387 Optical sizes don't work with glyphs printed as images.
388 If you \emph{have} to use these glyphs in different weights, you will have to take care for it yourself.
389 The general plan would be to create different versions of the glyph by creating different glyphs in LilyPond (presumably by using different staff sizes).
390
391 \chapter{Reference of Predefined Commands}
392 \label{chap:list_predefined_commands}
393 The following sections document the predefined commands that already have been implemented.
394 They generally contain explanations on the specific use of the commands (if necessary) and a table listing the implemented commands.
395 Remember that any glyph of the Emmentaler font which is not covered by a predefined command yet can be accessed by its name through the \cmd{lilyGlyph} command.
396 A full list of available glyphs is available in the documentation folder of the \lilyglyphs{} package or in LilyPond's original documentation at \url{http://www.lilypond.org/doc/v2.16/Documentation/notation/the-feta-font.html}.
397
398 The documentation explicitely mentions if the commands are based on image files.
399
400 \section{Single Notes}
401 \label{sec:singlenotes}
402 Single notes may well be the most frequently used glyphs.
403 Unfortunately they aren't present in \emmentaler{} because LilyPond draws them by itself, so \lilyglyphs{} realizes them using included pdf image files.
404 The commands are available identically in British and American form.
405 See \fref{tab:singlenotes} for the available predefined commands.
406
407 \begin{reftable}{Single Notes}{singlenotes}
408 \wholeNote & \cmd{semibreve} -- \cmd{wholeNote}\\
409 \wholeNoteDotted & \cmd{semibreveDotted} -- \cmd{wholeNoteDotted}\\
410 \halfNote & \cmd{minim} -- \cmd{halfNote}\\
411 \halfNoteDown & \cmd{minimDown} -- \cmd{halfNoteDown}\\
412 \halfNoteDotted & \cmd{minimDotted} -- \cmd{halfNoteDotted}\\
413 \halfNoteDottedDown & \cmd{minimDottedDown} -- \cmd{halfNoteDottedDown}\\
414 \halfNoteDottedDouble & \cmd{minimDottedDouble} -- \cmd{halfNoteDottedDouble}\\
415 \halfNoteDottedDoubleDown & \cmd{minimDottedDoubleDown} -- \cmd{halfNoteDottedDoubleDown}\\
416 \crotchet & \cmd{crotchet} -- \cmd{quarterNote}\\
417 \crotchetDown & \cmd{crotchetDown} -- \cmd{quarterNoteDown}\\
418 \crotchetDotted & \cmd{crotchetDotted} -- \cmd{quarterNoteDotted}\\
419 \crotchetDottedDown & \cmd{crotchetDottedDown} -- \cmd{quarterNoteDottedDown}\\
420 \crotchetDottedDouble & \cmd{crotchetDottedDouble} -- \cmd{quarterNoteDottedDouble}\\
421 \crotchetDottedDoubleDown & \cmd{crotchetDottedDoubleDown} -- \cmd{quarterNoteDottedDoubleDown}\\
422 \quaver & \cmd{quaver} -- \cmd{eighthNote}\\
423 \quaverDown & \cmd{quaverDown} -- \cmd{eighthNoteDown}\\
424 \quaverDotted & \cmd{quaverDotted} -- \cmd{eighthNoteDotted}\\
425 \quaverDottedDown & \cmd{quaverDottedDown} -- \cmd{eighthNoteDottedDown}\\
426 \quaverDottedDouble & \cmd{quaverDottedDouble} -- \cmd{eighthNoteDottedDouble}\\
427 \quaverDottedDoubleDown & \cmd{quaverDottedDoubleDown} -- \cmd{eighthNoteDottedDoubleDown}\\
428 \semiquaver & \cmd{semiquaver} -- \cmd{sixteenthNote}\\
429 \semiquaverDown & \cmd{semiquaverDown} -- \cmd{sixteenthNoteDown}\\
430 \semiquaverDotted & \cmd{semiquaverDotted} -- \cmd{sixteenthNoteDotted}\\
431 \semiquaverDottedDown & \cmd{semiquaverDottedDown} -- \cmd{sixteenthNoteDottedDown}\\
432 \semiquaverDottedDouble & \cmd{semiquaverDottedDouble} -- \cmd{sixteenthNoteDottedDouble}\\
433 \semiquaverDottedDoubleDown & \cmd{semiquaverDottedDoubleDown} -- \cmd{sixteenthNoteDottedDoubleDown}\\
434 \demisemiquaver & \cmd{demisemiquaver} -- \cmd{thirtysecondNote}\\
435 \demisemiquaverDown & \cmd{demisemiquaverDown} -- \cmd{thirtysecondNoteDown}\\
436 \demisemiquaverDotted & \cmd{demisemiquaverDotted} -- \cmd{thirtysecondNoteDotted}\\
437 \demisemiquaverDottedDown & \cmd{demisemiquaverDottedDown} -- \cmd{thirtysecondNoteDottedDown}\\
438 \demisemiquaverDottedDouble & \cmd{demisemiquaverDottedDouble} -- \cmd{thirtysecondNoteDottedDouble}\\
439 \demisemiquaverDottedDoubleDown & \cmd{demisemiquaverDottedDoubleDown} -- \cmd{thirtysecondNoteDottedDoubleDown}\\
440 \end{reftable}
441
442
443 \section{Beamed notes}
444 \label{sec:beamed_notes}
445
446 We will only provide a few complex symbols like beamed notes for default use.
447 Of course one could have the wish for indefinite variations like notes with variable beam slope.
448 But as long as it isn't possible to make this parametrical%
449 \footnote{See \ghIssue{64}}
450 it is probably a good idea to stick with a few basic commands.
451 For now see \fref{tab:beamedNotes} for the implemented commands.
452
453 Beamed notes are implemented using \textsc{pdf} files.
454
455 \begin{reftable}{Two Beamed Notes}{beamedNotes}
456 \twoBeamedQuavers & \cmd{twoBeamedQuavers}\\
457 \end{reftable}
458
459 \begin{reftable}{Three Beamed Notes}{threeBeamedNotes}
460 \threeBeamedQuavers & \cmd{threeBeamedQuavers} & Three beamed quavers\\
461 \threeBeamedQuaversI & \cmd{threeBeamedQuaversI} & Second dotted\\
462 \threeBeamedQuaversII & \cmd{threeBeamedQuaversII} & First dotted\\
463 \threeBeamedQuaversIII & \cmd{threeBeamedQuaversIII} & Second dotted, first short\\
464 \end{reftable}
465
466
467 \section{Clefs}
468 \label{sec:clefs}
469 Some of the clef glyphs are among the few that are too large by default.
470 You couldn't use a G clef at default size within continuous text without severely \clefG{} damaging line spacing.
471 But if you scale them to a size that doesn't disturb line spacing, they look quite disproportionate, especially when combined with other elements: \mbox{ \clefCInline{} \natural.}
472 To ease the handling of that issue we provide the clefs in two forms, at ordinary size which can be problematic in continuous text, and as an -Inline version which looks somewhat funny but can be used within the line.
473
474 See \fref{tab:clefs} for the available predefined commands.
475
476 \begin{reftable}{Clefs}{clefs}
477 \clefGInline & \cmd{clefG}, \cmd{clefGInline} & clefs.G\\
478 \clefFInline & \cmd{clefF}, \cmd{clefFInline} & clefs.F\\
479 \clefCInline & \cmd{clefC}, \cmd{clefCInline} & clefs.C\\
480 \end{reftable}
481
482 \section{Time Signatures}
483 \label{sec:timesignatures}
484
485 The Emmentaler font provides two “real” glyphs for time signatures, the \lilyTimeC{} and the \lilyTimeCHalf.
486
487 The numerical (single and compound) time signatures can be printed using \cmd{lilyTimeSignature\{numerator\}\{denominator\}}: \lilyTimeSignature{4}{4}.
488 \texttt{numerator} and \texttt{denominator} are treated as \cmd{lilyText}, so you can enter anything this command can use (see \fref{sec:generic_access_commands}).
489 This way you can easily write compound time signatures like \cmd{lilyTimeSignature\{4 + 7\}\{8\}}: \lilyTimeSignature{4 + 7}{8}.
490 But be aware that the command does \emph{not} have a notion of columns, so you have to take care about the horizontal alignment yourself if there are more than one item in both rows, for example by adding explicit space.
491
492 \cmd{lilyTimeSignature} respects any whitespace after the closing bracket so you don't have to supply the pair of curly braces.
493
494 \begin{reftable}{Time Signatures}{timesignatures}
495 \lilyTimeC & \cmd{lilyTimeC} & timesig.C44\\
496 \lilyTimeCHalf & \cmd{lilyTimeCHalf} & timesig.C22\\
497 \lilyTimeSignature{7}{8} & \cmd{lilyTimeSignature\{7\}\{8\}}\\
498 \lilyTimeSignature{3 + 4}{4 + 8} & \cmd{lilyTimeSignature\{3 + 4\}\{4 + 8\}}\\
499 \end{reftable}
500
501 \paragraph*{Known issues and warnings:} \cmd{lilyTimeSignature} also expects the optional argument as the other commands, but it doesn't understand the \texttt{raise} option correctly.
502 The box with the time signature is vertically centered so it should generally be OK, but if you for some reason have to change its vertical position you should manually surround the whole command by a \cmd{raisebox}.
503
504 \section{Numbers}
505 \label{sec:numbers}
506 Numbers can be entered with the already known \cmd{lilyText} command.
507 Access through the glyph names is possible but not necessary.
508 Therefore we don't provide predefined commands for them.
509 With the default scaling of 1.0 they generally fit as lowercase letters like \lilyText{0 1 2 3 4 5 6 7 8 9} \cmd{lilyText\{0 1 2 3 4 5 6 7 8 9\}}.
510 For Uppercase letters you can start trying a scaling of 1.3. A future version of the package may provide convenience commands with default scalings for upper/lowercase letters, fingerings, figured bass numbers, time signature numbers etc.
511
512 A special case are four glyphs that are related to numbers: \lilyText[scale=1.5]{+~-~.~,} (plus, hyphen, fullstop and comma).
513 These are also accessible through \cmd{lilyText} and their respective characters, the example in the previous sentence being written as \cmd{lilyText[scale=1.5]\{+~-~.~,\}}.
514
515 \section{Accidentals}
516 \label{sec:accidentals}
517
518 The \cmd{natural} \natural, the \cmd{flat} \flat{} and the \cmd{sharp} \sharp{} replace the respective commands from standard \LaTeX.
519 Please note that all the accidentals are designed at the same scaling in order to allow a uniform appearance. You will however have to check if they don't affect an even line spacing.
520
521 See \fref{tab:accidentals} for the list of implemented commands.
522
523 \begin{reftable}{Accidentals}{accidentals}
524 \natural & \cmd{natural} & accidentals.natural\\
525 \midrule
526 \sharp & \cmd{sharp} & accidentals.sharp\\
527 \sharpArrowup & \cmd{sharpArrowup} & accidentals.sharp.arrowup\\
528 \sharpArrowdown & \cmd{sharpArrowdown} & accidentals.sharp.arrowdown\\
529 \sharpArrowboth & \cmd{sharpArrowboth} & accidentals.sharp.arrowboth\\
530 \sharpSlashslashStem & \cmd{sharpSlashslashStem} & accidentals.sharp.slashslash.stem\\
531 \sharpSlashslashslashStemstem & \cmd{sharpSlashslashslashStemstem} & accidentals.sharp.slashslashslash.stemstem\\
532 \sharpSlashslashslashStem & \cmd{sharpSlashslashslashStem} & accidentals.sharp.slashslashslash.stem\\
533 \sharpSlashslashStemstemstem & \cmd{sharpSlashslashStemstemstem} & accidentals.sharp.slashslash.stemstemstem\\
534 \doublesharp & \cmd{doublesharp} & accidentals.doublesharp\\
535 \midrule
536 \flat & \cmd{flat} & accidentals.flat\\
537 \flatflat & \cmd{flatflat} & accidentals.flatflat\\
538 \end{reftable}
539
540 \section{Rests}
541 \label{sec:rests}
542
543 See \fref{tab:rests} for the implemented rest commands.
544
545 For more information on how to use \cmd{lilyPrintMoreDots} to produce multiply dotted rests please see \fref{sec:dotted_symbols}.
546
547 \begin{reftable}{Rests}{rests}
548 \wholeNoteRest & \cmd{wholeNoteRest} & Whole Note Rest\\
549 \wholeNoteRestDotted & \cmd{wholeNoteRestDotted} & DottedWhole Note Rest\\
550 \midrule
551 \halfNoteRest & \cmd{halfNoteRest} & Half Note Rest\\
552 \halfNoteRestDotted & \cmd{halfNoteRestDotted} & Dotted Half Note Rest\\
553 \halfNoteRestDotted\lilyPrintMoreDots &
554 \cmd{halfNoteRestDotted}\cmd{lilyPrintMoreDots} &
555 Example of Double Dotted Rest\\
556 \midrule
557 \crotchetRest & \cmd{crotchetRest} & Crotchet Rest\\
558 \crotchetRestDotted & \cmd{crotchetRestDotted} & Dotted Crotchet Rest\\
559 \midrule
560 \quaverRest & \cmd{quaverRest} & Quaver Rest\\
561 \quaverRestDotted & \cmd{quaverRestDotted} & Dotted Quaver Rest\\
562 \midrule
563 \semiquaverRest & \cmd{semiquaverRest} & Semiquaver Rest\\
564 \semiquaverRestDotted & \cmd{semiquaverRestDotted} & Dotted Semiquaver Rest\\
565 \end{reftable}
566
567 \section{Dynamic Text}
568 \label{sec:dynamic_text}
569 As explained earlier the Dynamic Letters can be accessed through \cmd{lilyText} without providing glyph names or numbers as argument.
570 For the available letters see \ref{tab:singleDynLetters}.
571 As a convenience there is a predefined command \cmd{lilyDynamics}, which is just a wrapper around \cmd{lilyText} that sets the \texttt{Scale} argument to a default value of 1.5.
572
573 \begin{reftable}{Single Dynamics Letters}{singleDynLetters}
574 \lilyDynamics{f} & \cmd{lilyDynamics\{f\}} & forte\\
575 \lilyDynamics{p} & \cmd{lilyDynamics\{p\}} & piano\\
576 \lilyDynamics{m} & \cmd{lilyDynamics\{m\}} & mezzo-\\
577 \lilyDynamics{r} & \cmd{lilyDynamics\{r\}} & rin-\\
578 \lilyDynamics{s} & \cmd{lilyDynamics\{s\}} & s-\\
579 \lilyDynamics{z} & \cmd{lilyDynamics\{z\}} & -z\\
580 \end{reftable}
581
582 These Letters can be combined to make complex Dynamics.
583 \lilyglyphs{} doesn't provide predefined commands as they can easily be entered as single strings to \cmd{lilyDynamics}, like \cmd{lilyDynamics\{sffzrmp\}}, resulting in \lilyDynamics{sffzrmp}.
584 In this specific situation you could enter a small horizontal space between the \lilyDynamics{z} and the \lilyDynamics{r} -- but as this combination wouldn't occur in real life we don't need to demonstrate it here.
585 There are a few predefined commands (see \fref{tab:combinedDynLetters}) handling the “kerning” of some special combination of letters.
586 Internally these commands internally use \cmd{lilyDynamics} with its default scaling.
587
588 \begin{reftable}{Combined Dynamics Expressions}{combinedDynLetters}
589 \lilyRF & \cmd{lilyRF} & rinforzando\\
590 \lilyRFZ & \cmd{lilyRFZ} & rinforzando (alternative)\\
591
592 \end{reftable}
593
594
595 \section{Graphical Dynamic Symbols}
596 \label{sec:graphical_dynamic_symbols}
597
598 Graphical dynamic symbols like hairpins are realized by including image files.
599 See \fref{tab:dynamicSigns} for the implemented commands.
600
601 \begin{reftable}{Dynamics Signs}{dynamicSigns}
602 \crescHairpin & \cmd{crescHairpin}\\
603 \decrescHairpin & \cmd{decrescHairpin}\\
604 \end{reftable}
605
606 \section{Articulations}
607 \label{sec:articulations}
608
609 \begin{reftable}{Articulations}{articulations}
610 \lilyAccent & \cmd{lilyAccent}\\
611 \lilyEspressivo & \cmd{lilyEspressivo}\\
612 \lilyStaccato & \cmd{lilyStaccato}\\
613 \lilyThumb & \cmd{lilyThumb} & Thumb pizzicato\\
614 \marcato & \cmd{marcato}\\
615 \marcatoDown & \cmd{marcatoDown}\\
616 \portato & \cmd{portato}\\
617 \portatoDown & \cmd{portatoDown}\\
618 \staccatissimo & \cmd{staccatissimo}\\
619 \tenuto & \cmd{tenuto}\\
620 \end{reftable}
621
622 \section{Scripts}
623 \label{sec:scripts}
624
625 Script implementation has just begun. For the implemented glyphs see \fref{tab:scripts}.
626
627 If you manually enter scripts through \cmd{lilyGlyph} you will notice that they usually seem to print too far to the left, clashing with the preceding text.
628 This is due to the fact that in musical engraving scripts are centered relative to the note they belong to.
629 Therefore you often have to add extra space before the glyph if you access them directly.
630 The predefined commands should of course have this already built in.
631
632 \begin{reftable}{Scripts}{scripts}
633 \fermata & \cmd{fermata} & Fermata\\
634 \end{reftable}
635
636 \section{Accordion Notation}
637 \label{sec:accordion-notation}
638
639 \begin{reftable}{Accordion notation}{accordion-notation}
640 \accordionBayanBass & \cmd{accordionBayanBass} & Bayan bass register\\
641 \accordionDiscant & \cmd{accordionDiscant} & Discant register\\
642 \accordionFreeBass & \cmd{accordionFreeBass} & Free bass register\\
643 \accordionOldEE & \cmd{accordionOldEE} & Unknown accordion notation\\
644 \accordionPull & \cmd{accordionPull} & Directon of bellows\\
645 \accordionPush & \cmd{accordionPush} & Directon of bellows\\
646 \accordionStdBass & \cmd{accordionStdBass} & Standard bass register\\
647 \end{reftable}
648
649 These are the symbols present in the Emmentaler font.
650 More symbols that are created through combination of the discant symbol with one or more accordion dot(s) have yet to be created.
651
652 \section{Fancy (Example) Commands}
653 \label{sec:fancy-examples}
654 This is just an example of a fancy notation generated with the assistance of our scripts (see \fref{sec:generating_commands_image}).
655
656 \begin{reftable}{Fancy (Example) Commands}{fancyexamples}
657 \lilyFancyExample & \cmd{lilyFancyExample} & a fancy command using a LilyPond file\\
658 \end{reftable}
659
660
661 \chapter{Internals}
662 \label{chap:internals}
663
664 \section{Documentation of the generic access commands}
665 \label{sec:internals_generic_access}
666 This section is essential for readers who want to understand how this package works internally, for example if they want to actively participate in its development.
667 It is structured from the perspective of the package's behaviour instead of from a user's POV.
668 If you simply want to add your own predefined commands “the \lilyglyphs{} way” it is a good idea to read this section too, but you may also skip it and directly go to \ref{sec:directory_structure}.
669
670 \medskip
671 In order to make the package's \texttt{.sty} file easier to understand, its content is split into multiple input files which are located in the \dir{/commands} and \dir{/core} subfolders.
672 The most fundamental definitions are in the \dir{core/keyval.inp} and \dir{core/genericAccess.inp} files.
673
674 \subsection{Accessing \emmentaler{} Glyphs}
675 \label{subsec:accessing_emmentaler_glyphs}
676 The command that actually prints glyphs from the Emmentaler font is \cmd{lilyPrint}, defined in \texttt{core/genericAccess.inp}.
677 It isn't intended to be called directly within a document, but only from the predefined commands.
678 It takes two arguments, the first -- optional -- being the comma-separated list of \texttt{<key=value>} pairs, the second the actual content to be printed.
679
680 \begin{lstlisting}[language={[LaTeX]TeX}]
681 \newcommand*{\lilyPrint}[2][]{%
682 \interpretLilyOptions{#1}%
683 \raisebox{{\lilyEffectiveRaise}ex}{%
684 {\fontspec[Scale=\lilyEffectiveScale]
685 {emmentaler-\lilyOpticalSuffix.otf}#2}%
686 }%
687 }
688 \end{lstlisting}
689
690 At first the command \cmd{interpretLilyOptions} is called, where the options of the different levels are evaluated and calculated to their effective values.
691 Then the content of \#2 is printed, within a \cmd{raisebox} and with the currently selected opticals version of the \emmentaler{} font.
692
693 \begin{lstlisting}[language={[LaTeX]TeX}]
694 \newcommand*{\interpretLilyOptions}[1]{%
695 \setkeys{lilyCmdOptions}{scale=1,raise=0}%
696 \setkeys{lilyCmdOptions}{#1}%
697 \pgfmathsetmacro{\lilyEffectiveScale}{%
698 \lilyGlobalOptions@scale *
699 \lilyCmdOptions@scale * \lilyDesignOptions@scale}%
700 \pgfmathsetmacro{\lilyEffectiveRaise}{%
701 \lilyGlobalOptions@raise +
702 \lilyCmdOptions@raise + \lilyDesignOptions@raise}%
703 }
704 \end{lstlisting}
705 \cmd{interpretLilyOptions} is defined in \dir{core/keyval.inp}.\\
706 The \texttt{<key=value>} mechanism is achieved using the \texttt{keyval} package as the most basic solution available.
707 {\color{red} If this can be implemented in a more elegant, extensible and/or powerful way using other packages, e.\,g.\ \package{pgfkeys}, we'd appreciate any input.}
708 It uses three families of keys, corresponding to the three levels of options:
709 \texttt{lilyGlobalOptions}, \texttt{lilyDesignOptions} and \texttt{lilyCmdOptions}.
710
711 In a first step the keys for the actual command options are initialized to a neutral state.
712 This is necessary because otherwise options not present in the command invocation would be in an uninitialized or unknown state.
713 After this the options provided by the command invocation (i.\,e. the ones in the end user's document) are applied.
714 Finally the effective values of the options are calculated from the global, the design and the command invocation options.
715 The scaling values are multiplied, the raise values added.
716 While the command options have just been determined, the global options are valid globally (and can be changed globally) and the design options have been set by the command that actually called \cmd{lilyPrint}.
717 This is the reason why \cmd{lilyPrint} should never be invoked directly -- the design options would be in the unknown state of the previous invocation of\cmd{lilyPrint}.
718
719 \medskip
720 At the next higher level there are the three generic access functions \cmd{lilyGlyph}, \cmd{lilyGlyphByNumber} and \cmd{lilyText}, defined in \dir{core/genericAccess.inp}.
721 They are very similar and differ only in the way they determine the actual content to be printed.
722 As stated in the end user part of this documentation they expect two arguments, the optional \texttt{<key=value>} pair list and the contents.
723 As a first step the commands initialize the design options to a neutral state, because the “design” of the generic glyphs has to be neutral by design.
724 In the second step they invoke \cmd{lilyPrint}, passing the optional argument along and determine the printed content individually:
725 \cmd{lilyGlyph} calls the helper function \cmd{lilyGetGlyph}, \cmd{lilyGlyphByNumber} calls \cmd{lilyGetGlyphByNumber}, while \cmd{lilyText} just passes its contents argument unchanged to \cmd{lilyPrint}.
726
727 These helper functions are important because most predefined commands call one of them to select glyphs from the Emmentaler fonts.\\
728 \cmd{lilyGetGlyph} takes the glyph name as found in the LilyPond documentation.\\
729 \cmd{lilyGetGlyphByNumber} takes the Unicode character index of the intended glyph.
730 But be aware that the Unicode index may change at any time with new versions of the Emmentaler font, so it usually isn't a good idea to access glyphs through their index.
731 There may be some uses for numerical access, however, e.\,g.\ to iterate over a range of glyphs.
732
733 \subsection{Printing image files}
734 \label{subsec:printing_image_files}
735 \cmd{lilyPrintImage}, defined in \dir{core/genericAccess.inp}, is the command that prints glyphs from a supplied image file.
736 It actually is quite similar to \cmd{lilyPrint}, with only the extra consideration of scaling the image to the text font size.
737
738 \begin{lstlisting}[language={[LaTeX]TeX}]
739 \newcommand*{\lilyPrintImage}[2][]{%
740 % interpret optional argument
741 \interpretLilyOptions{#1}%
742 % determine scaling factor to accomodate the current font size
743 % (as images don't scale automatically with the font)
744 \lilyScaleImage%
745 % Print the image in a raisebox
746 \raisebox{{\lilyEffectiveRaise}ex}{%
747 \includegraphics[scale=\lilyImageEffectiveScale]{#2}%
748 }%
749 }
750 \end{lstlisting}
751 First the command calls \cmd{interpretLilyOptions}, which is the same as with \cmd{lilyPrint}.
752 But as an additional step \cmd{lilyScaleImage} is called, and finally it uses \cmd{lilyImageEffectiveScale} as the scaling factor instead of \cmd{lilyEffectiveScale}.
753 I won't explain this in detail, but in effect it multiplies the \cmd{lilyEffectiveScale} calculated before with the ratio of the current font size to the \cmd{normalsize} size.
754
755 What is finally given as the content to be printed is the basename of an image file.
756 This can be any file format understood by the used \TeX engine but we highly recommend using \textsc{pdf} files for sake of printing quality.
757
758 As with printing Emmentaler glyphs there is no handling of design time options here, and for that reason you should never call this command directly from a document.
759 Please use \cmd{lilyImage} instead which does the same as \cmd{lilyPrintImage} but additionally defaults the design time options to neutral values.
760
761 \section{The Package's Directory Structure}
762 \label{sec:directory_structure}
763 This section describes the directory structure as found in the development repository on GitHub%
764 \footnote{\url{https://github.com/openlilylib/lilyglyphs}}.
765 If you have obtained \lilyglyphs{} from there and want to write new commands on a regular basis, especially if you want to contribute your results back to the package, you will need to have a fair understanding of it.
766 The same is true if you want to use the Python scripts as described in \fref{chap:python_scripts}.
767 If you intend to contribute or just start doing so it is highly recommended to go that way.
768
769 If you have downloaded \lilyglyphs{} from \textsc{ctan} there will be significant differences in the directory structure which are mentioned below, so you should read the section anyway.
770
771 If you are using \lilyglyphs{} from a \TeX{} distribution you can't really consider the contents of this section because the files will be scattered over a number of system and distribution specific places which are out of our control.
772 There is a way around this problem which is described in \fref{chap:python_scripts}, but we still recommend using the GitHub version for serious extending work.
773 Getting an idea about the package content is a good idea nevertheless.
774
775 \paragraph*{The root directory}
776 contains the usual number of files such as \textsc{readme}, installation hints and licensing information as well as the main package file \texttt{lilyglyphs.sty}.
777
778 \paragraph*{\dir{/core}
779 \footnote{For this section a leading “/” in directory names refer to the package root directory.}}
780 consists of include files for \texttt{lilyglyphs.sty} that contain the fundamental program logic of the package.
781
782 \paragraph*{The \dir{/commands} directory}
783 contains files defining the predefined commands available to the end user of \lilyglyphs.
784 If you are going to write new commands you will include them in these files or add new files here.
785
786 \paragraph*{\dir{/documentation}}
787 contains this manual and an example document, boxth as \texttt{.tex} and \textsc{pdf} files as well as an \textsc{html} document listing all glyphs of the \emmentaler{} font.
788
789 The subdirectory \dir{resources} contains included files for the \textsc{html} document as well as helper packages for the \LaTeX{} documents.
790 The subdirectory \dir{lilyglyphs\_logo} contains the logo of the package in \textsc{pdf} and \textsc{png} format along with its \texttt{.tex} source.
791
792 \paragraph*{\dir{/fonts}}
793 contains the \emmentaler{} font files, copied from LilyPond 2.16.2 as the latest stable version.
794 This is the directory you will have copied or linked to during a manual installation of the package.
795
796 \paragraph*{\dir{/glyphimages}}
797 contains all material for the image based commands: original input files, generated LilyPond source files and the resulting \textsc{pdf} images.
798 If you are going to create new commands using LilyPond generated images you will work in this directory.
799 This is explained in more detail in \fref{sec:generating_commands_image}.
800
801 \paragraph*{\dir{/license}}
802 contains the full \textsc{lppl} license for the package and the \textsc{ofl} license for the included Emmentaler fonts.
803
804 \paragraph*{\dir{/scripts}}
805 contains Python scripts that simplify the generation and management of new commands.
806 In the \textsc{ctan} archive the contents of this directory is distributed over two directories, \dir{/bin} and \dir{/lib}.
807
808 \paragraph*{\dir{source}}
809 contains the \textsc{metafont} sources for the Emmentaler fonts.
810 They are checked out from the LilyPond development repository at exactly the same state as the binary font files used.
811
812 \subsection{“Private” Directory Structure}
813 \label{subsec:private_directory_structure}
814 If you have obtained \lilyglyphs{} any other way than through its Git repository you probably can't or don't want to modify the package files directly.
815 Instead we recommend you set up a private “shadow” search path where you can safely place your own additions.
816 Apart from potential issues with write access to files in the \TeX{} installation this procedure will avoid your changes being overwritten by package updates.
817
818 We have provided a skeleton directory structure in the file \dir{lilyglyphs\_private.zip} which is located in the \dir{documentation/} directory of the package%
819 \footnote{Please consult the documentation of your \TeX{} distribution where to find these.
820 A good chance would be to run \texttt{kpsewhich lilyglyphs.sty} which should find the location of the main package file}.
821 Extract this archive somehwere in your \LaTeX{} search path, e.\,g. to \dir{TEXMFHOME/tex/latex/lilyglyphs\_private}.
822
823 In the first level of this directory you'll find two nearly empty stubs: \texttt{lilyglyphsPrivate.sty} and \texttt{lilyglyphsPrivate.tex}.
824 The first file is a \LaTeX{} package where you can store and organize your own predefined commands%
825 \footnote{Of course you will have to “use” this package to make the commands available to other documents},
826 the second a file where you can (and are strongly advised to) document your additions.
827 If you make use of these files in a structured way (following the hints in the comments in these files) it will be very easy for us to incorporate any additions you send to us by email (if you don't want to go the Git way).
828
829 The rest is a copy of the directory structure below \dir{/glyphimages}.
830 There you can store sources and results of commands generated with LilyPond.
831 Please adhere to the model of the directories in the package for this.
832 And please also see the chapter \fref{chap:contributing} on contributing.
833
834 \section{How to write predefined commands}
835 \label{sec:howto_predefined_commands}
836 Writing your own predefined commands is actually quite straightforward -- and identical if you want to write a command for your document or for inclusion in the package.
837 So if you find yourself creating predefined commands that you think are useful for general use, don't hesitate to submit them to us.
838
839 \subsubsection{Commands that print single glyphs}
840 \label{subsubsec:commands_single-glyphs}
841 Let's review an example of a predefined command, the \cmd{doublesharp}.
842
843 \begin{lstlisting}[language={[LaTeX]TeX}]
844 % "accidentals.doublesharp"
845 \newcommand*{\doublesharp}[1][]{%
846 \setkeys{lilyDesignOptions}{scale=1.5,raise=0.35}%
847 \lilyPrint[#1]{\lilyGetGlyph{accidentals.doublesharp}}%
848 }
849 \end{lstlisting}
850
851 We use the starred version of \cmd{newcommand}, because a glyph command naturally doesn't span paragraphs.
852 We declare to accept one optional argument, which defaults to empty.
853 This argument can take the list of \texttt{<key=value>} options.
854 When writing the commands, please take care not to omit the \texttt{\%} characters at the line endings, as they prevent unwanted whitespace to be introduced in the output.
855
856 In the second line we define the design options for the command.
857 In the example the designer has decided that a doublesharp glyph should be scaled to 1.5 and raised 0.35\,ex compared to its default appearance.
858
859 The third line calls the internal \cmd{lilyPrint} command.
860 It passes the optional argument, with which the end user can override (i.\,e.\ modify) the designed values.
861 As the \doublesharp{} is a glyph that has to be selected by its glyph name, we call \cmd{lilyGetGlyph}, supplying the glyph name found in the documentation.
862 The result of this command is passed as the \texttt{\#2} to \cmd{lilyPrint}.
863
864 To summarize: Writing a predefined command for printing an Emmentaler glyph involves just two steps, setting the design time options and calling \cmd{lilyPrint} with the appropriate \#2 argument.
865
866 \medskip
867 If you know the Unicode number of the desired glyph you can call \cmd{lilyGetGlyphByNumber} instead of \cmd{lilyGetGlyph}, but you can't be sure this number will stay the same forever.
868
869 \medskip
870 Creating commands using image files is practically the same and even simpler.
871 If you look at the definition of a \cmd{crotchet},
872 \begin{lstlisting}[language={[LaTeX]TeX}]
873 \newcommand*{\crotchet}[1][]{%
874 \setkeys{lilyDesignOptions}{scale=0.9,raise=-0.2}%
875 \lilyPrintImage[#1]{crotchet}%
876 }
877 \end{lstlisting}
878 you will notice that the only differences are that the actual printing is done with \cmd{lilyPrintImage} instead of \cmd{lilyPrint} and that therefore the basename of the image file can be passed directly.
879 In \fref{sec:generating_commands_image} you will see a tool that allows to create numerous image commands quite easily.
880
881 \bigskip
882 As a last example we will look at the definition of \cmd{lilyRFZ} \lilyRFZ.
883
884 \begin{lstlisting}[language={[LaTeX]TeX}]
885 \newcommand{\lilyRFZ}[1][]{%
886 \mbox{%
887 \lilyDynamics[#1]{r\hspace{0.035ex}fz}%
888 }%
889 }
890 \end{lstlisting}
891 You may notice that we use \cmd{lilyDynamics} here, one of the Generic Access Commands (see \fref{sec:generic_access_commands}) instead of the low-level printing command.
892 We can do this and also use the other ones: \cmd{lilyText}, \cmd{lilyGlyph}, \cmd{lilyGlyphByNumber} or \cmd{lilyImage}.
893 This is actually simpler because we don't have to set the design time options -- but that's also the main disadvantage: this way we \emph{can't} set them and have to use the given default parameters.
894 As mentioned in \fref{sec:dynamic_text}, \cmd{lilyDynamics} is just a wrapper around \cmd{lilyText}, setting the \texttt{scale} factor to 1.5.
895 While the other generic commands only print single glyphs, \cmd{lilyText} can print ‘plain text’, so usually there is no need to write predefined commands only to combine letters to a single command.
896 In some cases this may however be necessary.
897 In the given example of \cmd{lilyRFZ} we need to apply a little bit of extra space between the \lilyDynamics{r} and the \lilyDynamics{f}.
898 We see that we can insert a \cmd{hspace} command between the letters without any problems.
899 But as it turns out \LaTeX{} may now decide to insert a line break at its discretion, so we have to additionally enclose this call to \cmd{lilyDynamics} in a \cmd{mbox}.
900 The command just passes the optional argument to \cmd{lilyDynamics}, so you can use these arguments in your document as usual.
901
902 This example is meant to encourage you to experiment with the definition of new commands.
903 All you have to deal with is setting the design time options and the optional argument, and chosing the appropriate input method for the second argument.
904 Apart from this you can design commands as you aanre used to.
905
906 \bigskip
907 Once you have defined your new command you of course have to make it av ailable to \LaTeX.
908 If it is a “local” command that you just use for a specific document you can simply put it in the document's preamble or a dedicated helper \texttt{.sty} file.
909 If it is an image driven command you will have created the image file before and will have to place this in a location where \LaTeX{} can find it.
910 But the best place you can permanently store your new commands is the \package{lilyglyphsPrivate} package described in \fref{subsec:private_directory_structure}.
911 Please don't forget to document your command in \texttt{lilyglyphsPrivate.tex}.
912 For more information on how to contribute your new commands to the package see \fref{chap:contributing}.
913
914 \subsubsection{Create Dotted Symbols}
915 \label{subsubsec:dotted_symbols}
916
917 It is not exactly trivial to create dotted symbols as predefined commands.
918 Of course you can always use \cmd{lilyDot} to print LilyPond's dot glyph, but if you want to create commands that combine a glyph and one ore more dots you encounter two difficulties:
919 You can't apply the optional arguments independently on the two items, and there may be issues with the scaling and the gap between the two glyphs.
920
921 There is some infrastructure in \lilyglyphs{} (defined in the file dotted.inp) to faciliate dealing with dotted symbols, but this implementation isn't completely satisfactory so far.
922 Great care has been taken to hide as much complexity as possible in the mentioned file, in order to make the definition of actual commands as clean and concise as possible.
923
924 Let's analyze the implementation of a dotted half note rest:
925 \begin{lstlisting}[language={[LaTeX]TeX}]
926 % Dotted half note rest
927 \newcommand*{\halfNoteRestDotted}[1][]{%
928 % define the optional arguments for the dot
929 \setkeys{lilyDesignOptions}{scale=0.8,raise=0.2}%
930 % Calculate effective scale/raise and the hspace for the dot
931 \lilySetDotOptions[#1]{0.05}{0.5}{0}%
932 % Print the rest and then the dot
933 \halfNoteRest[#1]\lilyDotSpace\lilyPrintDot
934 }
935 \end{lstlisting}
936
937 The command takes the usual optional argument that can contain \texttt{<key=value>} pairs.
938 This applies to the dotted symbol as a whole.
939 Please note that in the last line the predefined command \cmd{halfNoteRest[\#1]} is called and passed the optional argument.
940 You can only use this technique of creating dotted symbols on top of correctly implemented predefined commands.
941
942 The first thing you have to do is to define the DesignTimeOptions for the dot. They are relative to the original design of \cmd{lilyDot}, and you have to adjust them so the dot suits the main glyph in its size and vertical position (you can ignore the horizontal spacing for now):
943 \begin{lstlisting}[language={[LaTeX]TeX}]
944 % define the optional arguments for the dot
945 \setkeys{lilyDesignOptions}{scale=0.8,raise=0.2}%
946 \end{lstlisting}
947 You should always set these options because otherwise you might get strange results or error messages.
948
949 The next step is to call a quite complex command \cmd{lilySetDotOptions} that sets several options for the dot:
950 \begin{lstlisting}[language={[LaTeX]TeX}]
951 % Calculate effective scale/raise and the hspace for the dot
952 \lilySetDotOptions[#1]{0}{0.5}{0.4}%
953 \end{lstlisting}
954 This command takes one optional and three mandatory arguments.
955 The optional argument is just the one that is written in the \LaTeX{} document and that is passed into the function. The remaining three arguments control the horizontal spacing between the main glyph and the dot.
956 As we now have two individual elements we have to control the gap between them explicitely as it doesn't scale relative to the \texttt{scale} argument by itself.
957 The relation between the \texttt{scale} factor and the horizontal gap can be understood as a curve (mathematically spoken: a 2nd order function).
958
959 The first (mandatory) argument sets the intensity of the curve.
960 A value of 0 will result in a linear relation (no curve at all), that is when doubling \texttt{scale} the gap will be exactly twice as wide.
961 Positive values will result in larger gaps for larger \textbf{scale}s.
962 As this is a quadratic function you will want to start with very small values or 0.
963
964 The second argument sets the general (linear) steepness of the curve.
965 A value of 1 means that by increasing \texttt{scale} by 1 the gap will be wider by 1\emph{ex}.
966 0.5 seems a good starting point for this argument.
967
968 The last argument is an offset in \emph{ex} for the whole curve which is independent from the scaling.
969 You can use it to accomodate specifically wide or narrow glyphs.
970
971 \cmd{lilySetDotOptions} takes all these informations, calculates some settings for the dot and stores them in internal variables that can be used by subsequent commands.
972 Please understand that they may be partially or totally overwritten by the next use of \emph{any} predefined command.
973 So you have to call this command immediately before actually printing the dot, otherwise it may or may not provide satisfying results.
974
975 The final line actually calls three commands:\\
976 \cmd{halfNoteRest[\#1]} prints the already defined main glyph.
977 \cmd{lilyDotSpace} prints a horizontal space that is determined by the previous call to \cmd{lilySetDotOptions}, and \cmd{lilyPrintDot} finally prints the dot with the settings just defined.
978
979 \begin{lstlisting}[language={[LaTeX]TeX}]
980 % Print the rest and then the dot
981 \halfNoteRest*[#1]\lilyDotSpace\lilyPrintDot
982 \end{lstlisting}
983
984 This was an explanation from the perspective of designing new predefined commands.
985 If you want to know how this is implemented internally, please look at the generously commented file \texttt{core/dotted.inp}.
986
987 \paragraph*{Known issues and warning:}
988 One issue that hasn't been addressed yet is the vertical placement of the dot when scaled.
989 The dot is positioned relatively to the baseline of the text, and the main glyph may have a different center point.
990 So when scaling the main glyph may seem to behave differently from the dot.\\~\\
991 If you want to create a dotted version of a glyph that is printed from an image file it will generally be easier and more reliable to create a command using a new image file.
992
993
994 \subsubsection{Create Multiply Dotted Symbols}
995 \label{subsubsec:multiply_dotted_symbols}
996
997 There is no need to define additional versions of glyphs with more than one dot.
998 For this purpose we have implemented the command \cmd{lilyPrintMoreDots}.
999 This prints a dot with the same characteristics as the preceding one from a dotted command (but remember that there shouldn't be any calls to other predefined commands in betwen).
1000 The horizontal gap between the dots scales linearly with a default of 0.25\emph{ex} per unit of \texttt{scale}.
1001 But if you pass an number as an optional argument this is interpreted as a different gap in \emph{ex}.
1002
1003 \chapter{Generating Commands with Python}
1004 \label{chap:python_scripts}
1005 As we just have seen in \fref{subsubsec:commands_single-glyphs} it is quite easy to create predefined commands.
1006 At least with regard to the Emmentaler glyphs it is really straightforward to simply create a command based on existing models and the documentation.
1007 Nothing prevents you from simply adding new commands to your document or helper package.
1008 Image driven commands are slightly more complex.
1009 The \LaTeX{} part is equally straightforward, but you also have to provide the \textsc{pdf} image by creating a score with LilyPond and produce the right output file, which involves a few steps.
1010
1011 Therefore we have developed a set of tools and templates to streamline the process of creating new commands even further.
1012 These tools are Python 2 scripts, so in order to use them you will need a working Python installation.
1013 They are located in the \dir{/scripts} (GitHub version) or \dir{/bin} (\textsc{ctan} version) directory of the package.
1014 If you want to create image driven commands you will of course have to have LilyPond installed too.
1015 In both cases the process basically consists of writing a definitions file (something like a template), calling a script and then putting the results to a useful place.
1016
1017 To summarize your options for extending the symbols coverage:
1018 \begin{itemize*}
1019 \item If you only have the plain \lilyglyphs{} package you can create new commands using Emmentaler glyphs.\\
1020 You can also create image driven commands using any preexisting images (e.\,g. scans or output from any software).
1021 \item If you also have LilyPond installed you can additionally create image driven commands that match the ones already present in the package.
1022 \item If you have Python working you can make use of our tools to generate Emmentaler and LilyPond commands (LilyPond presence provided).
1023 \end{itemize*}
1024
1025 The Python scripts expect to work inside either the package directory itself or in the private “shadow” directory described in \fref{subsec:private_directory_structure}.
1026 They perform the check based on the “lilygpyhs” part of the directory name, so for the scripts to work correctly it is crucial that you didn't change their names during a manual installation.
1027
1028 \medskip
1029 All Python scripts handle \texttt{-h/--help} and \texttt{-v/--version} arguments, printing a short usage help or the current \lilyglyphs{} version.
1030
1031 \paragraph{Licensing Note}
1032 All files generated by the Python scripts contain the \lilyglyphs{} license preamble stating them to be licensed with the GPL.
1033 But this is only relevant if you contribute them back to the package itself.
1034 Initially these generated files are the result of \emph{your} work and you can do with them whatever you want.
1035 So if you use the Python scripts to create commands for your own needs you can simply remove the license preamble from them.
1036
1037 \section{Generating Commands for \emmentaler{} Glyphs}
1038 \label{sec:generating_commands_emmentaler}
1039
1040 Generating commands that print Emmentaler glyphs with our tools is a straightforward process.
1041 The steps involved are few:
1042 \begin{inparaenum}[1)]
1043 \item create an input definitions file,
1044 \item run a Python script on it,
1045 \item fine-tune the commands in the generated \LaTeX{} file, and
1046 \item move the resulting code to an appropriate place.
1047 \end{inparaenum}
1048 We'll go through these steps in the following subsections.
1049 Be assured that although these instructions span several pages the actual process of creating new commands is very fast once you have got used to it.
1050
1051 In addition to the following documentation you can also refer to a more casual post on the \emph{Scores of Beauty} blog%
1052 \footnote{\url{http://lilypondblog.org/2013/09/extending-lilyglyphs-part-1/}}
1053 which shows an example of creating a complete group of glyphs.
1054
1055 \subsection{Preparing the Input File}
1056 \label{subsec:GGC_preparing_input_file}
1057
1058 The first step is to create a text file with entries for any number of new commands to be created.
1059 You can save it to any convenient location, and it is up to you to keep this file for reference or drop it after use.
1060
1061 The input file consists of one ore more command definitions.
1062 Each command definition is composed of a set of lines with \texttt{key=value} pairs (please note that you shouldn't use whitespace around the equals sign).
1063 The end of the definition is indicated by an empty line, therefore it is important that your file ends with an empty line, otherwise the last entry will be discarded.
1064 Lines beginning with Python and \LaTeX{} style comments (\% and \#) are ignored, so you can use them to document your file if you want.
1065
1066
1067 \medskip
1068 A command entry consists of several mandatory or optional lines.
1069 The order doesn't matter, but it is considered good practice to stick to one style.
1070 The following items are possible/necessary:
1071 \begin{itemize}
1072 \item \textsf{\textbf{cmd} (mandatory)}: Specifies the command name.
1073 You have to make sure that it is a valid \LaTeX{} name and that it isn't in use already.
1074 \lilyglyphs{} prefixes commands that seem prone to ambiguity with “lily” followed by an uppercase letter: instead of \cmd{dynamics} we used \cmd{lilyDynamics}.
1075 You are encouraged to adhere to that convention.
1076 \item \textsf{\textbf{comment} (optional)}: You can pass a single line comment that will be used before the command definition.
1077 (If you want to have a multiline comment instead you can insert line breaks with \cmd{n}.)
1078 \item \textsf{\textbf{element} (mandatory)}: The actual element to be passed to the internal printing functions.
1079 The possible type of its value depends on the \texttt{type} of the command, as described below.
1080 \item \textsf{\textbf{type} (mandatory, but defaulted)}: The type determines the internal printing command to be used with the command.
1081 Please refer to \fref{sec:generic_access_commands} for more information.
1082 The option is mandatory but defaults to “glyphname”, so you can skip it for the most common case that the glyph is called by name.
1083
1084 \begin{itemize}
1085 \item \textbf{\texttt{glyphname:}} The glyph is selected by its glyphname, which is what you have to specify as “element” (e.\,g. “accidentals.sharp“ (without the quotes)).
1086 You can look up the glyph names in LilyPond's documentation or in the glyph list contained in the package.
1087
1088 \item \textbf{\texttt{number:}} The Unicode number is used to determine the glyph.
1089
1090 \item \textbf{\texttt{text:}} The content is passed as plain text (works only for Dynamic letters, numbers and \texttt{+ - , .})
1091
1092 \item \textbf{\texttt{dynamics:}} The content is also passed as plain text, but the \cmd{lilyDynamics} function is used to print it (applying the suitable default scaling).
1093
1094 \item \textbf{\texttt{image:}} The command prints an image file.\\
1095 If you already have an image file created with LilyPond or obtained from any other source than LilyPond (e.\,g. a scanned image from a printed edition or an autograph) this is the recommended way to create image driven commands.
1096 []You can even use this to create non-musical commands that print images and profit from \lilyglyphs' infrastructure (like the automatic scaling with text size).]
1097 For this purpose you can use .pdf files (preferred) or any image files your \LaTeX{} installation can process.
1098
1099 The “element” for an image driven command is the plain file name without extension or path.
1100 The file has to be stored in a location that is visible to \LaTeX, and you are responsible for avoiding name clashes.
1101 If you have set up a private directory structure as recommended in \fref{subsec:private_directory_structure}, its \dir{custom\_images} subdirectory is a good choice.
1102 \end{itemize}
1103 \item \textsf{\textbf{scale / raise} (optional):}
1104 If a line contains one of the keys \verb|scale=| or \verb|raise=| the value after the equals sign is used for the design time options of the new command.
1105 These values are also kept for subsequent command entries until the file is finished or the script finds a new entry -- which would replace its value.
1106 The idea behind this option is to simplify the (likely) process of defining a set of related commands within an input file with its high probability of sharing default values.
1107 \end{itemize}
1108
1109 \noindent Here you can see two examples of command entries:
1110 \begin{lstlisting}
1111 cmd=fermataDown
1112 element=scripts.dfermata
1113 comment=downward fermata
1114 # type glyphname is implicitely used
1115
1116 cmd=rinforzando
1117 type=dynamics
1118 element=rfz
1119 comment=Rinforzando (kerned)
1120 \end{lstlisting}
1121
1122 In the following subsection you can see what these commands are processed to.
1123
1124 \subsection{Generating the \LaTeX{} code}
1125 \label{subsec:GGC_processing}
1126
1127 The Python script that processes your input file is \texttt{lily-glyph-commands.py}.
1128 It expects the (absolute or relative) filename of the input file as its first and single parameter (apart from the mentioned standard arguments).
1129 The program parses the input file and creates a new file with the same basename but a \texttt{.tex} extension, in the same folder where the input file is.
1130 Please note that the script in its current implementation will silently overwrite any earlier file with that name.
1131 So if you need to keep such a generated file for reference you'll have to copy/move it to a safe location.
1132
1133 The resulting file is a working \LaTeX{} document that uses the \lilyglyphs{} package.
1134 It contains \LaTeX{} \cmd{newcommand} definitions for each command definition in the input file.
1135 The visible part of the document contains a reference table (as used throughout this manual) with all generated commands and additionally example text for each generated command.
1136
1137 The examples above would be processed to the following two \LaTeX{} commands:
1138 \begin{lstlisting}[language={[LaTeX]TeX}]
1139 % downward fermata
1140 \newcommand*{\fermataDown}[1][0]{%
1141 \setkeys{lilyDesignOptions}{scale=1,raise=0}%
1142 \lilyPrint[#1]{\lilyGetGlyphs{scripts.dfermata}}%
1143 }
1144
1145 % Rinforzando (kerned)
1146 \newcommand*{\rinforzando}[1][]{%
1147 \setkeys{lilyDesignOptions}{scale=1,raise=0}%
1148 \lilyDynamics{rfz}}%
1149 }
1150 \end{lstlisting}
1151
1152 \subsection{Fine-tuning the \LaTeX{} Commands}
1153 \label{subsec:GGC_fine-tuning}
1154 So what are we going to do with the contents of this file?
1155 Well, it depends on how/where you want to eventually use it, but the first step will be to fine-tune the commands.
1156
1157 The first thing the generated example text does is showing that the command actually works.
1158 But its more important purpose is to print the new glyph in different contexts: in continuous text, before punctuations, at the beginning of a line etc.
1159 You should use these blocks of example text to adjust the arguments in the \verb|\setkeys{lilyDesignOptions}| clause.
1160 The script generates default values for the design time values of the optional argument, and it would of course be purely random if they would be perfect right away.
1161 Even if you supplied \texttt{scale} and/or \texttt{raise} values in the input file you're likely to have to tune the results.
1162 You should specifically keep an eye on spacing issues: Does the glyph affect line spacing, is the “kerning” of the glyph correct?
1163 On the other hand you should probably try to keep corresponding glyphs at an equal scaling.
1164 Besides tweaking the optional argument values you can add space before or after the glyph -- keep in mind that you may as well use negative \cmd{hspace}.
1165 And of course you can adjust the commands any way you like, but if you are going to make experimental commands you will probably rather write them manually as described in \fref{sec:howto_predefined_commands}.
1166
1167 \subsection{Finishing Off (and Contributing)}
1168 \label{subsec:GGC_finishing_off}
1169 If you are satisfied with the new command(s) you will have to move them to a useful place.
1170 If you are just creating the commands for your personal or one-time use you can either copy the command definitions to the preamble of your current \LaTeX{} document or to any style file you might maintain.
1171 A good choice would be the \package{lilyglyphsPrivate.sty} as described in \fref{subsec:private_directory_structure}.
1172 In this case it is recommended to supply documentation in the \texttt{lilyglyphsPrivate.tex} file on the same directory for your own reference.
1173
1174 But of course we would be happy if you decided to contribute your commands as additions to the package -- we consider increasing coverage of glyphs through user contribution a natural way of evolution for \lilyglyphs.
1175 Be prepared for compilation errors when your contribution returns to you as package updates.
1176 Once this happens your own command definitions will try to re-define the commands, and \LaTeX{} will throw out error messages.
1177 In that case you will have to remove your definitions from your private packages (wherever you have put them) -- they are obsolete now anyway.
1178
1179 Probably the simplest way to contribute is sending the processed \texttt{.tex} file as an email to the package maintainer (currently \href{mailto:[email protected]}{\nolinkurl{[email protected]}}).
1180 He would then incorporate them into the package.
1181 \emph{Please} keep the generated reference table in the file as we will need it to update the command reference in the manual.
1182 And please also add some information about your additions in the file: where it belongs, where it should be documented etc.
1183 If your commands need any special considerations (e.\,g. specific arguments) please also add some material suitable for the manual.
1184
1185 If you are working on a fork of the GitHub repository (as is recommended for potential contributors) you can incoporate the new commands directly and send us a pull request (preferably as soon as possible to minimize risk of conflicts with others' changes).
1186 This works by completing the following steps:
1187 \begin{itemize}
1188 \item Create a new branch with a suitable name.
1189 \item Move/copy the command definitions (with all comments) to appropriate .inp files in the package's \dir{/commands} subdirectory.
1190 If you find you should create a new .inp file because your commands belong to a new category please take the existing files as a model and add an appropriate \cmd{input} statement to \texttt{lilyglyphs.sty}.
1191 For any newly created files copy\,\&\,paste the usual copyright comment at the beginning from another file.
1192 \item \emph{Please} add documentation for your commands in the manual (\texttt{/documentation/lilyglyphs.tex}).
1193 Find the appropriate subsection in the “Predefined commands” section (or create a new one) and add information to it.
1194 At least we need the entries in the reference table, but if there is anything special to note about the commands please explain this too.
1195 If you add to an existing subsection you may copy the rows from the table in the file generated by the script, otherwise you should copy the whole table (but update the caption and label fields appropriately).
1196 \item If you are happy with the result you can push to your fork of the repository and send a pull request through the GitHub web site.
1197 \end{itemize}
1198
1199 If you have any questions on these procedures it is certainly a good idea to get in contact with us \emph{before} starting any substantial work.
1200
1201
1202 \section{Generating Commands with Glyph Images}
1203 \label{sec:generating_commands_image}
1204 Creating commands with images generated by LilyPond is a significantly more complex task than simply inserting Emmentaler glyphs, and therefore the Python script \texttt{lily-image-commands.py} is a more complex one.
1205 But from the end user's perspective the process is surprisingly similar:
1206 \begin{inparaenum}[1)]
1207 \item create an input definitions file,
1208 \item run a Python script on it,
1209 \item fine-tune the commands in the generated \LaTeX{} file, and
1210 \item move the resulting code to an appropriate place.
1211 \end{inparaenum}
1212 The main differences to consider are the different structure of the input files and some considerations about file locations.
1213
1214 But let us start with looking at the form of the input files.
1215
1216
1217 \subsection{Preparing the Input Files}
1218 \label{subsec:BGI_preparing_input}
1219 \texttt{lily-image-commands.py} doesn't expect regular LilyPond source files as its input, but rather a file with one or multiple ‘snippets’ in it, similar to those for \texttt{lily-glyph-commands.py}.
1220 We will later see that it is possible and makes sense to provide compilable Lilypond files, though.
1221
1222 Depending on the type of your \lilyglyphs{} installation you may work either in the \dir{/glyphimages} directory of the package or in the \dir{lilyglyphs\_private} directory you set up according to \fref{subsec:private_directory_structure}.
1223 So in the context of the following instructions \dir{/} or \texttt{ROOT} refer to the appropriate one of these two directories.
1224
1225 Input definition files are to be stored in the \dir{/definitions} subdirectory .
1226 Other than the files used for the generation of Emmentaler commands these files are considered persistent and should remain in place to be able to recreate the images at a later time.
1227 Therefore it is recommended to define related commands in one file and give it an appropriate name.
1228 A filename extension isn't mandatory but you may use \texttt{.ly} as you will see later.
1229 The file name will also be reflected in the resulting file with the generated \LaTeX{} commands.
1230
1231 As with the Emmentaler commands the definitions file can contain any number of command entries, although they are structured differently.
1232
1233 A command entry starts with the special key \verb|%%lilyglyphs| on a single line.
1234
1235 After this there may be any number of lines starting with a single \% as a LilyPond comment.
1236 These comment lines are used for commenting the command in the resulting \LaTeX{} file.
1237
1238 If a line consists of the special key \verb|%%protected| the script skips the entire command.
1239 You should use this key whenever you consider a command finished because it will prevent LilyPond from recompiling that command%
1240 \footnote{This is especially important when working inside a Git repository.
1241 With any new or different LilyPond installation the generated \texttt{pdf} files are likely to be different and would therefore be considered as ‘modified’ by Git}
1242 and the script from re-generating the \LaTeX{} command.
1243
1244 If a line contains one of the keys \verb|scale=| or \verb|raise=| the value after the equals sign is used for the design time options of the new command.
1245 These values are also kept for subsequent command entries until the file is finished or the script finds a new entry -- which would replace its value.
1246 The idea behind this option is to simplify the (likely) process of defining a set of related commands within an input file with its high probability of sharing default values.
1247 The setting of option defaults also works if a command is marked as “protected”.
1248 Generally this is an advantage since you don't have to take care to correctly update the file when you mark something as protected.
1249 But there may be cases where you will want to remove the defaults setting from a \texttt{\%\%protected} clause.
1250
1251 Afterwards you provide the actual LilyPond command in the form of a variable holding a musical expression.
1252 The first line should contain exactly the name, the '=' and the opening curly brace.
1253 The name of the variable is very important because it will also be used as the file name of the image file and the \LaTeX{} command name.
1254 The following lines are interpreted as LilyPond code until the parser finds a line starting with the closing curly brace.
1255 This will also end the command entry, but for readability's sake it is a good idea to enter at least one empty line after the entry.
1256
1257 One important thing to know is that by default the generated image will \emph{not} print staff lines, a time signature and the clef.
1258
1259 This is a minimal working example of a \lilyglyphs{} entry section:
1260
1261 \begin{lstlisting}
1262 %%lilyglyphs
1263 % crotchet with upward stem
1264 crotchet = {
1265 g'4
1266 }
1267 \end{lstlisting}
1268
1269 \paragraph*{Warnings:}
1270 So far the parser isn't very smart.
1271 It just \emph{assumes} that the input file it parses is correct.
1272 If you provide code with deviations from this explanation, the script will probably produce erroneous results or just stop working.
1273 Probably it won't do any harm, but we can't make any promises on that.
1274 Please consider the script as being in a \textbf{very experimental} state.
1275
1276 In the current implementation you can't create commands that \emph{do} print staff lines, time signatures or clefs.
1277 To achieve this you'd have to write the LilyPond input file(s) on your own.
1278 This issue is on the \textsc{todo} list for one of the next releases of \lilyglyphs.
1279
1280 \bigskip
1281 You can define as many entries in one file as you like -- they will all be processed at once.
1282 Of course it is recommended to combine a coherent set of commands.
1283
1284 Everything that is outside of the lilyglyph entries is ignored by the script, so you can make use of these places to make a usable LilyPond file out of it.
1285 You can start off with the file \texttt{/definitions/\_template.ly} to see how it works.
1286
1287 Basically you have to copy your definition to a new variable named \texttt{symbol} and then include a special include file \texttt{score.ily} (which is provided in that \dir{/definitions} directory).
1288 This will print your command definition as the only element in a new score block that is prepared not to print staff, time signature and clef.
1289 You can repeat this several times, inserting top-level \cmd{markup}s and have LilyPond produce a sheet with all defined symbols.
1290 This way you can finish your design in “pure LilyPond” before actually going on to the \LaTeX{} part -- and at the same time prepare a reference sheet of your work.
1291
1292 \begin{lstlisting}
1293 \version "2.16.2"
1294
1295 %%lilyglyphs
1296 % crotchet with upward stem
1297 crotchet = {
1298 g'4
1299 }
1300 \markup "Crotchet with upward stem"
1301 symbol = \crotchet
1302 \include "score.ily"
1303
1304 % %lilyglyphs
1305 % crotchet with downward stem
1306 crotchetDown = {
1307 \stemDown
1308 c'4
1309 }
1310 \markup "Crotchet with downward stem"
1311 symbol = \crotchetDown
1312 \include "score.ily"
1313
1314 % and so on ...
1315 \end{lstlisting}
1316
1317 \subsection{Running the Script}
1318 \label{subsec:BGI_running}
1319
1320 If you have prepared your input file you can run the \texttt{lily-image-commands.py} script, passing it the complete file name (as a relative or absolute path) of your definitions file.
1321 The script tries to check if the input file is in the correct location -- which is considered true if it is in a \dir{defintions} folder and has a \dir{lilyglyphs*} directory in its path.
1322 This is valid both within the package directory and the private directory structure.
1323
1324 Now the script will do several things:
1325
1326 \paragraph*{Generate LilyPond source files:}
1327 In a first step the program parses the input file and extracts information about the command definitions that haven't been marked as protected.
1328 For each command definition it generates one compilable LilyPond source file in the \dir{/generated\_src} directory, named with the command name.
1329 If there is such a file already (i.\,e. the command had already been processed before) you will be asked if you want to overwrite this file.
1330 If you are currently working on a command you will probably want the file to be overwritten, but if you \emph{accidentally} used a name that already exists you should of course keep the existing files and rename your new command.
1331
1332 \paragraph*{Compile images with LilyPond:}
1333 Now these generated source files are compiled using LilyPond with the command line option \verb|-dpreview|.
1334 The directory is then cleaned up, and the resulting small PDF files are moved to the \dir{/pdfs} directory.
1335
1336 \paragraph*{Generate \LaTeX{} commands:}
1337 Finally the script generates a \LaTeX{} file that is comparable to the one generated by the Emmentaler command generation script.
1338 It will be stored in the \dir{/generated\_cmd} directory as a \texttt{.tex} file with the same basename as your original input file.
1339 Please note that these generated files aren't considered persistent and will be overwritten if you repeatedly process the same input file.
1340
1341 \subsection{Utilizing the results}
1342 \label{subsec:BGI_utilizing_results}
1343
1344 If you have successfully run the script you have the following results:
1345 \begin{itemize}
1346 \item LilyPond source files in the \dir{/generated\_src} folder (one for each command),
1347 \item corresponding PDF files in the \dir{/pdfs} folder and
1348 \item the file \dir{/generated\_cmd/INPUTFILENAME.tex}.
1349 \end{itemize}
1350
1351 You shouldn't touch the first two items but go on and open the \texttt{.tex} file.
1352 This file is structured identically as the files generated by \texttt{lily-glyph-commands.py}, and also the way to finish off and possibly contribute your commands is essentially the same as described in \fref{subsec:GGC_fine-tuning} and \fref{subsec:GGC_finishing_off}.
1353
1354 There are a few differences however:
1355
1356 \begin{itemize}
1357 \item You should always keep the original definitions file so you can later re-generate the image from it.
1358 This can happen when you need to modify it -- or when you want to upgrade the package to a new version of \emmentaler{} or LilyPond.
1359 \item Don't forget to mark finished command definitions as ‘protected’.
1360 \item Keep in mind that the generated \texttt{.tex} file will be overwritten next time the same input file is processed by the script, so if you need to make any changes to the \LaTeX{} command definitions you should immediately copy them to a safe place.
1361 \item Sometimes you will find that a rather tall glyph is difficult to accomodate because the necessary scaling will make it look unnaturally small.
1362 In such a case you might consider going back to the LilyPond side to review the design of your glyph (for example the glyphs for the single note commands have shortened stems).
1363 Please make sure that you understand the implications of the following section about partial processing.
1364 \item If you want to submit new commands by email we need
1365 \begin{inparaenum}[1)]
1366 \item the original definition,
1367 \item the generated LilyPond source, and
1368 \item the final \LaTeX{} command.
1369 \end{inparaenum}
1370 \end{itemize}
1371
1372 \subsection{Partial processing of the input file}
1373 \label{subsec:BGI_partial_processing}
1374
1375 You are encouraged to put a coherent set of multiple command definitions in one definitions file and keep this file, as it is the source from that everything can be rebuilt at any time.
1376 But there will be occasions when you don't want the Python script to do all the work over and over again.
1377 If you add a new command to the input file (and you \emph{should} add it to an existing file if it belongs to the same category) you only want the new command to be processed.
1378 Or if you are working on the fine-tuning of the commands (as described in the previous section) and decide that you have to change the LilyPond definition of a single glyph you also only want to reprocess this one.
1379 For this purpose you can mark entries in the input definitions file as “protected”, in order to prevent them to be newly processed by the script.
1380 To do this you enter a line containing \verb|%%protected| in your entry definition (note the double percent sign and the absence of a \texttt{space} after them).
1381 You can see an example for this in the \texttt{\_template.ly} file -- because the example entry shouldn't be processed at all.
1382 From now on the marked command won't be processed anymore.
1383 This means that the LilyPond source file won't be generated again, LilyPond isn't run again for the script (which would be the most annoying thing), and the \LaTeX{} commands won't be generated again.
1384 The output file will of course be overwritten (you have renamed it before re-running the script, didn't you?) but it won't be cluttered with commands that you have already dealt with earlier.
1385
1386
1387 \subsection{Recreating Image Files}
1388 \label{subsec:BGI_recreating_images}
1389
1390 There also are occasions when you might have to (re)create the \textsc{pdf} files that serve as the glyph images without having to regenerate the \LaTeX{} commands or the LilyPond source files.
1391 One example would be the upgrade to a new an \emmentaler{} version.
1392 In that case you can run the script \texttt{rebuild-pdfs.py}.
1393 In order to work the script expects the current working directory to be either the \dir{glyphimages} subdirectory of the package or the root of the \dir{lilyglyphs\_private} directory.
1394 This script essentially compares the directories with the generated LilyPond sources and with the created pdf files, and if it finds a source without a corresponding pdf it will call LilyPond to recreate it.
1395 If you don't want to regenerate \emph{missing} \textsc{pdf}s but rather replace \emph{existing} files you first have to delete the \emph{pdf} files on disk so the script can detect them as missing.
1396 Of course this script will only work with a working LilyPond installation.
1397
1398 \medskip
1399 Maybe in the future there will be functionality to detect changes in the glyphs' definitions, or remove \textsc{pdf} files that don't have a corresponding source file anymore.
1400
1401 \chapter{Contributing to \lilyglyphs}
1402 \label{chap:contributing}
1403
1404 The original motivation to create \lilyglyphs{} was the need to include musical symbols in a critical report of a scholarly edition.
1405 Looking around on the internet and \textsc{ctan} I didn't find a solution that was even near the flexibility and output quality I wanted for this edition (and my work in general), so I came up with the idea of accessing the glyphs of LilyPond's \emmentaler{} font.
1406 Fortunately I realized very early that I should make all this more generic and create a public \LaTeX{} package.
1407 When I found the solution to incorporate non-Emmentaler glyphs through LilyPond-generated \textsc{pdf} images I saw that it worked out quite well.
1408 By now I have a solution that completely works for my personal needs and presumably is a useful package for any \LaTeX{} authors interested in incorporating musical symbols in their documents.
1409
1410 But \lilyglyphs{} definitely is a package that lives on community contribution.
1411 Why? Because one of the main goals for continuing development is a growing coverage of glyphs.
1412 This task is very “scalable“ and prone to “crowd-development” because any number of contributors can add commands from the fields they are working on and need glyphs from.
1413 I personally will probably only add new commands as I need them for my work, maybe sometimes getting the hang and complete a group.
1414 So anybody who uses the package to a more than casual degree is highly encouraged to share his additions with me and the community.
1415
1416 There are also existing issues with the \LaTeX{} implementation that can be seen in the project's issue tracker on GitHub (\url{https://github.com/openlilylib/lilyglyphs}).
1417 Furthermore I'm sure there are quite a few things that could be implemented more elegantly, more efficiently, or with less package dependencies -- this package is actually my first serious work with \LaTeX{} \dots
1418
1419 And finally I have some ideas how \lilyglyphs' functionality could be enhanced, and others could come up with more ideas.
1420 For example I would be interested in having parametrized commands that can print a number of related glyphs, there could be more layout options, I would like to be able to use global layout options for specific glyph groups (e.g. raise all accidentals by a certain amount) etc.
1421 And one day I would like to make the package compliant to the currently emerging SMuFL standard%
1422 \footnote{\url{http://www.smufl.org}}
1423 in order to allow using glyphs from different music fonts.
1424
1425 So if you think this package is interesting, please contact me so it can evolve over time!
1426 If you're just using it, please submit any additions you make for your own use (or start submitting arbitrary commands to enhance the package's coverage).
1427 And if you're a \LaTeX{} expert please don't hesitate to go right to the core and help me with the evolution of its code base \dots
1428
1429 \end{document}