Debian Codegraph @

texk/gregorio/gregorio-src/tex/gregoriotex-spaces.tex

raw
1 %GregorioTeX file.
2 %
3 % Copyright (C) 2007-2025 The Gregorio Project (see CONTRIBUTORS.md)
4 %
5 % This file is part of Gregorio.
6 %
7 % Gregorio is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
11 %
12 % Gregorio is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 % GNU General Public License for more details.
16 %
17 % You should have received a copy of the GNU General Public License
18 % along with Gregorio. If not, see <http://www.gnu.org/licenses/>.
19
20 % this file contains definitions of spaces
21
22 \gre@declarefileversion{gregoriotex-spaces.tex}{6.1.0}% GREGORIO_VERSION
23
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 %% macros for tuning penalties
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 %% The following macros enable users to tune penalties used in Gregorio
29
30 % macro to force a break on a new line
31 \def\GreForceBreak{\gre@penalty{\the\gre@space@count@newlinepenalty}}%
32
33 % macro to prevent a line break
34 \def\GreNoBreak{\gre@penalty{\the\gre@space@count@nobreakpenalty}}%
35
36
37
38 \newcount\gre@saved@prescore@hyphenpenalty%
39 \newcount\gre@saved@prescore@exhyphenpenalty%
40 \newcount\gre@saved@prescore@exhyphenchar%
41 \newcount\gre@saved@prescore@doublehyphendemerits%
42 \newcount\gre@saved@prescore@finalhyphendemerits%
43 \newcount\gre@saved@prescore@brokenpenalty%
44 \newcount\gre@saved@prescore@looseness%
45 \newcount\gre@saved@prescore@tolerance%
46 \newcount\gre@saved@prescore@pretolerance%
47 \newskip\gre@saved@prescore@emergencystretch%
48 \newcount\gre@saved@prescore@widowpenalty%
49 \newcount\gre@saved@prescore@clubpenalty%
50 \newskip\gre@saved@prescore@parskip%
51 \newskip\gre@saved@prescore@lineskip%
52 \newskip\gre@saved@prescore@baselineskip%
53 \newskip\gre@saved@prescore@lineskiplimit%
54 %% The following macros cancel some useless penalties, and reinstates them
55 %% at the end of a score
56
57 \def\gre@cancelpenalties{%
58 \gre@trace{gre@cancelpenalties}%
59 \global\gre@saved@prescore@hyphenpenalty=\hyphenpenalty\relax %
60 \hyphenpenalty=\gre@space@count@hyphenpenalty %
61 %
62 \global\gre@saved@prescore@exhyphenpenalty=\exhyphenpenalty\relax %
63 \exhyphenpenalty=\gre@space@count@hyphenpenalty %
64 %
65 \global\gre@saved@prescore@exhyphenchar=\exhyphenchar\relax %
66 \exhyphenchar=-1\relax%
67 %
68 \global\gre@saved@prescore@doublehyphendemerits=\doublehyphendemerits\relax %
69 \doublehyphendemerits=0\relax %
70 %
71 \global\gre@saved@prescore@finalhyphendemerits=\finalhyphendemerits\relax %
72 \finalhyphendemerits=0\relax %
73 %
74 \global\gre@saved@prescore@brokenpenalty=\brokenpenalty\relax %
75 \brokenpenalty=\gre@space@count@brokenpenalty %
76 %
77 \global\gre@saved@prescore@looseness=\looseness\relax %
78 \looseness=\gre@space@count@looseness %
79 %
80 \global\gre@saved@prescore@tolerance=\tolerance\relax %
81 \tolerance=\gre@space@count@tolerance %
82 %
83 \global\gre@saved@prescore@pretolerance=\pretolerance\relax %
84 \pretolerance=\gre@space@count@pretolerance %
85 %
86 \global\gre@saved@prescore@emergencystretch=\emergencystretch\relax %
87 \emergencystretch=\gre@space@skip@emergencystretch\relax %
88 %
89 \global\gre@saved@prescore@widowpenalty=\widowpenalty\relax %
90 \widowpenalty=\gre@space@count@widowpenalty %
91 %
92 \global\gre@saved@prescore@clubpenalty=\clubpenalty\relax %
93 \clubpenalty=\gre@space@count@clubpenalty %
94 %
95 \global\gre@saved@prescore@parskip=\parskip%
96 \parskip=\gre@space@skip@parskip%
97 %
98 \global\gre@saved@prescore@lineskip=\lineskip%
99 \lineskip=\gre@space@skip@lineskip%
100 %
101 \global\gre@saved@prescore@baselineskip=\baselineskip%
102 \baselineskip=\gre@space@skip@baselineskip%
103 %
104 \global\gre@saved@prescore@lineskiplimit=\lineskiplimit%
105 \lineskiplimit=\gre@space@skip@lineskiplimit%
106 \gre@trace@end%
107 }%
108
109 \def\gre@restorepenalties{%
110 \gre@trace{gre@restorepenalties}%
111 \hyphenpenalty=\gre@saved@prescore@hyphenpenalty %
112 \exhyphenpenalty=\gre@saved@prescore@exhyphenpenalty %
113 \exhyphenchar=\gre@saved@prescore@exhyphenchar %
114 \doublehyphendemerits=\gre@saved@prescore@doublehyphendemerits %
115 \finalhyphendemerits=\gre@saved@prescore@finalhyphendemerits %
116 \brokenpenalty=\gre@saved@prescore@brokenpenalty %
117 \looseness=\gre@saved@prescore@looseness %
118 \tolerance=\gre@saved@prescore@tolerance %
119 \pretolerance=\gre@saved@prescore@pretolerance %
120 \emergencystretch=\gre@saved@prescore@emergencystretch %
121 \widowpenalty=\gre@saved@prescore@widowpenalty %
122 \clubpenalty=\gre@saved@prescore@clubpenalty %
123 \parskip=\gre@saved@prescore@parskip%
124 \lineskip=\gre@saved@prescore@lineskip%
125 \baselineskip=\gre@saved@prescore@baselineskip%
126 \lineskiplimit=\gre@saved@prescore@lineskiplimit%
127 \gre@trace@end%
128 }%
129
130
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 %% macros for the typesetting of spaces
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134
135 % Independent default distances are defined in gregoriotex-gsp-default.tex. The distances defined here are calculated from those distances.
136
137 %%%%%%%%%%%%%%%%%
138 %% Global distances
139 %%%%%%%%%%%%%%%%%
140
141 % textlower is the height of the separation between the bottom line (which is invisible : for the notes which are very low) and the bottom of the text
142 \newdimen\gre@dimen@textlower\relax%
143 \def\gre@calculate@textlower{%
144 \gre@trace{gre@calculate@textlower}%
145 \gre@dimen@textlower=\gre@space@dimen@spacebeneathtext\relax%
146 %\advance\gre@dimen@textlower by \translationheight
147 \gre@trace@end%
148 }%
149
150 % stafflinewidth is the width of a line of staff, this can vary, for example at the first line
151 \newdimen\gre@dimen@stafflinewidth\relax%
152 \def\gre@calculate@stafflinewidth{%
153 \gre@trace{gre@calculate@stafflinewidth}%
154 \gre@dimen@stafflinewidth=\gre@dimen@linewidth\relax%
155 \gre@trace@end%
156 }%
157
158
159 % linewidth is the width of a line of a score (including the initial)
160 \newdimen\gre@dimen@linewidth\relax%
161 \def\gre@calculate@linewidth{%
162 \gre@trace{gre@calculate@linewidth}%
163 \gre@dimen@linewidth=\hsize %
164 \gre@trace@end%
165 }%
166
167 % Messing with the staff line thickness directly is messy, so we provide the following interface to make life easier on the user:
168 % stafflineheight is the height of a staff line
169 % = gre@dimen@stafflinethicknessbase * stafflinefactor
170 \newdimen\gre@dimen@stafflineheight\relax%
171 \def\gre@calculate@stafflineheight{%
172 \gre@trace{gre@calculate@stafflineheight}%
173 \global\gre@dimen@stafflineheight=\dimexpr(\gre@dimen@stafflinethicknessbase * \gre@stafflinefactor)\relax %
174 \gre@trace@end%
175 }%
176
177 % interstafflinespace is the space between two lines of staff
178 % = (gre@dimen@interstafflinedistancebase + gre@dimen@stafflinethicknessbase) * gre@factor - gre@dimen@stafflinethicknessbase * gre@stafflinefactor
179 \newdimen\gre@dimen@interstafflinespace\relax%
180 \def\gre@calculate@interstafflinespace{%
181 \gre@trace{gre@calculate@interstafflinespace}%
182 \global\gre@dimen@interstafflinespace=\dimexpr((\gre@dimen@interstafflinedistancebase + \gre@dimen@stafflinethicknessbase) * \gre@factor - \gre@dimen@stafflinethicknessbase * \gre@stafflinefactor)\relax%
183 \gre@trace@end%
184 }%
185
186 % a distance to help place glyphs when the lines are not their default thickness
187 % = gre@dimen@stafflinethicknessbase * (gre@stafflinefactor - gre@factor) / 2
188 \newdimen\gre@dimen@stafflinediff\relax%
189 \def\gre@calculate@stafflinediff{%
190 \gre@trace{gre@calculate@stafflinediff}%
191 \global\gre@dimen@stafflinediff = \dimexpr( \gre@dimen@stafflinethicknessbase * (\gre@stafflinefactor - \gre@factor) / 2 )\relax%
192 \gre@trace@end%
193 }%
194
195 % the default factor
196 % the stafflinefactor follows the same scale as the gre@factor, i.e. a stafflinefactor corresponds to the default staff line thickness for gre@factor 17, stafflinefactor 34 corresponds to the default staff line thickness for gre@factor 34, etc.
197 \xdef\gre@stafflinefactor{17}%
198 % flag for whether the stafflinefactor should scale with changes of the gre@factor
199 \newif\ifgre@scale@stafflinefactor%
200 \gre@scale@stafflinefactortrue
201
202 % a macro for setting the thickness of the staff lines. The changes to stafflinefactor will be automatically picked up when the staff lines are redrawn
203 \def\grechangestafflinethickness#1{%
204 \xdef\gre@stafflinefactor{#1}%
205 \relax %
206 }%
207
208
209 %constantglyphraise is the space between the 0 of the gregorian fonts and the effective 0 of the TeX score
210 \newdimen\gre@dimen@constantglyphraise\relax%
211 % to calculate that, we take the bottom of the third line : it is at 200 in the fonts, and it must be at grespacelinestext + grespacebeneathtext + 2*greinterstafflinespace + 2*grestafflineheight + translationheight
212 \def\gre@calculate@constantglyphraise{%
213 \gre@trace{gre@calculate@constantglyphraise}%
214 \global\gre@dimen@constantglyphraise = \dimexpr((\gre@dimen@glyphraisebase * \gre@factor) %
215 + \gre@dimen@additionalbottomspace %
216 + \gre@space@dimen@spacebeneathtext %
217 + \gre@space@dimen@spacelinestext %
218 + \gre@dimen@interstafflinespace %
219 + \gre@dimen@interstafflinespace %
220 + \gre@dimen@stafflineheight %
221 + \gre@dimen@stafflineheight %
222 + \gre@dimen@currenttranslationheight %
223 % an adjustment in the case of big lines
224 + \gre@dimen@stafflinediff)\relax%
225 \relax %
226 \gre@trace@end%
227 }%
228
229 %% Here is the function to compute some more vertical spaces from the basic values
230 \newdimen\gre@dimen@staffheight\relax%
231 \def\gre@calculate@staffheight{%
232 \gre@trace{gre@calculate@staffheight}%
233 \global\gre@dimen@staffheight = \dimexpr %
234 \gre@count@stafflines\gre@dimen@stafflineheight %
235 + \gre@count@stafflines\gre@dimen@interstafflinespace %
236 - \gre@dimen@interstafflinespace\relax%
237 \relax %
238 \gre@trace@end%
239 }%
240
241 % A routine that simply aggregates the above global space calculating routines so we can easily update all when needed.
242 %% Note: It used to be that some distance calculating functions called others. Since this can create problems with circularity if one is not careful, this is no longer the case. Now all distance calculating functions simply calculate their respective distance. This means that dependent distances are not necessarily recalculated when an individual distance is recalculated. This function updates all global calculated distances and in the order needed for the dependencies.
243 %% Dependencies:
244 %% textlower: spacebeneathtext
245 %% linewidth: hsize
246 %% stafflinewidth: linewidth
247 %% stafflineheight: stafflinefactor & gre@factor
248 %% interstafflinespace: stafflineheight & gre@factor
249 %% stafflinediff: stafflineheight & gre@factor
250 %% staffheight: stafflineheight & interstafflinespace
251 %% constantglyphraise: gre@factor, additionalbottomspace, spacebeneathtext, spacelinestext, interstafflinespace, stafflineheight, currenttranslationheight, stafflinediff
252 \def\gre@computespaces{%
253 \gre@trace{gre@computespaces}%
254 \gre@calculate@textlower%
255 \gre@calculate@linewidth%
256 \gre@calculate@stafflinewidth%
257 \gre@calculate@stafflineheight%
258 \gre@calculate@interstafflinespace%
259 \gre@calculate@stafflinediff%
260 \gre@calculate@staffheight%
261 \gre@calculate@constantglyphraise%
262 \gre@trace@end%
263 }%
264
265 \newskip\gre@skip@syllablefinalskip
266 \newskip\gre@skip@minTextDistance%
267 \newskip\gre@skip@minNotesDistance%
268 \newdimen\gre@dimen@curTextDistance%
269 \newdimen\gre@dimen@curNotesDistance%
270 \newskip\gre@skip@minShiftText%
271 \newskip\gre@skip@minShiftNotes%
272
273 %% @desc Macro computing the skip at the end of the syllable
274 %% @arg#1 0 if end of syllable, 1 if end of word
275 %% @arg#2 0 if next syllable is normal, 1 if it's a bar, 2 if it starts with
276 %% an alteration
277 %%
278 %% @uses \gre@dimen@enddifference
279 %% @uses \gre@skip@nextbegindifference
280 %%
281 %% Pseudo-code:
282 %% min_text_dist = same_word ? 0 : space_inter_words
283 %% if (no_txt_under_prev) :
284 %% tmp = cur_end_diff > 0 ? 0 : -cur_end_diff
285 %% min_text_dist = max(min_text_dist, tmp)
286 %% min_notes_dist = space_between_notes
287 %% if (barres sur cur ou barres sur next):
288 %% min_notes_dist = space_between_bars
289 %% % space between end of syllable and current point for previous note
290 %% cur_dist_notes = cur_dist_text = 0
291 %% if (cur_end_diff < 0):
292 %% cur_dist_text += -cur_end_diff
293 %% else:
294 %% cur_dist_notes += cur_end_diff
295 %% if (next_begin_diff < 0):
296 %% cur_dist_notes += -next_begin_diff
297 %% else:
298 %% cur_dist_text += next_begin_diff
299 %% min_shift_text = min_dist_text - cur_dist_text
300 %% min_shift_notes = min_dist_notes - cur_dist_notes
301 %% shift = max(min_shift_text, min_shift_notes)
302 \def\gre@calculate@syllablefinalskip#1#2{%
303 \gre@trace{gre@calculate@syllablefinalskip{#1}{#2}}%
304 %% min_text_dist = prev_cur_word ? 0 : space_inter_words
305 \ifnum#1=1\relax %
306 \ifgre@in@euouae %
307 \ifgre@newbarspacing%
308 \ifnum#2=1\relax %
309 \gre@skip@minTextDistance=\gre@space@dimen@interwordspacetext@bars@euouae\relax%
310 \else %
311 \gre@skip@minTextDistance=\gre@space@skip@interwordspacetext@euouae\relax%
312 \fi %
313 \else%
314 \gre@skip@minTextDistance=\gre@space@skip@interwordspacetext@euouae\relax%
315 \fi%
316 \else %
317 \ifgre@newbarspacing%
318 \ifnum#2=1\relax %
319 \gre@skip@minTextDistance=\gre@space@dimen@interwordspacetext@bars\relax%
320 \else %
321 \gre@skip@minTextDistance=\gre@space@skip@interwordspacetext\relax%
322 \fi %
323 \else%
324 \gre@skip@minTextDistance=\gre@space@skip@interwordspacetext\relax%
325 \fi%
326 \fi %
327 \else %
328 \gre@skip@minTextDistance=0pt\relax%
329 \fi %
330 \gre@debugmsg{syllablespacing}{ minTextDistance = \the\gre@skip@minTextDistance}%
331 % setting minNotesDistance (quite simple)
332 \ifcase#2\relax %
333 \ifnum#1=1\relax %
334 \ifgre@in@euouae %
335 \gre@skip@minNotesDistance=\gre@space@skip@interwordspacenotes@euouae\relax%
336 \else %
337 \gre@skip@minNotesDistance=\gre@space@skip@interwordspacenotes\relax%
338 \fi %
339 \else %
340 \gre@skip@minNotesDistance=\gre@space@dimen@intersyllablespacenotes\relax%
341 \fi %
342 \ifnum\gre@count@shiftaftermora>3\relax %
343 \ifgre@thisendswithmora %
344 % last syllable ends by a punctum mora, we want to ignore it.
345 % this sets the distance to shift into \gre@skip@temp@four:
346 \gre@get@unkern@aftermora{1}%
347 \advance\gre@skip@minNotesDistance by \gre@skip@punctummorashift %
348 \fi %
349 \fi %
350 \or %
351 \ifgre@newbarspacing %
352 \gre@skip@minNotesDistance=0pt\relax%
353 \else %
354 \gre@skip@minNotesDistance=\gre@space@skip@notebarspace\relax%
355 \fi %
356 \or %
357 \ifnum#1=1\relax %
358 \gre@skip@minNotesDistance=\gre@space@skip@interwordspacenotes@alteration\relax %
359 \else %
360 \gre@skip@minNotesDistance=\gre@space@dimen@intersyllablespacenotes@alteration\relax%
361 \fi %
362 \fi %
363 \gre@debugmsg{syllablespacing}{ minNotesDistance = \the\gre@skip@minNotesDistance}%
364 % determining current distance between notes and
365 % next notes, and current distance between text and next text
366 \gre@dimen@curTextDistance=0pt\relax%
367 \gre@dimen@curNotesDistance=0pt\relax%
368 %% cur_dist_notes = cur_dist_text = 0
369 %% if (cur_end_diff < 0):
370 %% cur_dist_notes += -cur_end_diff
371 %% else:
372 %% cur_dist_text += cur_end_diff
373 %% if (next_begin_diff < 0):
374 %% cur_dist_notes += -next_begin_diff
375 %% else:
376 %% cur_dist_text += next_begin_diff
377 \gre@debugmsg{syllablespacing}{ enddifference = \the\gre@dimen@enddifference}%
378 \gre@debugmsg{syllablespacing}{ nextbegindifference = \the\gre@skip@nextbegindifference}%
379 \ifdim\gre@dimen@enddifference < 0 pt\relax%
380 \gre@dimen@curNotesDistance = -\gre@dimen@enddifference\relax%
381 \else %
382 \gre@dimen@curTextDistance = \gre@dimen@enddifference\relax%
383 \fi %
384 \ifdim\gre@skip@nextbegindifference < 0 pt\relax%
385 \advance\gre@dimen@curNotesDistance by -\gre@skip@nextbegindifference\relax%
386 \else %
387 \advance\gre@dimen@curTextDistance by \gre@skip@nextbegindifference\relax%
388 \fi %
389 \gre@debugmsg{syllablespacing}{ curNotesDistance = \the\gre@dimen@curNotesDistance}%
390 \gre@debugmsg{syllablespacing}{ curTextDistance = \the\gre@dimen@curTextDistance}%
391 %% min_shift_text = min_dist_text - cur_dist_text
392 %% min_shift_notes = min_dist_notes - cur_dist_notes
393 %% shift = max(min_shift_text, min_shift_notes)
394 \gre@skip@minShiftText = \glueexpr(\gre@skip@minTextDistance - \gre@dimen@curTextDistance)\relax %
395 \gre@skip@minShiftNotes = \glueexpr(\gre@skip@minNotesDistance - \gre@dimen@curNotesDistance)\relax %
396 \gre@debugmsg{syllablespacing}{ minShiftNotes = \the\gre@skip@minShiftNotes}%
397 \gre@debugmsg{syllablespacing}{ minShiftText = \the\gre@skip@minShiftText}%
398 \ifdim\gre@skip@minShiftNotes < \gre@skip@minShiftText %
399 \global\gre@skip@syllablefinalskip = \gre@skip@minShiftText %
400 \else %
401 \global\gre@skip@syllablefinalskip = \gre@skip@minShiftNotes %
402 \fi %
403 \ifgre@showhyphenafterthissyllable %
404 \gre@debugmsg{syllablespacing}{ add intersyllablespacestretchhyphen (\gre@space@skip@intersyllablespacestretchhyphen)}%
405 \advance\gre@skip@syllablefinalskip by \gre@space@skip@intersyllablespacestretchhyphen\relax%
406 \fi %
407 \gre@debugmsg{syllablespacing}{ syllablefinalskip = \the\gre@skip@syllablefinalskip}%
408 \relax %
409 \gre@trace@end%
410 }
411
412 % dimen keeping the shift computed with next function
413 \newdimen\gre@dimen@bolshift
414 % dimen which is used to add a bit extra to the previous one in the case where the first glyph is a flat or a natural
415 \newdimen\gre@dimen@bolextra
416
417 %% @desc Macro used in \GreSyllable. Sets \gre@skip@bolshift to the left kern that
418 %% should appear at the beginning of a line in case of a linebreak.
419 %% The goal of this left kern is to have all lines aligned on notes. See
420 %% TODO for details.
421 %%
422 %% @arg#1 \gre@dimen@begindifference of the first syllable of the line
423 \def\gre@calculate@bolshift#1{%
424 \gre@trace{gre@calculate@bolshift{#1}}%
425 \gre@skip@temp@three = 0pt\relax%
426 % bolextra is the space taken up by a leading alteration (it's 0 if there is no leading alteration)
427 % it's allowed to invade spaceafterlineclef, so long as it leaves at least beforealterationspace between itself and the clef
428 % and minimalspaceatlinebeginning between the lyrics and the beginning of the line
429 \gre@skip@temp@one = \glueexpr(\gre@space@skip@spaceafterlineclef-\gre@space@dimen@beforealterationspace)\relax%
430 \ifdim\gre@dimen@bolextra>\gre@skip@temp@one\relax%
431 \global\advance\gre@skip@temp@three by \gre@skip@temp@one\relax%
432 \else%
433 \global\advance\gre@skip@temp@three by \gre@dimen@bolextra\relax%
434 \fi%
435 \gre@debugmsg{bolshift}{ clefwidthcurrent = \the\gre@dimen@clefwidth@current}%
436 \gre@debugmsg{bolshift}{ clefwidthbol = \the\gre@dimen@clefwidth@bol}%
437 % we ignore the current-bol adjustment if the clef is the first of the score and there is an initial on one line:
438 \ifnum\gre@count@initiallines=1\ifgre@beginningofscore\else %
439 \global\advance\gre@skip@temp@three by \dimexpr(\gre@dimen@clefwidth@current-\gre@dimen@clefwidth@bol)\relax %
440 \fi\else %
441 \global\advance\gre@skip@temp@three by \dimexpr(\gre@dimen@clefwidth@current-\gre@dimen@clefwidth@bol)\relax %
442 \fi %
443 \ifdim#1>0pt\relax%
444 % no additional shift is needed if the notes start before the text
445 \global\gre@dimen@bolshift = \gre@skip@temp@three\relax%
446 \else%
447 % as the \gre@dimen@bolshift is computed from skips, we compute it in
448 % a skip temp registry, and then "cast" it into a dimen
449 % basic value for bolshift needs to incorporate -begindifference
450 \advance\gre@skip@temp@three by -#1\relax%
451 % we don't want to kern more than clefwidth + spaceafterlineclef - minimalspaceatlinebeginning
452 % violating this would mean that either the notes are closer than (clefwidth + spaceafterlineclef)
453 % or that the lyrics are closer than minimalspaceatlinebeginning
454 \gre@skip@temp@one = \glueexpr(\gre@dimen@clefwidth@current %
455 + \gre@space@skip@spaceafterlineclef %
456 - \gre@space@dimen@minimalspaceatlinebeginning)\relax %
457 \ifdim\gre@skip@temp@three < \gre@skip@temp@one %
458 \global\gre@dimen@bolshift = \dimexpr\gre@skip@temp@three\relax %
459 \else%
460 \global\gre@dimen@bolshift = \dimexpr\gre@skip@temp@one\relax %
461 \fi %
462 \fi%
463 \gre@debugmsg{bolshift}{ bolshift = \the\gre@dimen@bolshift}%
464 \relax %
465 \gre@trace@end%
466 }
467
468 % the width of the current
469 \newdimen\gre@dimen@clefwidth@current\relax%
470 % the width of the max clef
471 \newdimen\gre@dimen@clefwidth@largest\relax%
472 % the width to compute bolshift with
473 \newdimen\gre@dimen@clefwidth@bol\relax%
474
475 \def\gre@update@clefwidth@current#1{%
476 \gre@trace{gre@update@clefwidth@current{#1}}%
477 \gre@debugmsg{bolshift}{ updating clefwidthcurrent to \the\gre@dimen@clefwidth@current}%
478 \global\gre@dimen@clefwidth@current=#1\relax %
479 \ifnum\gre@bolshiftcleftypelocal=2\relax %
480 \global\gre@dimen@clefwidth@bol=#1\relax %
481 \fi %
482 \relax %
483 \gre@trace@end%
484 }
485
486 \def\gre@update@clefwidth@largest#1{%
487 \gre@trace{gre@update@clefwidth@largest{#1}}%
488 \global\gre@dimen@clefwidth@largest=#1\relax %
489 \ifnum\gre@bolshiftcleftypelocal=1\relax %
490 \global\gre@dimen@clefwidth@bol=#1\relax %
491 \fi %
492 \gre@trace@end%
493 }
494
495 \def\gre@update@clefwidth@forced#1{%
496 \gre@trace{gre@update@clefwidth@forced{#1}}%
497 \global\gre@dimen@clefwidth@bol=#1\relax %
498 \gre@trace@end%
499 }
500
501 % 1 for largest, 2 for current and 3 for forced
502 \xdef\gre@bolshiftcleftypeglobal{1}
503 \xdef\gre@bolshiftcleftypelocal{1}
504
505 \def\grebolshiftcleftype#1{
506 \IfStrEqCase{#1}{%
507 {largest}%
508 {\xdef\gre@bolshiftcleftypeglobal{1}\xdef\gre@bolshiftcleftypelocal{1}}%
509 {current}%
510 {\xdef\gre@bolshiftcleftypeglobal{2}\xdef\gre@bolshiftcleftypelocal{2}}%
511 }[% all other cases
512 \gre@error{Unrecognized option "#1" for \protect\grebolshiftcleftype\MessageBreak Possible options are: 'largest' and 'current'.}%
513 ]%
514 }
515
516 \def\grelocalbolshiftcleftype#1{
517 \IfStrEqCase{#1}{%
518 {largest}%
519 {\xdef\gre@bolshiftcleftypelocal{1}%
520 \global\gre@dimen@clefwidth@bol=\gre@dimen@clefwidth@largest\relax }%
521 {current}%
522 {\xdef\gre@bolshiftcleftypelocal{2}%
523 \global\gre@dimen@clefwidth@bol=\gre@dimen@clefwidth@current\relax }%
524 {c}%
525 {\gre@boxclef{c}{3}{0}{1}{3}{c}{0}{3}%
526 \xdef\gre@bolshiftcleftypelocal{3}%
527 \gre@update@clefwidth@forced{\wd\gre@box@temp@width}}%
528 {f}%
529 {\gre@boxclef{f}{3}{0}{1}{3}{c}{0}{3}%
530 \xdef\gre@bolshiftcleftypelocal{3}%
531 \gre@update@clefwidth@forced{\wd\gre@box@temp@width}}%
532 {cb}%
533 {\gre@boxclef{c}{3}{0}{1}{8}{c}{0}{3}%
534 \xdef\gre@bolshiftcleftypelocal{3}%
535 \gre@update@clefwidth@forced{\wd\gre@box@temp@width}}%
536 {fb}%
537 {\gre@boxclef{f}{3}{0}{1}{8}{c}{0}{3}%
538 \xdef\gre@bolshiftcleftypelocal{3}%
539 \gre@update@clefwidth@forced{\wd\gre@box@temp@width}}%
540 }[% all other cases
541 \gre@error{Unrecognized option "#1" for \protect\grelocalbolshiftcleftype\MessageBreak Possible options are: 'largest', 'current', 'c', 'f', 'cb' and 'fb'.}%
542 ]%
543 }
544
545 \def\GreProtrusionFactor#1{\csname gre@protrusionfactor@#1\endcsname}%
546
547 \def\gresetprotrusionfactor#1#2{%
548 \IfStrEqCase{#1}{%
549 {,}{\def\gre@protrusionfactor@comma{#2}}%
550 {;}{\def\gre@protrusionfactor@semicolon{#2}}%
551 {:}{\def\gre@protrusionfactor@colon{#2}}%
552 {.}{\def\gre@protrusionfactor@period{#2}}%
553 {eolhyphen}{\def\gre@protrusionfactor@eolhyphen{#2}}%
554 {default}{\def\gre@protrusionfactor@default{#2}}%
555 }[%
556 \gre@error{Unrecognized protrusion "#1" for \protect\gresetprotrusionfactor\MessageBreak Possible options are: ',', ';', ':', '.', 'eolhyphen', and\MessageBreak 'default'}%
557 ]%
558 }%
559
560 \def\GreProtrusion#1#2{%
561 \gre@widthof{#2}%
562 \IfStrEq{#1}{d}{% d = default
563 \gre@dimen@temp@four=\dimexpr(\gre@dimen@temp@three-\gre@protrusionfactor@default\gre@dimen@temp@three)\relax %
564 }{%
565 \gre@dimen@temp@four=\dimexpr(\gre@dimen@temp@three-#1\gre@dimen@temp@three)\relax %
566 }%
567 \ifdim\gre@dimen@temp@four<0pt\relax %
568 \gre@warning{protrusion factor may not be more than 1}%
569 \gre@dimen@temp@four=0pt\relax %
570 \fi %
571 \ifdim\gre@dimen@temp@four>\gre@dimen@temp@three\relax %
572 \gre@warning{protrusion factor may not be less than 0}%
573 \gre@dimen@temp@four=\gre@dimen@temp@three\relax %
574 \fi %
575 \hbox to \gre@dimen@temp@four{#2\hss}%
576 }%
577
578 \def\gresethyphenprotrusion#1{% OBSOLETE
579 \gre@obsolete{\protect\gresethyphenprotrusion{percentage}}{\protect\gresetprotrusionfactor{eolhyphen}{factor}}% OBSOLETE
580 }% OBSOLETE
581
582 % dimen keeping the shift computed with next function
583 \newdimen\gre@dimen@eolshift
584
585 %% @desc Macro used in \GreSyllable. Sets \gre@dimen@eolshift to the right kern
586 %% that should appear before an end of line. When active this prevents
587 %% text from going under the custos.
588 %%
589 %% @arg#1 The \gre@dimen@enddifference of the corresponding syllable
590 \def\gre@calculate@eolshift#1{%
591 \gre@trace{gre@calculate@eolshift{#1}}%
592 \gre@skip@temp@two=0pt\relax%
593 % we only need a shift if the lyrics are longer than the notes
594 \gre@debugmsg{eolshift}{eolshift called with enddifference: \the #1}%
595 % dimen@temp@three is the length of the hyphen at the end of the syllable
596 \gre@dimen@temp@three=0pt\relax %
597 % if there is a possible hyphen (added afterwards in lua), we keep some room for it
598 \ifgre@possibleluahyphenafterthissyllable %
599 \setbox\gre@box@temp@width=\hbox{\GreHyph}%
600 \gre@dimen@temp@three=\dimexpr(\wd\gre@box@temp@width-\gre@protrusionfactor@eolhyphen\wd\gre@box@temp@width)\relax%
601 \gre@debugmsg{eolshift}{widthof the potential hyphen: \the\gre@dimen@temp@three}%
602 \fi %
603 % The basic value for the eol shift is -enddifference + width of the hyphen
604 \gre@skip@temp@two=\glueexpr(\gre@dimen@temp@three-\the #1)\relax%
605 \gre@debugmsg{eolshift}{adjusted enddifference: \the\gre@skip@temp@two}%
606 % if tex+hyphen goes further than the notes:
607 \ifdim\gre@skip@temp@two>0pt\relax%
608 \gre@skip@temp@three = 0pt%
609 \ifgre@blockeolcustos\else%
610 % The maximum value is wd(custos) + spacebeforeeolcustos
611 % Were the eolshift larger than this the lyrics would stick out
612 % into the margin
613 \setbox\gre@box@temp@width=\hbox{\gre@pickcustos{\gre@pitch@g}{0}}%
614 \gre@skip@temp@three = \glueexpr(\wd\gre@box@temp@width+\gre@space@skip@spacebeforeeolcustos)\relax%
615 \fi %
616 \gre@debugmsg{eolshift}{custos + space before custos = \the\gre@skip@temp@three}%
617 % pick the smaller of the two values calculated above
618 \ifdim\gre@skip@temp@two>\gre@skip@temp@three%
619 \gre@debugmsg{eolshift}{imposing limit}%
620 \global\gre@dimen@eolshift = \glueexpr(\gre@skip@temp@three-\gre@dimen@temp@three)\relax %
621 \else%
622 \ifdim\gre@skip@temp@two<\gre@dimen@temp@three %
623 \global\gre@dimen@eolshift = \gre@skip@temp@two\relax %
624 \else %
625 \global\gre@dimen@eolshift = \glueexpr(\gre@skip@temp@two-\gre@dimen@temp@three)\relax %
626 \fi %
627 \fi%
628 \else%
629 \global\gre@dimen@eolshift=0pt\relax%
630 \fi %
631 % if the notes are not visible, then there's no shifting allowed.
632 \ifgre@shownotes\else%
633 \global\gre@dimen@eolshift=0pt\relax%
634 \fi%
635 \gre@debugmsg{eolshift}{eolshift: \the\gre@dimen@eolshift}%
636 \relax %
637 \gre@trace@end%
638 }
639
640 %%%%%%%%%%%%%%%%%%%
641 %% Local Distances (computed as needed)
642 %%%%%%%%%%%%%%%%%%%
643
644 % glyphraisevalue is the value of which we must raise one glyph (that will vary with every glyph)
645 \newdimen\gre@dimen@glyphraisevalue\relax%
646
647 \newif\ifgre@useledgerlineheuristic%
648 \gre@useledgerlineheuristictrue%
649 \def\gresetledgerlineheuristic#1{%
650 \IfStrEqCase{#1}{%
651 {enable}%
652 {\gre@useledgerlineheuristictrue}%
653 {disable}%
654 {\gre@useledgerlineheuristicfalse}%
655 }[% all other cases
656 \gre@error{Unrecognized option "#1" in \protect\gresetledgerlineheuristic\MessageBreak Possible options are: 'enable' and 'disable'}%
657 ]%
658 }%
659 % for backwards compatibility, we set these to true by default, and the
660 % system will set them appropriately if the heuristics determine a ledger
661 % line probably doesn't exist at that point
662 \newif\ifgre@ledgerline@above%
663 \newif\ifgre@ledgerline@below%
664 \def\GreSupposeHighLedgerLine{%
665 \ifgre@useledgerlineheuristic\gre@ledgerline@abovetrue\fi %
666 }%
667 \def\GreSupposeLowLedgerLine{%
668 \ifgre@useledgerlineheuristic\gre@ledgerline@belowtrue\fi %
669 }%
670 \def\gre@resetledgerlineheuristics{%
671 \gre@trace{gre@resetledgerlineheuristics}%
672 \gre@ledgerline@abovetrue\gre@ledgerline@belowtrue %
673 \gre@trace@end%
674 }%
675 \def\gre@prephepisemaledgerlineheuristics{%
676 \gre@trace{gre@prephepisemaledgerlineheuristics}%
677 \ifgre@useledgerlineheuristic %
678 \gre@ledgerline@abovefalse\gre@ledgerline@belowfalse %
679 \else %
680 \gre@ledgerline@abovetrue\gre@ledgerline@belowtrue %
681 \fi %
682 \gre@trace@end%
683 }%
684
685 % a very useful macro : it determines the good height of a glyph : the argument is the "number" where the glyph should be : 4 for the first line, 6 for the second, etc.
686 % the second argument is for the cases of signs: for example if the note is on a line, the punctummora will be above, and the auctus duplex beneath. the possible values are:
687 %% 0: no modification
688 %% 1: puts the value on the interline just above if it is on a line
689 %% 2: puts the value on the interline just beneath if it is on a line
690 %% 3: case of the vertical episema, which is not placed at the same place if the corresponding note is on a line or not
691 %% 4: case of the punctum mora, for the same reason
692 %% 5: case of the horizontal episema under a note, that must be placed a bit lower if the note is on a line
693 %% 6: case of the signs above (accentus, etc.)
694 %% 8: case of the punctum mora of the first note of a podatus or the 2nd note of a porrectus, etc.
695 %% 9: case of the horizontal episema, that must be placed a bit lower if the note is on a line
696 %% 10: low choral sign not below the note
697 %% 11: high choral sign
698 %% 12: low choral sign below the note
699 %% 13: brace above the bars
700 %% 14: punctum mora in a space with a note on the line below it
701 %% 15: over slur
702 %% 16: under slur
703 %% 17: bracket
704 % #3, for horizontal episemata, is the interline position:
705 %% 0: auto
706 %% 1: middle
707 %% 2: low in space above note
708 %% 3: high in space above note
709 %% 4: low in space below note
710 %% 5: high in space below note
711 \def\gre@calculate@glyphraisevalue#1#2#3{%
712 \gre@trace{gre@calculate@glyphraisevalue{#1}{#2}{#3}}%
713 \global\gre@isonalinefalse%
714 \ifcase#1%
715 % the first two cases are special cases for episemae on the lowest note
716 \or\gre@count@temp@three=\number 0%
717 \or\gre@count@temp@three=\number 1%
718 \or\gre@count@temp@three=\number 2%
719 \or\gre@count@temp@three=\number 3%
720 \ifgre@ledgerline@below %
721 \ifnum#2=3\relax %
722 \else %
723 % if it is a vertical episema, we don't care if it is on a line or
724 % not... which may cause some problems...
725 \global\gre@isonalinetrue %
726 \fi %
727 \fi %
728 \or\gre@count@temp@three=\number 4%
729 \or\gre@count@temp@three=\number 5%
730 \global\gre@isonalinetrue%
731 \or\gre@count@temp@three=\number 6%
732 \or\gre@count@temp@three=\number 7%
733 \global\gre@isonalinetrue%
734 \or\gre@count@temp@three=\number 8%
735 \or\gre@count@temp@three=\number 9%
736 \ifnum\gre@count@stafflines>2\relax
737 \global\gre@isonalinetrue%
738 \else %
739 \ifgre@ledgerline@above %
740 \global\gre@isonalinetrue%
741 \fi %
742 \fi %
743 \or\gre@count@temp@three=\number 10%
744 \or\gre@count@temp@three=\number 11%
745 \ifnum\gre@count@stafflines>3\relax
746 \global\gre@isonalinetrue%
747 \else %
748 \ifnum\gre@count@stafflines>2\relax
749 \ifgre@ledgerline@above %
750 \global\gre@isonalinetrue%
751 \fi %
752 \fi %
753 \fi %
754 \or\gre@count@temp@three=\number 12%
755 \or\gre@count@temp@three=\number 13%
756 \ifnum\gre@count@stafflines>4\relax
757 \global\gre@isonalinetrue%
758 \else %
759 \ifnum\gre@count@stafflines>3\relax
760 \ifgre@ledgerline@above %
761 \global\gre@isonalinetrue%
762 \fi %
763 \fi %
764 \fi %
765 \or\gre@count@temp@three=\number 14%
766 \or\gre@count@temp@three=\number 15%
767 \ifnum\gre@count@stafflines>4\relax
768 \ifgre@ledgerline@above %
769 \global\gre@isonalinetrue%
770 \fi %
771 \fi %
772 \or\gre@count@temp@three=\number 16%
773 \or\gre@count@temp@three=\number 17%
774 \or\gre@count@temp@three=\number 18%
775 \or\gre@count@temp@three=\number 19%
776 \or\gre@count@temp@three=\number 20%
777 \fi%
778 % if there is not line... we don't consider notes are on lines
779 \ifgre@showlines\else %
780 \global\gre@isonalinefalse %
781 \fi %
782 % if the note is on a line, we change its height if necessary
783 \ifgre@isonaline%
784 \ifcase#2 %
785 \or% 1
786 \global\advance\gre@count@temp@three by 1%
787 \or% 2
788 \global\advance\gre@count@temp@three by -1%
789 \or% 3
790 \global\advance\gre@count@temp@three by -1%
791 \or% 4
792 \global\advance\gre@count@temp@three by 1%
793 \or% 5
794 \global\advance\gre@count@temp@three by -1%
795 \or\or\or% 8
796 \global\advance\gre@count@temp@three by -1%
797 \or% 9
798 \global\advance\gre@count@temp@three by 1%
799 \or% 10
800 \global\advance\gre@count@temp@three by 1%
801 \or% 11
802 \global\advance\gre@count@temp@three by 1%
803 \or% 12
804 \global\advance\gre@count@temp@three by -1%
805 \fi%
806 \fi%
807 \global\advance\gre@count@temp@three by -8 %
808 \global\gre@dimen@glyphraisevalue = \dimexpr(((\gre@dimen@interstafflinedistancebase + \gre@dimen@stafflinethicknessbase) / 2 ) * \gre@factor * \gre@count@temp@three)\relax %
809 \ifcase#2 %
810 \or\or\or%3: if it is a vertical episema on a line, we shift it a bit higher, so that it's more beautiful
811 \ifgre@isonaline%
812 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@vepisemahighshift\relax %
813 \else % if it is not on a line, we shift it a bit lower
814 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@vepisemalowshift\relax %
815 \fi %
816 \or% 4: if it is a punctum mora on a line, we shift it a bit lower, for the same reason
817 \ifgre@isonaline%
818 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@linepunctummorashift\relax %
819 \else %
820 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@spacepunctummorashift\relax %
821 \fi%
822 \or% 5: if it is a horizontal episema under a note which is on a line, we shift it lower
823 \ifcase#3\relax % 0 - auto
824 \ifgre@isonaline% if it is under a note between two lines, we shift it higher
825 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@underhepisemahighshift\relax %
826 \else %
827 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@underhepisemalowshift\relax %
828 \fi %
829 \or % 1 - middle
830 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@hepisemamiddleshift\relax %
831 \or % 2 - over-low
832 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@overhepisemalowshift\relax %
833 \or % 3 - over-high
834 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@overhepisemahighshift\relax %
835 \or % 4 - under-low
836 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@underhepisemalowshift\relax %
837 \or % 5 - under-high
838 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@underhepisemahighshift\relax %
839 \fi %
840 \or% 6: if it is a sign, we put it at an arbitrary height
841 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@raresignshift\relax %
842 \or\or% 8: if it is a punctum mora on a line, we shift it a bit lower, for the same reason
843 \ifgre@isonaline%
844 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@lineporrectuspunctummorashift\relax %
845 \else %
846 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@spaceporrectuspunctummorashift\relax %
847 \fi %
848 \or% 9: if it is an horizontal episema not on a line, we put it a bit lower
849 \ifcase#3\relax % 0 - auto
850 \ifgre@isonaline%
851 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@overhepisemalowshift\relax %
852 \else %
853 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@overhepisemahighshift\relax %
854 \fi %
855 \or % 1 - middle
856 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@hepisemamiddleshift\relax %
857 \or % 2 - over-low
858 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@overhepisemalowshift\relax %
859 \or % 3 - over-high
860 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@overhepisemahighshift\relax %
861 \or % 4 - under-low
862 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@underhepisemalowshift\relax %
863 \or % 5 - under-high
864 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@underhepisemahighshift\relax %
865 \fi %
866 \or% 10: low choral sign that is not lower than the note
867 \global\advance\gre@dimen@glyphraisevalue by -\gre@space@dimen@choralsigndownshift\relax%
868 \or% 11: high choral sign
869 \ifgre@isonaline%
870 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@choralsignupshift\relax%
871 \else %
872 \global\advance\gre@dimen@glyphraisevalue by -\gre@space@dimen@choralsigndownshift\relax%
873 \fi %
874 \or% 12: low choral sign that is lower than the note
875 \ifgre@isonaline%
876 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@choralsignupshift\relax%
877 \else %
878 \global\advance\gre@dimen@glyphraisevalue by -\gre@space@dimen@choralsigndownshift\relax%
879 \fi %
880 \or% 13: if it is the brace above the bars, we shift it to a user-defined value
881 \global\advance\gre@dimen@glyphraisevalue by -\gre@space@dimen@braceshift\relax%
882 \or% 14: raise the punctum mora in a space a bit higher than case 4
883 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@spaceamonepespunctummorashift\relax%
884 \or% 15: over slur
885 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@overslurshift\relax%
886 \or% 16: under slur
887 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@underslurshift\relax%
888 \or% 17: bracket
889 \ifgre@isonaline %
890 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@bracketupshift\relax%
891 \else %
892 \ifnum#1>\gre@pitch@belowstaff\relax % #1 is not below staff
893 \global\advance\gre@dimen@glyphraisevalue by -\gre@space@dimen@bracketdownshift\relax%
894 \else % #1 is below staff
895 \global\advance\gre@dimen@glyphraisevalue by \gre@space@dimen@bracketupshift\relax%
896 \fi %
897 \fi %
898 \fi%
899 \global\advance\gre@dimen@glyphraisevalue by \the\gre@dimen@constantglyphraise\relax%
900 \gre@trace@end%
901 }%
902
903 % two dimensions for the additionalspaces
904 \newdimen\gre@dimen@additionalbottomspace\relax%
905 % the one taken into account to adjust space between lines
906 \newdimen\gre@dimen@additionaltopspace\relax%
907 % the one taken into account for above lines text height
908 \newdimen\gre@dimen@additionaltopspacealt\relax%
909 % the one taken into account for above lines nabc height
910 \newdimen\gre@dimen@additionaltopspacenabc\relax%
911
912 \newcount\gre@space@count@additionaltopspacethreshold\relax%
913 \gre@space@count@additionaltopspacethreshold=2
914
915 \newcount\gre@space@count@additionaltopspacealtthreshold\relax%
916 \gre@space@count@additionaltopspacealtthreshold=0
917
918 \newcount\gre@space@count@additionaltopspacenabcthreshold\relax%
919 \gre@space@count@additionaltopspacenabcthreshold=4
920
921 \newcount\gre@space@count@noteadditionalspacelinestextthreshold\relax%
922 \gre@space@count@noteadditionalspacelinestextthreshold=2
923
924 \def\gre@num@min#1#2{%
925 \gre@trace{gre@num@min{#1}{#2}}%
926 \ifnum#1 < #2\relax %
927 \gre@count@temp@one=#1\relax %
928 \else %
929 \gre@count@temp@one=#2\relax %
930 \fi %
931 \gre@trace@end%
932 }%
933 \def\gre@num@max#1#2{%
934 \gre@trace{gre@num@max{#1}{#2}}%
935 \ifnum#1 > #2\relax %
936 \gre@count@temp@one=#1\relax %
937 \else %
938 \gre@count@temp@one=#2\relax %
939 \fi %
940 \gre@trace@end%
941 }%
942
943 % some backup demensions for use around discretionaries
944 \newdimen\gre@saved@prediscretionary@dimen@additionalbottomspace\relax%
945 \newdimen\gre@saved@prediscretionary@dimen@additionaltopspace\relax%
946 \newdimen\gre@saved@prediscretionary@dimen@additionaltopspacealt\relax%
947 \newdimen\gre@saved@prediscretionary@dimen@additionaltopspacenabc\relax%
948 \newdimen\gre@saved@prediscretionary@dimen@currenttranslationheight\relax%
949 \newdimen\gre@saved@prediscretionary@dimen@textlower\relax%
950 \newdimen\gre@saved@prediscretionary@dimen@currentabovelinestextheight\relax%
951 \newdimen\gre@saved@prediscretionary@dimen@constantglyphraise\relax%
952
953
954 \def\gre@save@additionalspaces{%
955 \gre@trace{gre@save@additionalspaces}%
956 \global\gre@saved@prediscretionary@dimen@additionalbottomspace=\gre@dimen@additionalbottomspace\relax%
957 \global\gre@saved@prediscretionary@dimen@additionaltopspace=\gre@dimen@additionaltopspace\relax%
958 \global\gre@saved@prediscretionary@dimen@additionaltopspacealt=\gre@dimen@additionaltopspacealt\relax%
959 \global\gre@saved@prediscretionary@dimen@additionaltopspacenabc=\gre@dimen@additionaltopspacenabc\relax%
960 \global\gre@saved@prediscretionary@dimen@currenttranslationheight=\gre@dimen@currenttranslationheight\relax%
961 \global\gre@saved@prediscretionary@dimen@textlower=\gre@dimen@textlower\relax%
962 \global\gre@saved@prediscretionary@dimen@currentabovelinestextheight=\gre@dimen@currentabovelinestextheight\relax%
963 \global\gre@saved@prediscretionary@dimen@constantglyphraise=\gre@dimen@constantglyphraise\relax%
964 \gre@trace@end%
965 }%
966
967 \def\gre@restore@additionalspaces{%
968 \gre@trace{gre@restore@additionalspaces}%
969 \global\gre@dimen@additionalbottomspace=\gre@saved@prediscretionary@dimen@additionalbottomspace\relax%
970 \global\gre@dimen@additionaltopspace=\gre@saved@prediscretionary@dimen@additionaltopspace\relax%
971 \global\gre@dimen@additionaltopspacealt=\gre@saved@prediscretionary@dimen@additionaltopspacealt\relax%
972 \global\gre@dimen@additionaltopspacenabc=\gre@saved@prediscretionary@dimen@additionaltopspacenabc\relax%
973 \global\gre@dimen@currenttranslationheight=\gre@saved@prediscretionary@dimen@currenttranslationheight\relax%
974 \global\gre@dimen@textlower=\gre@saved@prediscretionary@dimen@textlower\relax%
975 \global\gre@dimen@currentabovelinestextheight=\gre@saved@prediscretionary@dimen@currentabovelinestextheight\relax%
976 \global\gre@dimen@constantglyphraise=\gre@saved@prediscretionary@dimen@constantglyphraise\relax%
977 \gre@trace@end%
978 }%
979
980 \let\gre@pitch@cleftop\gre@pitch@dummy %
981 \let\gre@pitch@clefbottom\gre@pitch@dummy %
982
983 % #1 is the high height
984 % #2 is the low height
985 % #3 is 1 if there is a translation somewhere
986 % #4 is if 1 if we have space above the staff
987 \def\gre@calculate@additionalspaces#1#2#3#4{%
988 \gre@trace{gre@calculate@additionalspaces{#1}{#2}{#3}{#4}}%
989 \gre@num@max{#1}{\gre@pitch@cleftop}%
990 \gre@count@temp@one=\numexpr(\gre@count@temp@one - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacethreshold)\relax %
991 \ifnum\gre@count@temp@one>0\relax %
992 \global\gre@dimen@additionaltopspace=\dimexpr(((\gre@dimen@interstafflinedistancebase + \gre@dimen@stafflinethicknessbase) / 2 ) * \gre@count@temp@one * \gre@factor)\relax %
993 \else %
994 \global\gre@dimen@additionaltopspace=0 sp%
995 \fi %
996 \gre@num@max{#1}{\gre@pitch@cleftop}%
997 \gre@count@temp@one=\numexpr(\gre@count@temp@one - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacealtthreshold)\relax %
998 \ifnum\gre@count@temp@one>0\relax %
999 \global\gre@dimen@additionaltopspacealt=\dimexpr(((\gre@dimen@interstafflinedistancebase + \gre@dimen@stafflinethicknessbase) / 2 ) * \gre@count@temp@one * \gre@factor)\relax %
1000 \else %
1001 \global\gre@dimen@additionaltopspacealt=0 sp%
1002 \fi %
1003 \gre@num@max{#1}{\gre@pitch@cleftop}%
1004 \gre@count@temp@one=\numexpr(\gre@count@temp@one - \gre@pitch@adjust@top - \gre@space@count@additionaltopspacenabcthreshold)\relax %
1005 \ifnum\gre@count@temp@one>0\relax %
1006 \global\gre@dimen@additionaltopspacenabc=\dimexpr(((\gre@dimen@interstafflinedistancebase + \gre@dimen@stafflinethicknessbase) / 2 ) * \gre@count@temp@one * \gre@factor)\relax %
1007 \else %
1008 \global\gre@dimen@additionaltopspacenabc=0 sp%
1009 \fi %
1010 \gre@num@min{#2}{\gre@pitch@clefbottom}%
1011 \gre@count@temp@one=\numexpr(\gre@pitch@adjust@bottom - \gre@count@temp@one)\relax %
1012 \ifnum\gre@count@temp@one>0\relax %
1013 \ifgre@noteadditionalspacelinestext%
1014 \global\gre@dimen@additionalbottomspace=\dimexpr(\gre@space@dimen@noteadditionalspacelinestext * \gre@count@temp@one)\relax%
1015 \else%
1016 \global\gre@dimen@additionalbottomspace=\dimexpr(((\gre@dimen@interstafflinedistancebase + \gre@dimen@stafflinethicknessbase) / 2 ) * \gre@factor * \gre@count@temp@one)\relax%
1017 \fi%
1018 \else %
1019 \global\gre@dimen@additionalbottomspace=0 sp%
1020 \fi %
1021 \ifnum#3 = 1\relax %
1022 \gre@addtranslationspace %
1023 \else %
1024 \gre@removetranslationspace %
1025 \fi %
1026 \ifnum#4 = 1\relax %
1027 \gre@addspaceabove %
1028 \else %
1029 \gre@removespaceabove %
1030 \fi %
1031 \gre@generatelines %
1032 \gre@calculate@constantglyphraise %
1033 \relax %
1034 \gre@trace@end%
1035 }%
1036
1037 %% macro that typesets the text of the syllable, and sets textaligncenter to the middle of the middle letters, it is needed because we align the note (often the middle of the note) with the middle of the middle letters
1038 %% third argument is 0 if it's the current syllable, 1 if it's the alignment of the following one
1039 %% warning: gretextaligncenter is the width from the beginning of the letters to the middle of the middle letters
1040 %% warning: value is approximative when a ligature appears
1041
1042 \newdimen\gre@dimen@textaligncenter\relax%
1043
1044 \def\gre@calculate@textaligncenter#1#2#3#4{%
1045 \gre@trace{gre@calculate@textaligncenter{#1}{#2}{#3}{#4}}%
1046 \ifnum#4=0\relax%
1047 \gre@widthof{\gre@saved@syllable@fixedtextformat{#1}\gre@fixedtextformat{#2#3}}%
1048 \else %
1049 \gre@widthof{\gre@fixedtextformat{#1}\gre@fixednexttextformat{#2#3}}%
1050 \fi %
1051 \global\gre@dimen@textaligncenter=\the\gre@dimen@temp@three %
1052 \ifnum#4=0\relax%
1053 \gre@widthof{\gre@fixedtextformat{#3}}%
1054 \else %
1055 \gre@widthof{\gre@fixednexttextformat{#3}}%
1056 \fi %
1057 \divide\gre@dimen@temp@three by 2 %
1058 \global\advance\gre@dimen@textaligncenter by -\the\gre@dimen@temp@three%
1059 \relax%
1060 \gre@trace@end%
1061 }%
1062
1063 % a dimen that will contain the difference between the end of the text and the end of the notes for the previous syllable (if we are in the same word) : positive if notes go further than text. We will use it for space adjustment between syllables of the same word
1064 \newdimen\gre@dimen@enddifference\relax%
1065
1066 % a dimen that will contain the enddifference of the previous glyph
1067 \newdimen\gre@dimen@previousenddifference\relax%
1068
1069 % macro to set enddifference (defined above) to \wd\gre@box@syllablenotes - (\wd\gre@box@syllabletext - textaligncenter) - notesaligncenter
1070 % enddifference will be positive if text go further than the notes, and negative in the other case
1071 % arguments are :
1072 % #1: \wd\gre@box@syllablenotes : the total width of the notes
1073 % #2: \wd\gre@box@syllabletext : the total width of the text
1074 % #3: textaligncenter (defined above)
1075 % #4: notesaligncenter (defined above too)
1076 % #5: if we have to set previousenddifference or not
1077 \def\gre@calculate@enddifference#1#2#3#4#5{%
1078 \gre@trace{gre@calculate@enddifference{#1}{#2}{#3}{#4}{#5}}%
1079 \ifcase#5\or %
1080 \global\gre@dimen@previousenddifference=\the\gre@dimen@enddifference\relax%
1081 \fi %
1082 \global\gre@dimen@enddifference=\dimexpr(#1 - #2 + #3 - #4)\relax%
1083 \relax%
1084 \gre@trace@end%
1085 }%
1086
1087 % temporary value for space for the translation, beneath the text
1088 \newdimen\gre@dimen@currenttranslationheight\relax%
1089
1090 % macro to tell gregorio to set space for the translation
1091 \def\gre@addtranslationspace{%
1092 \gre@trace{gre@addtranslationspace}%
1093 \gre@style@translation%
1094 \global\gre@dimen@currenttranslationheight=\gre@space@dimen@translationheight\relax%
1095 \global\gre@dimen@textlower=\dimexpr(\gre@space@dimen@spacebeneathtext %
1096 + \gre@space@dimen@translationheight)\relax%
1097 \endgre@style@translation%
1098 \relax %
1099 \gre@trace@end%
1100 }%
1101
1102 \def\gre@removetranslationspace{%
1103 \gre@trace{gre@removetranslationspace}%
1104 \global\gre@dimen@currenttranslationheight=0 sp%
1105 \global\gre@dimen@textlower=\gre@space@dimen@spacebeneathtext\relax%
1106 \relax %
1107 \gre@trace@end%
1108 }%
1109
1110 %nextbegindifference is the begindifference of the next syllable
1111 \newskip\gre@skip@nextbegindifference\relax%
1112
1113 % macro to set nextbegindifference
1114 %% 1 : the carry-over letters for the next syllable
1115 %% 2 : the first letters of the next syllable
1116 %% 3 : the middle letters of the next syllable
1117 %% 4 : the end letters of the next syllable
1118 %% 5 : the type of notes alignment
1119 %% 6 : alteration type (see \gre@alteration)
1120 \def\gre@calculate@nextbegindifference#1#2#3#4#5#6{%
1121 \gre@trace{gre@calculate@nextbegindifference{#1}{#2}{#3}{#4}{#5}{#6}}%
1122 \ifnum\gre@lastoflinecount=1\relax %
1123 \global\gre@skip@nextbegindifference=0pt\relax%
1124 \else %
1125 %to prevent the pollution of the normal values, we stock them into a temp value
1126 \gre@dimen@temp@two=\gre@dimen@textaligncenter\relax%
1127 \gre@calculate@textaligncenter{#1}{#2}{#3}{1}%
1128 \gre@dimen@temp@four=\gre@dimen@notesaligncenter\relax%
1129 \global\gre@skip@nextbegindifference=-\gre@dimen@textaligncenter\relax%
1130 % caution: calculate@nextnotesaligncenter needs a properly set \gre@dimen@textaligncenter
1131 % (corresponding to the text align center of the next syllable)
1132 \gre@calculate@nextnotesaligncenter{#5}{#6}% idem
1133 \global\advance\gre@skip@nextbegindifference by \the\gre@dimen@notesaligncenter\relax%
1134 \global\gre@dimen@textaligncenter=\gre@dimen@temp@two %
1135 \global\gre@dimen@notesaligncenter=\gre@dimen@temp@four %
1136 \fi %
1137 \relax %
1138 \gre@trace@end%
1139 }%
1140
1141 %The distance from the baseline of the line to the baseline of the annotations
1142 \newdimen\gre@dimen@annotationtrueraise\relax%
1143 % When text is placed in the annotation boxes these dimensions are initialized with values based on the contents and the user parameters
1144 %This function sets the true raises of the two lines above the initial (it has to be called just as the boxes are placed in order to make sure that the values are all correct)
1145 \def\gre@calculate@annotationtrueraise{%
1146 \gre@trace{gre@calculate@annotationtrueraise}%
1147 \global\advance\gre@dimen@annotationtrueraise by %
1148 \dimexpr(\gre@dimen@staffheight %
1149 + \gre@space@dimen@spacebeneathtext %
1150 + \gre@dimen@currenttranslationheight %
1151 + \gre@space@dimen@spacelinestext %
1152 + \gre@dimen@additionalbottomspace)\relax%
1153 \gre@style@annotation%
1154 \global\advance\gre@dimen@annotationtrueraise by \gre@space@dimen@annotationraise\relax%
1155 \gre@debugmsg{annotation}{Added user raise.}%
1156 \endgre@style@annotation%
1157 \relax %
1158 \gre@trace@end%
1159 }%
1160
1161 %The distance from the baseline of the line to the baseline of the commentary
1162 \newdimen\gre@dimen@commentarytrueraise\relax%
1163 %This function sets the true raises of the commentary (it has to be called just as the boxes are placed in order to make sure that the values are all correct)
1164 \def\gre@calculate@commentarytrueraise{%
1165 \gre@trace{gre@calculate@commentarytrueraise}%
1166 \gre@style@commentary%
1167 \gre@debugmsg{commentary}{Calculating the raise.}%
1168 \global\advance\gre@dimen@commentarytrueraise by %
1169 \dimexpr(\gre@dimen@staffheight %
1170 + \gre@space@dimen@spacebeneathtext %
1171 + \gre@dimen@currenttranslationheight %
1172 + \gre@space@dimen@spacelinestext %
1173 + \gre@dimen@additionalbottomspace %
1174 + \gre@space@dimen@commentaryraise)\relax%
1175 \endgre@style@commentary%
1176 \gre@trace@end%
1177 }%
1178
1179 % spaces for new bar positioning algorithm
1180 \newskip\gre@skip@bar@requirement% amount of space required by bar (including skips before and after)
1181 \newskip\gre@skip@bar@allocation% amount of space allocated to the bar
1182 \newdimen\gre@dimen@bar@shift% displacement from center of the bar’s position
1183 \newskip\gre@skip@text@requirement% amount of space required by the text (including skips before and after)
1184 \newskip\gre@skip@text@allocation% amount of space allocated to the text
1185 \newdimen\gre@dimen@text@shift% displacement from center of the text’s position
1186 \newdimen\gre@dimen@adjustedpreviousenddifference% previousenddifference adjusted to account for the presence of a punctum mora at the end of the pervious syllable
1187 \newdimen\gre@skip@adjustednextbegindifference% idem, nextbegindifference taking into account the presence of an alteration at the beginning of next syllable
1188 \newskip\gre@skip@punctummorashift% displacement of whole syllable to account for the presence of a punctum mora at the end of the previous syllable
1189 \newskip\gre@skip@alterationshift % idem for alteration at the beginning of next syllable
1190
1191 %
1192 % New bar spacing algorithm
1193 %
1194 %In the new algorithm the bar and the text are set independently of each other based purely on the positions of the corresponding element in the previous and next syllable
1195 % #1 is #4 from \GreBarSyllable (1 if bar is end of word, 0 if not)
1196 % #2 is #7:2 from \GreBarSyllable (alteration type of first next glyph)
1197 \def\gre@calculate@barposition#1#2{%
1198 \gre@trace{gre@calculate@barposition{#1}{#2}}%
1199 % we start by finding the distance between the text and notes of the previous and the next syllable (as if this syllable didn't exist, for the moment)
1200 \gre@debugmsg{barspacing}{calculate available space}%
1201 % first, recomputing \gre@dimen@previousenddifference into \gre@dimen@adjustedpreviousenddifference
1202 \gre@punctummoraadjustment%
1203 % recomputing \gre@dimen@nextbegindifference into \gre@dimen@adjustednextdifference
1204 \gre@alterationadjustment{#2}%
1205 \ifdim\gre@dimen@adjustedpreviousenddifference > 0pt\relax%
1206 % the notes ended after the text in the previous syllable
1207 \gre@skip@text@allocation = \gre@dimen@adjustedpreviousenddifference\relax%
1208 \gre@skip@bar@allocation = 0pt\relax%
1209 \else%
1210 % the text ended after the notes in the previous syllable
1211 \gre@skip@text@allocation = 0pt\relax%
1212 \gre@skip@bar@allocation = -\gre@dimen@adjustedpreviousenddifference\relax%
1213 \fi%
1214 \ifdim\gre@skip@adjustednextbegindifference > 0pt\relax%
1215 % the text began after the notes in the next syllable
1216 \advance\gre@skip@text@allocation by \gre@skip@adjustednextbegindifference\relax%
1217 \advance\gre@skip@bar@allocation by 0pt\relax%
1218 \else%
1219 % the notes begin after the text in the next syllable
1220 \advance\gre@skip@text@allocation by 0pt\relax%
1221 \advance\gre@skip@bar@allocation by -\gre@skip@adjustednextbegindifference\relax%
1222 \fi%
1223 \gre@debugmsg{barspacing}{space available to text: \the\gre@skip@text@allocation}%
1224 \gre@debugmsg{barspacing}{spacing available to notes: \the\gre@skip@bar@allocation}%
1225 % now we need to check these widths against the width the current syllable needs for each element and increase them as necessary
1226 % if they aren't wide enough, then we need to increase *both* widths
1227 \gre@debugmsg{barspacing}{calculate required widths}%
1228 % first we check the text width
1229 % we have to account for the spacing around the text as well as the text itself
1230 \ifdim\wd\gre@box@syllabletext > 0pt\relax%
1231 % first we account for the spacing which is needed after the previous syllable text (by using the minTextDistance left over from the previous syllablefinalskip calculation)
1232 \gre@debugmsg{barspacing}{text width: \the\wd\gre@box@syllabletext}%
1233 \gre@debugmsg{barspacing}{previous syllable skip after text: \the\gre@skip@minTextDistance}%
1234 \gre@skip@text@requirement = \glueexpr\wd\gre@box@syllabletext + \gre@skip@minTextDistance\relax%
1235 %now we need to account for the spacing which goes after this syllable (if there is text to this syllable)
1236 %this calculation is similar to what is done in \gre@calculate@syllablefinalskip, but is only for the text, so we'll use \gre@skip@syllablefinalskip to hold this value for now
1237 \ifnum#1=1\relax %
1238 \ifgre@in@euouae %
1239 \gre@skip@syllablefinalskip=\gre@space@dimen@interwordspacetext@bars@euouae\relax%
1240 \else %
1241 \gre@skip@syllablefinalskip=\gre@space@dimen@interwordspacetext@bars\relax%
1242 \fi %
1243 \else %
1244 \gre@skip@syllablefinalskip=0pt\relax%
1245 \fi %
1246 \gre@debugmsg{barspacing}{this syllable skip after text: \the\gre@skip@syllablefinalskip}%
1247 \advance\gre@skip@text@requirement by \gre@skip@syllablefinalskip\relax%
1248 \else%
1249 \ifnum#1=1\relax%
1250 \ifgre@in@euouae%
1251 \gre@skip@text@requirement=\gre@space@dimen@interwordspacetext@bars@notext@euouae\relax%
1252 \else%
1253 \gre@skip@text@requirement=\gre@space@dimen@interwordspacetext@bars@notext\relax%
1254 \fi%
1255 \else%
1256 \gre@skip@text@requirement=0pt\relax%
1257 \fi%
1258 \fi%
1259 \ifdim\gre@skip@text@allocation < \gre@skip@text@requirement\relax%
1260 \advance\gre@skip@bar@allocation by \glueexpr(\gre@skip@text@requirement - \gre@skip@text@allocation)\relax%
1261 \gre@skip@text@allocation = \gre@skip@text@requirement\relax%
1262 \fi%
1263 \gre@debugmsg{barspacing}{space required by text: \the\gre@skip@text@requirement}%
1264 \gre@debugmsg{barspacing}{allocated text space: \the\gre@skip@text@allocation}%
1265 \gre@debugmsg{barspacing}{allocated notes space: \the\gre@skip@bar@allocation}%
1266 % now we check the bar width
1267 \gre@skip@bar@requirement = \wd\gre@box@syllablenotes\relax%
1268 \ifdim\gre@skip@bar@requirement=0pt\relax % no notes
1269 \gre@skip@bar@requirement=\gre@space@skip@interwordspacenotes %
1270 \fi %
1271 \gre@debugmsg{barspacing}{bar width: \the\gre@skip@bar@requirement}%
1272 \ifdim\gre@skip@bar@allocation < \gre@skip@bar@requirement\relax%
1273 \advance\gre@skip@text@allocation by \glueexpr(\gre@skip@bar@requirement - \gre@skip@bar@allocation)\relax%
1274 \gre@skip@bar@allocation = \gre@skip@bar@requirement\relax%
1275 \fi%
1276 \gre@debugmsg{barspacing}{required space for notes: \the\gre@skip@bar@requirement}%
1277 \gre@debugmsg{barspacing}{allocated text space: \the\gre@skip@text@allocation}%
1278 \gre@debugmsg{barspacing}{allocated notes space: \the\gre@skip@bar@allocation}%
1279 % our final position calculation is to make sure that the centers of the text and the bar are not too far from each other
1280 % this isn't really the begindifference (it doesn't account for the width of the text and the bar), but it's close enough that we'll use that register for this calculation
1281 % to be consistent with the normal begin difference, this value should take us from the middle of the notes to the middle of the text.
1282 \gre@dimen@begindifference=\dimexpr(-\gre@skip@bar@allocation/2% going to the left by the bar@allocation/2 (an always positive value, so we lead with a minus sign to go left)
1283 -\gre@dimen@adjustedpreviousenddifference% moving from the end of the notes in the previous syllable to the end of the text there (opposite the sense of enddifference so we lead with a minus sign)
1284 +\gre@skip@text@allocation/2)\relax% going to the right by the text@allocation/2 (an always positive value, so lead with positive to go right)
1285 \gre@debugmsg{barspacing}{new begindifference approximation: \the\gre@dimen@begindifference}%
1286 % in order to avoid code duplication, we check whether or not there is a bar line now and set temp variables to the appropriate offset limits. We’ll then use those temp variables in the code below.
1287 \ifdim\wd\gre@box@syllablenotes = 0pt\relax%
1288 \gre@debugmsg{barspacing}{no bar offset limits}%
1289 \gre@dimen@temp@three=\gre@space@dimen@maxbaroffsettextleft@nobar\relax%
1290 \gre@dimen@temp@two=\gre@space@dimen@maxbaroffsettextright@nobar\relax%
1291 \else%
1292 \gre@debugmsg{barspacing}{normal offset limits}%
1293 \gre@dimen@temp@three=\gre@space@dimen@maxbaroffsettextleft\relax%
1294 \gre@dimen@temp@two=\gre@space@dimen@maxbaroffsettextright\relax%
1295 \fi%
1296 % in the event that the bar is occurring at the end of the line, we use different offset limits
1297 % for now this only works for explicit end of lines which occur in the same syllable as the bar line (e.g. `test(::z)`)
1298 \ifnum\gre@newlinearg=-1\relax\else%
1299 \gre@debugmsg{barspacing}{end of line override on offset limits}%
1300 \gre@dimen@temp@three=\gre@space@dimen@maxbaroffsettextleft@eol\relax%
1301 \gre@dimen@temp@two=\gre@space@dimen@maxbaroffsettextright@eol\relax%
1302 \fi%
1303 % If the bar syllable is to be cleared from overlapping the previous syllable then we force the text and bar to be exactly aligned.
1304 \ifgre@textcleared%
1305 \gre@dimen@temp@three=0pt\relax%
1306 \gre@dimen@temp@two=0pt\relax%
1307 \fi%
1308 \gre@debugmsg{barspacing}{left offset limit: \the\gre@dimen@temp@three}%
1309 \gre@debugmsg{barspacing}{right offset limit: \the\gre@dimen@temp@two}%
1310 % All this worry about shifts is superfluous if the text isn’t present,
1311 % so now we check for that and set them to 0 if it is missing
1312 \ifdim\wd\gre@box@syllabletext = 0pt\relax%
1313 \gre@debugmsg{barspacing}{no text, shifts set to 0}%
1314 \gre@dimen@text@shift = 0pt\relax%
1315 \gre@dimen@bar@shift = 0pt\relax%
1316 \else%
1317 \ifdim\gre@dimen@begindifference > \gre@dimen@temp@two\relax%
1318 %the two elements are too far apart and the text is to the right of the bar
1319 \gre@debugmsg{barspacing}{shifts for text right of bar}%
1320 % first we shift text to the left so that it has the correct offset
1321 \gre@dimen@bar@shift = 0pt\relax%
1322 \gre@dimen@text@shift = \dimexpr(0pt - (\gre@dimen@begindifference - \gre@dimen@temp@two))\relax%
1323 % is the text too far to the left?
1324 \ifdim-\gre@dimen@text@shift > \dimexpr(\gre@skip@text@allocation/2-\gre@skip@text@requirement/2)\relax%
1325 % it is, so push both bar and text right to prevent a collision
1326 \gre@debugmsg{barspacing}{text collision detected}%
1327 \gre@dimen@bar@shift = \dimexpr(-\gre@dimen@text@shift-(\gre@skip@text@allocation/2-\gre@skip@text@requirement/2))\relax %
1328 \gre@dimen@text@shift = \dimexpr(0pt - (\gre@skip@text@allocation/2 - \gre@skip@text@requirement/2))\relax %
1329 % is the bar too far to the right?
1330 % \gre@dimen@temp@one is excess shift
1331 \gre@dimen@temp@one = \dimexpr\gre@dimen@bar@shift - (\gre@skip@bar@allocation/2 - \gre@skip@bar@requirement/2)\relax%
1332 \ifdim\gre@dimen@temp@one>0pt\relax %
1333 \gre@debugmsg{barspacing}{bar collision detected}%
1334 % it is, so allocate more space to prevent the collision
1335 \advance\gre@skip@bar@allocation by \gre@dimen@temp@one\relax %
1336 % since the additional allocation will be split evenly on both sides of the bar, we also need to shift both elements left so that all of it will appear on the right hand side
1337 \advance\gre@dimen@bar@shift by -0.5\gre@dimen@temp@one\relax%
1338 \advance\gre@dimen@text@shift by -0.5\gre@dimen@temp@one\relax%
1339 \fi %
1340 \fi%
1341 \else\ifdim-\gre@dimen@begindifference > \gre@dimen@temp@three\relax%
1342 %the two elements are too far apart and the text is to the left of the bar
1343 \gre@debugmsg{barspacing}{shifts for text to left of bar}%
1344 % first we shift text to the right so that it has the correct offset
1345 \gre@dimen@bar@shift = 0pt\relax %
1346 \gre@dimen@text@shift = \dimexpr((-\gre@dimen@begindifference) - \gre@dimen@temp@three)\relax %
1347 % is the text too far to the right?
1348 \ifdim\gre@dimen@text@shift > \dimexpr(\gre@skip@text@allocation/2-\gre@skip@text@requirement/2)\relax %
1349 \gre@debugmsg{barspacing}{text collision detected}%
1350 % it is so push both bar and text left to prevent a collision
1351 \gre@dimen@bar@shift = \dimexpr(-\gre@dimen@text@shift+\gre@skip@text@allocation/2-\gre@skip@text@requirement/2)\relax %
1352 \gre@dimen@text@shift = \dimexpr(\gre@skip@text@allocation/2-\gre@skip@text@requirement/2)\relax %
1353 % is the bar too far to the left?
1354 % gre@dimen@temp@one is the excess of bar@shift:
1355 \gre@dimen@temp@one=\dimexpr(-\gre@dimen@bar@shift -(\gre@skip@bar@allocation/2-\gre@skip@bar@requirement/2))\relax %
1356 \ifdim\gre@dimen@temp@one>0pt\relax %
1357 \gre@debugmsg{barspacing}{bar collision detected}%
1358 % it is, so allocate more space to prevent the collision
1359 \advance\gre@skip@bar@allocation by \gre@dimen@temp@one\relax %
1360 % since the allocation will be split evenly on either side of the bar, we also need to shift both bar an text right by half of the increase so all of it appears on the left side
1361 \advance\gre@dimen@bar@shift by 0.5\gre@dimen@temp@one\relax%
1362 \advance\gre@dimen@text@shift by 0.5\gre@dimen@temp@one\relax%
1363 \fi %
1364 \fi %
1365 \else%
1366 %the two elements are sufficiently close together
1367 \gre@debugmsg{barspacing}{zero shifts}%
1368 \gre@dimen@text@shift = 0pt\relax%
1369 \gre@dimen@bar@shift = 0pt\relax%
1370 \fi\fi%
1371 \fi%
1372 \gre@debugmsg{barspacing}{text shift: \the\gre@dimen@text@shift}%
1373 \gre@debugmsg{barspacing}{bar shift: \the\gre@dimen@bar@shift}%
1374 %at this point we're going to correct the values of enddifference and begindifference so that they are right for calculations which reference them in the next syllable
1375 \gre@debugmsg{barspacing}{bar width: \the\wd\gre@box@syllablenotes}%
1376 \gre@debugmsg{barspacing}{text width: \the\wd\gre@box@syllabletext}%
1377 \gre@debugmsg{barspacing}{Correcting begindifference}%
1378 %same as before but now we need to account for the widths of the elements and the shifts
1379 \gre@dimen@begindifference = \dimexpr(\wd\gre@box@syllablenotes/2% go right to the middle of the bar syllable (width is always positive so lead with plus to go right)
1380 -\gre@dimen@bar@shift% go from actual middle of bar to nominal middle of bar (bar@shift represents going the other way, so lead with minus)
1381 +\gre@dimen@begindifference% go from nominal middle of bar line to nominal middle of text (this is what begindifference currently holds, so lead with positive)
1382 +\gre@dimen@text@shift% go from nominal middle of text to actual middle of text (text@shift represents this move, so lead with positive)
1383 -\wd\gre@box@syllabletext/2)\relax% go left from middle to beginning of text (width is always positive, so lead with negative to go left
1384 \gre@debugmsg{barspacing}{begindifference: \the\gre@dimen@begindifference}%
1385 \gre@debugmsg{barspacing}{Correcting enddifference}%
1386 \gre@dimen@enddifference = \dimexpr-\wd\gre@box@syllabletext% go from end of text to beginning of text (width is always positive, so lead with negative to go left)
1387 -\gre@dimen@begindifference% go from beginning of text to beginning of notes (opposite sense of begindifference so lead with negative)
1388 +\wd\gre@box@syllablenotes\relax% go from beginning of notes to end of notes (width is always positive so lead with positive to go right
1389 \gre@debugmsg{barspacing}{enddifference: \the\gre@dimen@enddifference}%
1390 %we also need to correct syllablefinalskip to make sure it’s accurate because it depends on enddifference
1391 \gre@debugmsg{barspacing}{Correcting syllablefinalskip}%
1392 \gre@calculate@syllablefinalskip{#1}{\gre@count@temp@one}%
1393 \gre@debugmsg{barspacing}{syllablefinalskip: \the\gre@skip@syllablefinalskip}%
1394 \gre@trace@end%
1395 }%
1396
1397 % alteration adjustment calculations
1398 \def\gre@alterationadjustment#1{%
1399 \gre@trace{gre@alterationadjustment{#1}}%
1400 % taking into account the punctum mora shift
1401 \global\gre@skip@adjustednextbegindifference=\gre@skip@nextbegindifference %
1402 % gre@skip@alterationshift is 0 or the punctum mora shift
1403 \global\gre@skip@alterationshift=0pt\relax %
1404 \ifnum#1>0\ifnum\gre@insidediscretionary=0\relax % next is a flat, we're not in a clef change
1405 \advance\gre@skip@adjustednextbegindifference by -\gre@space@dimen@alterationadjustmentbar %
1406 \global\gre@skip@alterationshift=\gre@space@dimen@alterationadjustmentbar\relax %
1407 \gre@debugmsg{barspacing}{adjustment for alteration: \gre@space@dimen@alterationadjustmentbar}%
1408 \gre@debugmsg{barspacing}{adjusted next begindifference (for alteration): \the\gre@skip@adjustednextbegindifference}%
1409 \fi\fi %
1410 \gre@trace@end%
1411 }
1412
1413 %punctum mora adjustment calculations for bars
1414 \def\gre@punctummoraadjustment{%
1415 \gre@trace{gre@punctummoraadjustment}%
1416 % taking into account the punctum mora shift
1417 \global\gre@dimen@adjustedpreviousenddifference=\gre@dimen@previousenddifference %
1418 % gre@skip@punctummorashift is 0 or the punctum mora shift
1419 \gre@skip@punctummorashift=0pt\relax %
1420 \ifgre@lastendswithmora %
1421 \ifcase\gre@count@shiftaftermora\or\or %
1422 \ifdim\wd\gre@box@syllabletext=0pt\relax %
1423 % punctum mora adjustment should occur only for bars with no text
1424 \gre@get@unkern@aftermora{2}%
1425 \advance\gre@dimen@adjustedpreviousenddifference by \gre@skip@punctummorashift %
1426 \fi %
1427 \or %
1428 % punctum mora adjustment only before bars
1429 \gre@get@unkern@aftermora{2}%
1430 \advance\gre@dimen@adjustedpreviousenddifference by \gre@skip@punctummorashift %
1431 \or\or %
1432 % punctum mora adjustment always occurs
1433 \gre@get@unkern@aftermora{2}%
1434 \advance\gre@dimen@adjustedpreviousenddifference by \gre@skip@punctummorashift %
1435 \fi %
1436 \fi %
1437 % now something a bit tricky: as we changed previousenddifference,
1438 % we must kern of the difference we created, but no more than
1439 % the end of the text:
1440 \ifdim\gre@skip@punctummorashift=0pt\else %
1441 \gre@debugmsg{barspacing}{adjustment for punctum mora: \the\gre@skip@punctummorashift}%
1442 \gre@debugmsg{barspacing}{adjusted previous enddifference (for punctum mora): \the\gre@dimen@adjustedpreviousenddifference}%
1443 \ifdim -\gre@skip@punctummorashift < \gre@dimen@previousenddifference %
1444 \gre@debugmsg{barspacing}{kern \the\gre@skip@punctummorashift for punctum mora adjustment}%
1445 \kern\gre@skip@punctummorashift %
1446 \else %
1447 \ifdim\gre@dimen@previousenddifference > 0pt\relax %
1448 \gre@debugmsg{barspacing}{kern \the\gre@dimen@previousenddifference for punctum mora adjustment}%
1449 \kern-\gre@dimen@previousenddifference %
1450 \fi %
1451 \fi %
1452 \fi %
1453 \gre@trace@end%
1454 }%
1455
1456 % Clearing a syllable so it doesn't overlap with the previous one
1457 \def\gre@clearsyllable#1{%
1458 \gre@trace{gre@clearsyllable{#1}}%
1459 % because the way mora shifts are implemented is different for bars and
1460 % notes, we have to use a different set of dimensions depending on which
1461 % kind of syllable we're dealing with. We know this by looking at the
1462 % argument of this function, which should be 'bar' for a bar syllable and 'note'
1463 % for a note syllable.
1464 \IfStrEq{#1}{bar}%
1465 {%
1466 \gre@debugmsg{clear}{adjustedpreviousenddifference = \the\gre@dimen@adjustedpreviousenddifference}%
1467 \gre@dimen@temp@one=\gre@dimen@adjustedpreviousenddifference%
1468 }%
1469 {%
1470 \gre@debugmsg{clear}{previousenddifference = \the\gre@dimen@previousenddifference}%
1471 \gre@dimen@temp@one=\gre@dimen@previousenddifference%
1472 }%
1473 \gre@debugmsg{clear}{begindifference = \the\gre@dimen@begindifference}%
1474 \gre@debugmsg{clear}{syllablefinalskip = \the\gre@skip@syllablefinalskip}%
1475 \ifdim\gre@dimen@temp@one > 0pt\relax%
1476 \ifdim\gre@dimen@begindifference < 0pt\relax%
1477 \ifdim\gre@dimen@temp@one > -\gre@dimen@begindifference\relax%
1478 \gre@debugmsg{clear}{Case 1}%
1479 \kern -\gre@dimen@begindifference\relax%
1480 \else%
1481 \gre@debugmsg{clear}{Case 2}%
1482 \kern \gre@dimen@temp@one\relax%
1483 \fi%
1484 \IfStrEq{#1}{note}%
1485 {% when dealing with notes we may have already skipped
1486 % forward some, in which case we need to account for that
1487 \ifdim\gre@skip@syllablefinalskip > 0pt\relax%
1488 \gre@debugmsg{clear}{undo syllablefinalskip}%
1489 \kern -\gre@skip@syllablefinalskip\relax%
1490 \fi%
1491 }{}%
1492 \else%
1493 \gre@debugmsg{clear}{Syllable already clear}%
1494 \fi%
1495 \else%
1496 \ifdim\gre@dimen@begindifference > 0pt\relax%
1497 \ifdim-\gre@dimen@temp@one > \gre@dimen@begindifference\relax%
1498 \gre@debugmsg{clear}{Case 3}%
1499 \kern \gre@dimen@begindifference\relax%
1500 \else%
1501 \gre@debugmsg{clear}{Case 4}%
1502 \kern -\gre@dimen@temp@one\relax%
1503 \fi%
1504 \IfStrEq{#1}{note}%
1505 {% when dealing with notes we may have already skipped
1506 % forward some, in which case we need to account for that
1507 \ifdim\gre@skip@syllablefinalskip > 0pt\relax%
1508 \gre@debugmsg{clear}{undo syllablefinalskip}%
1509 \kern -\gre@skip@syllablefinalskip\relax%
1510 \fi%
1511 }{}%
1512 \else%
1513 \gre@debugmsg{clear}{Syllable already clear}%
1514 \fi%
1515 \fi%
1516 \gre@trace@end%
1517 }%
1518
1519 %%%%%%%%%%%%%%%%%%%
1520 %% other spaces calculated elsewhere
1521 %%%%%%%%%%%%%%%%%%%
1522
1523 % These distances don't have independent functions which calculate their value, generally because their calculation is distributed over multiple events.
1524
1525 % begindifference is the difference between the beginning of the text and the beginning of the notes. Warning : it can be negative.
1526 \newdimen\gre@dimen@begindifference\relax%
1527
1528 % the width of the last glyph
1529 \newdimen\gre@dimen@lastglyphwidth\relax%
1530
1531 % notes align center is the point of alignment for the notes
1532 \newdimen\gre@dimen@notesaligncenter\relax%
1533
1534 % the calculated width of the initial (may be actual width of letter or be forced wider under certain conditions)
1535 \newdimen\gre@dimen@initialwidth\relax%
1536 \gre@dimen@initialwidth= 0 pt\relax%
1537
1538 \newdimen\gre@dimen@currentabovelinestextheight\relax%
1539 \gre@dimen@currentabovelinestextheight = 0pt\relax%
1540
1541 %% TODO: perhaps create a pair of functions which “reserve” and “release” the temporary registers in order to keep track of which ones are in use when. There would also need to be a list of the registers currently in use. The reserve function would then check the list to make sure the requested register isn’t already in use, throwing an error if it is and adding its name to the list if it isn’t. It might also provide for an alias (via \let). The release function would simply remove the register from the list of those in use.
1542 % Register allocation is an inherently global process in TeX. Below are the registers used within calculations on a temporary basis.
1543 \newdimen\gre@dimen@temp@one%
1544 \newdimen\gre@dimen@temp@two%
1545 \newdimen\gre@dimen@temp@three%
1546 \newdimen\gre@dimen@temp@four%
1547 \newdimen\gre@dimen@temp@five%
1548
1549 \newskip\gre@skip@temp@one%
1550 \newskip\gre@skip@temp@two %
1551 \newskip\gre@skip@temp@three%
1552 \newskip\gre@skip@temp@four%
1553
1554 \newcount\gre@count@temp@one%
1555 \newcount\gre@count@temp@two%
1556 \newcount\gre@count@temp@three%
1557
1558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1559 %% dimension changing macros
1560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1561
1562 %% This macro creates one dim (#1), setting its value to #2 and sets whether it should scale when the \gre@factor changes (#3, scalable or fixed). Checks that #1 can accept the kind of distance given in #2.
1563 %% Note: the distances created by this function are stored as strings, not skip or dimension registers. This allows the user to specify a distance in em or ex units even though the font parameters may not be the same at the time the distance is specified and the time the distance is used.
1564 \newif\ifgre@checklength%
1565 \def\gre@createdim#1#2#3{%
1566 \csname newif\expandafter\endcsname\csname ifgre@scale@#1\endcsname%
1567 \IfStrEqCase{#3}{%
1568 {scalable}%
1569 {\grescaledim{#1}{true}}%
1570 {fixed}%
1571 {\grescaledim{#1}{false}}%
1572 {inherited}%
1573 {\grescaledim{#1}{false}}%
1574 }[% all other cases
1575 \gre@error{Unrecognized option "#3" for \protect\gre@createdim\MessageBreak Possible options are: 'scalable' and 'fixed' and 'inherited'}%
1576 ]%
1577 \gre@dimension{#1}{#2}{#3}%
1578 }%
1579
1580
1581 % a macro for changing a dimension. Unlike \grecreatedim, this function won’t create a new distance, just change an existing one.
1582 \def\grechangedim#1#2#3{%
1583 \gre@rubberpermit{#1}%
1584 % figure out our prefix
1585 \ifgre@rubber%
1586 \gre@debugmsg{spacing}{Changing a skip.}%
1587 \def\gre@prefix{skip}%
1588 \else%
1589 \gre@debugmsg{spacing}{Changing a dimen.}%
1590 \def\gre@prefix{dimen}%
1591 \fi%
1592 \ifcsname gre@space@\gre@prefix @#1\endcsname%
1593 \gre@debugmsg{spacing}{It does exist.}%
1594 \IfStrEqCase{#3}{%
1595 {scalable}%
1596 {\grescaledim{#1}{true}}%
1597 {fixed}%
1598 {\grescaledim{#1}{false}}%
1599 {inherited}%
1600 {%
1601 \gre@rubberpermit{#2}%
1602 \ifgre@rubber%
1603 \def\gre@prefixII{skip}%
1604 \else%
1605 \def\gre@prefixII{dimen}%
1606 \fi%
1607 \ifcsname gre@space@\gre@prefixII @#2\endcsname%
1608 \grescaledim{#1}{false}%
1609 \else%
1610 \gre@error{'#1' cannot inherit from '#2'\MessageBreak Please make sure '#2' is a valid GregorioTeX distance}%
1611 \fi%
1612 }%
1613 % all other cases
1614 }[\gre@error{Unrecognized option "#3" for \protect\grechangedim\MessageBreak Possible options are: 'scalable', 'fixed', and 'inherited'}]%
1615 \gre@dimension{#1}{#2}{#3}%
1616 %If we are calling grechangedim from a space configuration file (greconffactor is not 0)
1617 % and the space configuration file is designed for a \gre@factor other than the current
1618 % one, then we need to rescale the distance being changed.
1619 \ifnum\greconffactor=0\else%
1620 \ifnum\the\gre@factor=\greconffactor\else%
1621 \gre@changeonedimenfactor{#1}{\greconffactor}{\gre@factor} %
1622 \fi%
1623 \fi%
1624 \else%
1625 \gre@error{#1 is not a recognized distance.}%
1626 \fi%
1627 }%
1628
1629 \def\grechangecount#1#2{%
1630 \expandafter\csname gre@space@count@#1\endcsname=#2%
1631 \relax %
1632 }
1633
1634 % The common internals for \grecreatedim and \grechangedim.
1635 \def\gre@dimension#1#2#3{%
1636 \gre@trace{gre@dimension{#1}{#2}{#3}}%
1637 \IfStrEq{#3}{inherited}{%
1638 \gre@debugmsg{spacing}{setting inherited distance}%
1639 \gre@rubberpermit{#1}%
1640 \ifgre@rubber%
1641 \def\gre@prefix{skip}%
1642 \else%
1643 \def\gre@prefix{dimen}%
1644 \fi%
1645 \gre@rubberpermit{#2}%
1646 \ifgre@rubber%
1647 \def\gre@prefixII{skip}%
1648 \else%
1649 \def\gre@prefixII{dimen}%
1650 \fi%
1651 \expandafter\edef\csname gre@space@\gre@prefix @#1\endcsname{\expandafter\unexpanded{\csname gre@space@\gre@prefixII @#2\endcsname}}%
1652 \directlua{gregoriotex.hash_spaces("\luatexluaescapestring{#1}", "\luatexluaescapestring{inherited from #2}")}%
1653 }{%
1654 \gre@rubberpermit{#2}%
1655 \ifgre@rubber%
1656 \def\gre@prefixII{skip}%
1657 \else%
1658 \def\gre@prefixII{dimen}%
1659 \fi%
1660 \ifcsname gre@space@\gre@prefixII @#2\endcsname%
1661 \gre@error{'#1' cannot be '#3' and depend on '#2' at the same time\MessageBreak Either use 'inherited' in the third argument\MessageBreak or give an actual distance in the second}%
1662 \fi%
1663 \gre@checklengthfalse%
1664 %check if #2 is a rubber length (contains plus and/or minus)
1665 \IfSubStr{#2}{plus}{\gre@checklengthtrue}{\relax}%
1666 \IfSubStr{#2}{minus}{\gre@checklengthtrue}{\relax}%
1667 %if #1 is one of the distances which cannot be rubber.
1668 \gre@rubberpermit{#1}%
1669 % do we try to assign a rubber to one where it's not permitted?
1670 \ifgre@rubber%
1671 \def\gre@prefix{skip}%
1672 \else%
1673 \ifgre@checklength%
1674 \gre@error{#1 cannot be a rubber length.}%
1675 \else%
1676 \def\gre@prefix{dimen}%
1677 \fi%
1678 \fi%
1679 % special check for bar@rubber
1680 \IfStrEq*{#1}{bar@rubber}%
1681 {%
1682 \gre@skip@temp@one = #2\relax%
1683 \ifdim\gre@skip@temp@one=0pt\relax\else%
1684 \gre@error{bar@rubber cannot have a non-zero base}%
1685 \fi%
1686 }{}%
1687 \expandafter\edef\csname gre@space@\gre@prefix @#1\endcsname{#2}%
1688 \directlua{gregoriotex.hash_spaces("\luatexluaescapestring{#1}", "\luatexluaescapestring{#2}")}%
1689 \relax %
1690 }%
1691 \gre@trace@end%
1692 }
1693
1694 %a macro to use if all you want to do is turn on or off the scaling for a particular distance
1695 \def\grescaledim#1#2{%
1696 \ifcsname ifgre@scale@#1\endcsname%
1697 \IfStrEqCase{#2}{%
1698 {true}%
1699 {\csname gre@scale@#1true\endcsname}%
1700 {yes}%
1701 {\grescaledim{true}}%
1702 {on}%
1703 {\grescaledim{true}}%
1704 {scalable}%
1705 {\grescaledim{true}}%
1706 }[% all other cases
1707 \csname gre@scale@#1false\endcsname%
1708 ]%
1709 \else%
1710 \gre@error{Unrecognized distance "#1" in \protect\grescaledim}%
1711 \fi%
1712 }
1713
1714 % same arguments as \grechangedim, but used for setting the dimension for a
1715 % single line
1716 \def\gre@changedimforline#1#2#3{%
1717 \gre@trace{gre@changedimforline{#1}{#2}{#3}}%
1718 \gre@rubberpermit{#1}%
1719 \ifgre@rubber%
1720 \def\gre@prefix{skip}%
1721 \else%
1722 \def\gre@prefix{dimen}%
1723 \fi%
1724 \directlua{%
1725 gregoriotex.save_dim(%
1726 "\luatexluaescapestring{#1}",%
1727 "\luatexluaescapestring{\expandafter\unexpanded%
1728 \expandafter\expandafter\expandafter{%
1729 \csname gre@space@\gre@prefix @#1\endcsname%
1730 }%
1731 }",%
1732 "\csname ifgre@scale@#1\endcsname scalable\else fixed\fi"%
1733 )%
1734 }%
1735 \grechangedim{#1}{#2}{#3}%
1736 \gre@trace@end%
1737 }%
1738
1739 % #1 : line number
1740 % #2-#4 : same as #1-#3 of \grechangedim
1741 \def\grechangenextscorelinedim#1#2#3#4{%
1742 \directlua{%
1743 gregoriotex.change_next_score_line_dim(%
1744 "\luatexluaescapestring{#1}",%
1745 "\luatexluaescapestring{#2}",%
1746 "\luatexluaescapestring{#3}",%
1747 "\luatexluaescapestring{#4}"%
1748 )%
1749 }%
1750 }%
1751
1752 % same arguments as \grechangecount, but used for setting the dimension for a
1753 % single line
1754 \def\gre@changecountforline#1#2{%
1755 \gre@trace{gre@changecountforline{#1}{#2}}%
1756 \directlua{%
1757 gregoriotex.save_count(%
1758 "\luatexluaescapestring{#1}",%
1759 "\luatexluaescapestring{\expandafter\unexpanded%
1760 \expandafter\expandafter\expandafter{%
1761 \expandafter\the\csname gre@space@count@#1\endcsname%
1762 }%
1763 }"%
1764 )%
1765 }%
1766 \grechangecount{#1}{#2}%
1767 \gre@trace@end%
1768 }%
1769
1770 % #1 : line number
1771 % #2-#3 : same as #1-#2 of \grechangecount
1772 \def\grechangenextscorelinecount#1#2#3{%
1773 \directlua{%
1774 gregoriotex.change_next_score_line_count(%
1775 "\luatexluaescapestring{#1}",%
1776 "\luatexluaescapestring{#2}",%
1777 "\luatexluaescapestring{#3}"%
1778 )%
1779 }%
1780 }%
1781
1782 \newcount\gre@space@count@newlinepenalty%
1783 \newcount\gre@space@count@nobreakpenalty%
1784 \newcount\gre@space@count@endofwordpenalty%
1785 \newcount\gre@space@count@endofsyllablepenalty%
1786 \newcount\gre@space@count@endafterbarpenalty%
1787 \newcount\gre@space@count@endafterbaraltpenalty%
1788 \newcount\gre@space@count@finalpenalty%
1789 \newcount\gre@space@count@endofelementpenalty%
1790 \newcount\gre@space@count@hyphenpenalty%
1791 \newcount\gre@space@count@brokenpenalty%
1792 \newcount\gre@space@count@looseness%
1793 \newcount\gre@space@count@tolerance%
1794 \newcount\gre@space@count@pretolerance%
1795 \newcount\gre@space@count@widowpenalty%
1796 \newcount\gre@space@count@clubpenalty%
1797
1798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1799 % space configuration loading
1800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1801
1802 \newcount\greconffactor%
1803 \def\greloadspaceconf#1{%
1804 \IfStrEq{#1}{default}{% load default spacings
1805 \ifx\@onlypreamble\@notprerr%
1806 \gre@debugmsg{preamble}{Not in preamble}%
1807 \makeatletter%
1808 \else%
1809 \gre@debugmsg{preamble}{In preamble}%
1810 \fi%
1811 \input gregoriotex-gsp-default.tex%
1812 \gre@changedimenfactor{\greconffactor}{\gre@factor}%
1813 \ifx\@onlypreamble\@notprerr%
1814 \makeatother%
1815 \fi%
1816 }{% load a custom spacing
1817 \input gsp-#1.tex\relax %
1818 \ifnum\greconffactor=0\relax%
1819 \gre@error{gsp-#1.tex does not have an assigned staff size.\MessageBreak Please edit it to define \protect\greconffactor}%
1820 \fi %
1821 }
1822 \greconffactor=0%
1823 \relax %
1824 }%
1825
1826
1827 % For everything to work fine the default configuration has to loaded after the gregoriotex package is completely loaded (so that all functions are well defined). As a result you'll find that as the last line in gregoriotex-main.tex
1828
1829
1830 %%%%%%%%%%%%%%
1831 %% Rescaling dimensions (for when \gre@factor changes)
1832 %%%%%%%%%%%%%%
1833
1834 % This function checks to see if the length is one of the ones which cannot be a rubber length. The assumption is that any length not listed here is allowed to be rubber.
1835 \newif\ifgre@rubber%
1836 \def\gre@rubberpermit#1{%
1837 \gre@trace{gre@rubberpermit{#1}}%
1838 % is length one that cannot be rubber?
1839 \IfStrEqCase*{#1}{%
1840 {additionallineswidth}{\gre@rubberfalse}%
1841 {additionalcustoslineswidth}{\gre@rubberfalse}%
1842 {zerowidthspace}{\gre@rubberfalse}%
1843 {maximumspacewithoutdash}{\gre@rubberfalse}%
1844 {afterinitialshift}{\gre@rubberfalse}%
1845 {beforeinitialshift}{\gre@rubberfalse}%
1846 {minimalspaceatlinebeginning}{\gre@rubberfalse}%
1847 {manualinitialwidth}{\gre@rubberfalse}%
1848 {minimalinitialwidth}{\gre@rubberfalse}%
1849 {annotationseparation}{\gre@rubberfalse}%
1850 {intersyllablespacenotes}{\gre@rubberfalse}%
1851 {intersyllablespacenotes@alteration}{\gre@rubberfalse}%
1852 {annotationraise}{\gre@rubberfalse}%
1853 {commentaryseparation}{\gre@rubberfalse}%
1854 {commentaryraise}{\gre@rubberfalse}%
1855 {noclefspace}{\gre@rubberfalse}%
1856 {clivisalignmentmin}{\gre@rubberfalse}%
1857 {choralsigndownshift}{\gre@rubberfalse}%
1858 {choralsignupshift}{\gre@rubberfalse}%
1859 {translationheight}{\gre@rubberfalse}%
1860 {spacelinestext}{\gre@rubberfalse}%
1861 {spacebeneathtext}{\gre@rubberfalse}%
1862 {abovelinestextraise}{\gre@rubberfalse}%
1863 {abovelinestextheight}{\gre@rubberfalse}%
1864 {braceshift}{\gre@rubberfalse}%
1865 {curlybraceaccentusshift}{\gre@rubberfalse}%
1866 {initialraise}{\gre@rubberfalse}%
1867 {beforealterationspace}{\gre@rubberfalse}%
1868 {alterationspace}{\gre@rubberfalse}%
1869 {overslurshift}{\gre@rubberfalse}%
1870 {underslurshift}{\gre@rubberfalse}%
1871 {maxbaroffsettextleft}{\gre@rubberfalse}%
1872 {maxbaroffsettextright}{\gre@rubberfalse}%
1873 {maxbaroffsettextleft@nobar}{\gre@rubberfalse}%
1874 {maxbaroffsettextright@nobar}{\gre@rubberfalse}%
1875 {maxbaroffsettextleft@eol}{\gre@rubberfalse}%
1876 {maxbaroffsettextright@eol}{\gre@rubberfalse}%
1877 {interwordspacetext@bars@euouae}{\gre@rubberfalse}%
1878 {interwordspacetext@bars}{\gre@rubberfalse}%
1879 {interwordspacetext@bars@notext@euouae}{\gre@rubberfalse}%
1880 {interwordspacetext@bars@notext}{\gre@rubberfalse}%
1881 {overhepisemalowshift}{\gre@rubberfalse}%
1882 {overhepisemahighshift}{\gre@rubberfalse}%
1883 {underhepisemalowshift}{\gre@rubberfalse}%
1884 {underhepisemahighshift}{\gre@rubberfalse}%
1885 {hepisemamiddleshift}{\gre@rubberfalse}%
1886 {vepisemalowshift}{\gre@rubberfalse}%
1887 {vepisemahighshift}{\gre@rubberfalse}%
1888 {linepunctummorashift}{\gre@rubberfalse}%
1889 {spacepunctummorashift}{\gre@rubberfalse}%
1890 {spaceamonepespunctummorashift}{\gre@rubberfalse}%
1891 {lineporrectuspunctummorashift}{\gre@rubberfalse}%
1892 {spaceporrectuspunctummorashift}{\gre@rubberfalse}%
1893 {raresignshift}{\gre@rubberfalse}%
1894 {divisiofinalissep}{\gre@rubberfalse}%
1895 {alterationadjustmentbar}{\gre@rubberfalse}%
1896 {bracketupshift}{\gre@rubberfalse}%
1897 {bracketdownshift}{\gre@rubberfalse}%
1898 {noteadditionalspacelinestext}{\gre@rubberfalse}%
1899 }[\gre@rubbertrue]%
1900 \gre@trace@end%
1901 }%
1902
1903 %% an aux function adapting the value #1 from the factor #2 to the factor #3
1904 \def\gre@changeonedimenfactor#1#2#3{%
1905 \gre@trace{gre@changeonedimenfactor{#1}{#2}{#3}}%
1906 % Math
1907 \gre@rubberpermit{#1}%
1908 \ifgre@rubber%
1909 \gre@debugmsg{gsp}{scaling a rubber}%
1910 % if we have a rubber allowed length we create a temporary skip
1911 \let\gre@scaledist\gre@skip@temp@one%
1912 \edef\gre@convert{\csname gre@space@skip@#1\endcsname}%
1913 \gre@scaledist=\glueexpr(\gre@convert * \number#3 / \number#2)\relax %
1914 \else%
1915 \gre@debugmsg{gsp}{scaling a fixed distance}%
1916 % otherwise we create a temporary dimen
1917 \let\gre@scaledist\gre@dimen@temp@one%
1918 \edef\gre@convert{\csname gre@space@dimen@#1\endcsname}%
1919 \gre@scaledist=\dimexpr(\gre@convert * \number#3 / \number#2)\relax %
1920 \fi%
1921 \gre@consistentunits{\gre@convert}{\gre@scaledist}%
1922 \gre@dimension{#1}{\gre@stringdist}%
1923 \relax %
1924 \gre@trace@end%
1925 }%
1926
1927
1928 % This function converts a distance to the units indicated in #1 and returns it as a string.
1929 \def\gre@convertto#1#2{%
1930 \gre@trace{gre@convertto{#1}{#2}}%
1931 % \p@ is equal to 1pt and is used here for a more accurate computation
1932 \edef\gre@converted{\gre@strip@pt\dimexpr#2*\p@/\dimexpr 1#1\relax\relax #1}%
1933 \gre@debugmsg{general}{converted value is \gre@converted}%
1934 \gre@trace@end%
1935 }%
1936
1937 % This function takes a distance (#2) and formats it as a string so that its units conform to the pattern set by a string representation of a distance (#1)
1938 \newif\ifgre@stretch%
1939 \newif\ifgre@shrink%
1940 \def\gre@consistentunits#1#2{%
1941 \gre@trace{gre@consistentunits{#1}{#2}}%
1942 \gre@stretchfalse%
1943 \gre@shrinkfalse%
1944 \IfSubStr{#1}{plus}{\gre@stretchtrue}{\relax}%
1945 \IfSubStr{#1}{minus}{\gre@shrinktrue}{\relax}%
1946 \ifgre@stretch%
1947 \ifgre@shrink%
1948 %rubber with both stretch and shrink
1949 \StrBefore{#1}{plus}[\gre@baseunit]%
1950 \StrBetween{#1}{plus}{minus}[\gre@stretchunit]%
1951 \StrBehind{#1}{minus}[\gre@shrinkunit]%
1952 \else%
1953 %rubber with stretch only
1954 \StrBefore{#1}{plus}[\gre@baseunit]%
1955 \StrBehind{#1}{plus}[\gre@stretchunit]%
1956 \def\gre@shrinkunit{\relax}%
1957 \fi%
1958 \else%
1959 \ifgre@shrink%
1960 %rubber with shrink only
1961 \StrBefore{#1}{minus}[\gre@baseunit]%
1962 \def\gre@stretchunit{\relax}%
1963 \StrBehind{#1}{minus}[\gre@shrinkunit]%
1964 \else%
1965 %non-rubber
1966 \def\gre@baseunit{#1}%
1967 \def\gre@stretchunit{\relax}%
1968 \def\gre@shrinkunit{\relax}%
1969 \fi%
1970 \fi%
1971 \StrDel{\gre@baseunit}{ }[\gre@baseunit]%
1972 \StrRight{\gre@baseunit}{2}[\gre@baseunit]%
1973 \StrDel{\gre@stretchunit}{ }[\gre@stretchunit]%
1974 \StrRight{\gre@stretchunit}{2}[\gre@stretchunit]%
1975 \StrDel{\gre@shrinkunit}{ }[\gre@shrinkunit]%
1976 \StrRight{\gre@shrinkunit}{2}[\gre@shrinkunit]%
1977 \gre@convertto{\gre@baseunit}{\dimexpr#2\relax}%
1978 \edef\gre@stringdist{\gre@converted}%
1979 \if\relax\gre@stretchunit\else%
1980 \gre@convertto{\gre@stretchunit}{\gluestretch#2}%
1981 \edef\gre@stringdist{\gre@stringdist plus \gre@converted}%
1982 \fi%
1983 \if\relax\gre@shrinkunit\else%
1984 \gre@convertto{\gre@shrinkunit}{\glueshrink#2}%
1985 \edef\gre@stringdist{\gre@stringdist minus \gre@converted}%
1986 \fi%
1987 \gre@trace@end%
1988 }%
1989
1990
1991 %% this function changes all the values of the spaces (vertical and horizontal) from one factor to another
1992 %% simply by dividing them by the old factor, and multiplying them by the new one.
1993 % #1 is the old gre@factor, #2 is the new one
1994 \def\gre@changedimenfactor#1#2{%
1995 \gre@trace{gre@changedimenfactor{#1}{#2}}%
1996 \ifgre@scale@additionallineswidth%
1997 \gre@changeonedimenfactor{additionallineswidth}{#1}{#2}%
1998 \fi%
1999 \ifgre@scale@additionalcustoslineswidth%
2000 \gre@changeonedimenfactor{additionalcustoslineswidth}{#1}{#2}%
2001 \fi%
2002 \ifgre@scale@zerowidthspace%
2003 \gre@changeonedimenfactor{zerowidthspace}{#1}{#2}%
2004 \fi%
2005 \ifgre@scale@interglyphspace%
2006 \gre@changeonedimenfactor{interglyphspace}{#1}{#2}%
2007 \fi%
2008 \ifgre@scale@alterationspace%
2009 \gre@changeonedimenfactor{alterationspace}{#1}{#2}%
2010 \fi%
2011 \ifgre@scale@clefflatspace%
2012 \gre@changeonedimenfactor{clefflatspace}{#1}{#2}%
2013 \fi%
2014 \ifgre@scale@beforelowchoralsignspace%
2015 \gre@changeonedimenfactor{beforelowchoralsignspace}{#1}{#2}%
2016 \fi%
2017 \ifgre@scale@beforealterationspace%
2018 \gre@changeonedimenfactor{beforealterationspace}{#1}{#2}%
2019 \fi%
2020 \ifgre@scale@halfspace%
2021 \gre@changeonedimenfactor{halfspace}{#1}{#2}%
2022 \fi%
2023 \ifgre@scale@interelementspace%
2024 \gre@changeonedimenfactor{interelementspace}{#1}{#2}%
2025 \fi%
2026 \ifgre@scale@largerspace%
2027 \gre@changeonedimenfactor{largerspace}{#1}{#2}%
2028 \fi%
2029 \ifgre@scale@nabcinterelementspace%
2030 \gre@changeonedimenfactor{nabcinterelementspace}{#1}{#2}%
2031 \fi%
2032 \ifgre@scale@nabclargerspace%
2033 \gre@changeonedimenfactor{nabclargerspace}{#1}{#2}%
2034 \fi%
2035 \ifgre@scale@glyphspace%
2036 \gre@changeonedimenfactor{glyphspace}{#1}{#2}%
2037 \fi%
2038 \ifgre@scale@spacebeforeinlinecustos%
2039 \gre@changeonedimenfactor{spacebeforeinlinecustos}{#1}{#2}%
2040 \fi%
2041 \ifgre@scale@spacebeforeeolcustos%
2042 \gre@changeonedimenfactor{spacebeforeeolcustos}{#1}{#2}%
2043 \fi%
2044 \ifgre@scale@spacebeforesigns%
2045 \gre@changeonedimenfactor{spacebeforesigns}{#1}{#2}%
2046 \fi%
2047 \ifgre@scale@spaceaftersigns%
2048 \gre@changeonedimenfactor{spaceaftersigns}{#1}{#2}%
2049 \fi%
2050 \ifgre@scale@spaceafterlineclef%
2051 \gre@changeonedimenfactor{spaceafterlineclef}{#1}{#2}%
2052 \fi%
2053 \ifgre@scale@shortspaceafterlineclef%
2054 \gre@changeonedimenfactor{shortspaceafterlineclef}{#1}{#2}%
2055 \fi%
2056 \ifgre@scale@interwordspacenotes%
2057 \gre@changeonedimenfactor{interwordspacenotes}{#1}{#2}%
2058 \fi%
2059 \ifgre@scale@intersyllablespacenotes%
2060 \gre@changeonedimenfactor{intersyllablespacenotes}{#1}{#2}%
2061 \fi%
2062 \ifgre@scale@interwordspacenotes@alteration%
2063 \gre@changeonedimenfactor{interwordspacenotes@alteration}{#1}{#2}%
2064 \fi%
2065 \ifgre@scale@intersyllablespacenotes@alteration%
2066 \gre@changeonedimenfactor{intersyllablespacenotes@alteration}{#1}{#2}%
2067 \fi%
2068 \ifgre@scale@intersyllablespacestretchhyphen%
2069 \gre@changeonedimenfactor{intersyllablespacestretchhyphen}{#1}{#2}%
2070 \fi%
2071 \ifgre@scale@interwordspacetext%
2072 \gre@changeonedimenfactor{interwordspacetext}{#1}{#2}%
2073 \fi%
2074 \ifgre@scale@interwordspacetext@bars%
2075 \gre@changeonedimenfactor{interwordspacetext@bars}{#1}{#2}%
2076 \fi%
2077 \ifgre@scale@interwordspacetext@bars@notext%
2078 \gre@changeonedimenfactor{interwordspacetext@bars@notext}{#1}{#2}%
2079 \fi%
2080 \ifgre@scale@interwordspacenotes@euouae%
2081 \gre@changeonedimenfactor{interwordspacenotes@euouae}{#1}{#2}%
2082 \fi%
2083 \ifgre@scale@interwordspacetext@euouae%
2084 \gre@changeonedimenfactor{interwordspacetext@euouae}{#1}{#2}%
2085 \fi%
2086 \ifgre@scale@interwordspacetext@bars@euouae%
2087 \gre@changeonedimenfactor{interwordspacetext@bars@euouae}{#1}{#2}%
2088 \fi%
2089 \ifgre@scale@interwordspacetext@bars@notext@euouae%
2090 \gre@changeonedimenfactor{interwordspacetext@bars@notext@euouae}{#1}{#2}%
2091 \fi%
2092 \ifgre@scale@bitrivirspace%
2093 \gre@changeonedimenfactor{bitrivirspace}{#1}{#2}%
2094 \fi%
2095 \ifgre@scale@bitristrospace%
2096 \gre@changeonedimenfactor{bitristrospace}{#1}{#2}%
2097 \fi%
2098 \ifgre@scale@punctuminclinatumshift%
2099 \gre@changeonedimenfactor{punctuminclinatumshift}{#1}{#2}%
2100 \fi%
2101 \ifgre@scale@ascendingpunctuminclinatumshift%
2102 \gre@changeonedimenfactor{ascendingpunctuminclinatumshift}{#1}{#2}%
2103 \fi%
2104 \ifgre@scale@beforepunctainclinatashift%
2105 \gre@changeonedimenfactor{beforepunctainclinatashift}{#1}{#2}%
2106 \fi%
2107 \ifgre@scale@punctuminclinatumanddebilisshift%
2108 \gre@changeonedimenfactor{punctuminclinatumanddebilisshift}{#1}{#2}%
2109 \fi%
2110 \ifgre@scale@ascendingpunctuminclinatumanddebilisshift%
2111 \gre@changeonedimenfactor{ascendingpunctuminclinatumanddebilisshift}{#1}{#2}%
2112 \fi%
2113 \ifgre@scale@punctuminclinatumdebilisshift%
2114 \gre@changeonedimenfactor{punctuminclinatumdebilisshift}{#1}{#2}%
2115 \fi%
2116 \ifgre@scale@punctuminclinatumbigshift%
2117 \gre@changeonedimenfactor{punctuminclinatumbigshift}{#1}{#2}%
2118 \fi%
2119 \ifgre@scale@ascendingpunctuminclinatumbigshift%
2120 \gre@changeonedimenfactor{ascendingpunctuminclinatumbigshift}{#1}{#2}%
2121 \fi%
2122 \ifgre@scale@punctuminclinatummaxshift%
2123 \gre@changeonedimenfactor{punctuminclinatummaxshift}{#1}{#2}%
2124 \fi%
2125 \ifgre@scale@ascendingpunctuminclinatummaxshift%
2126 \gre@changeonedimenfactor{ascendingpunctuminclinatummaxshift}{#1}{#2}%
2127 \fi%
2128 \ifgre@scale@descendinginclinatumtonobarshift%
2129 \gre@changeonedimenfactor{descendinginclinatumtonobarshift}{#1}{#2}%
2130 \fi%
2131 \ifgre@scale@descendinginclinatumtonobarbigshift%
2132 \gre@changeonedimenfactor{descendinginclinatumtonobarbigshift}{#1}{#2}%
2133 \fi%
2134 \ifgre@scale@descendinginclinatumtonobarmaxshift%
2135 \gre@changeonedimenfactor{descendinginclinatumtonobarmaxshift}{#1}{#2}%
2136 \fi%
2137 \ifgre@scale@ascendinginclinatumtonobarshift%
2138 \gre@changeonedimenfactor{ascendinginclinatumtonobarshift}{#1}{#2}%
2139 \fi%
2140 \ifgre@scale@ascendinginclinatumtonobarbigshift%
2141 \gre@changeonedimenfactor{ascendinginclinatumtonobarbigshift}{#1}{#2}%
2142 \fi%
2143 \ifgre@scale@ascendinginclinatumtonobarmaxshift%
2144 \gre@changeonedimenfactor{ascendinginclinatumtonobarmaxshift}{#1}{#2}%
2145 \fi%
2146 \ifgre@scale@bar@virgula%
2147 \gre@changeonedimenfactor{bar@virgula}{#1}{#2}%
2148 \fi%
2149 \ifgre@scale@bar@virgula@short%
2150 \gre@changeonedimenfactor{bar@virgula@short}{#1}{#2}%
2151 \fi%
2152 \ifgre@scale@bar@minimis%
2153 \gre@changeonedimenfactor{bar@minimis}{#1}{#2}%
2154 \fi%
2155 \ifgre@scale@bar@minimis@short%
2156 \gre@changeonedimenfactor{bar@minimis@short}{#1}{#2}%
2157 \fi%
2158 \ifgre@scale@bar@minima%
2159 \gre@changeonedimenfactor{bar@minima}{#1}{#2}%
2160 \fi%
2161 \ifgre@scale@bar@minima@short%
2162 \gre@changeonedimenfactor{bar@minima@short}{#1}{#2}%
2163 \fi%
2164 \ifgre@scale@bar@minor%
2165 \gre@changeonedimenfactor{bar@minor}{#1}{#2}%
2166 \fi%
2167 \ifgre@scale@bar@minor%
2168 \gre@changeonedimenfactor{bar@dominican}{#1}{#2}%
2169 \fi%
2170 \ifgre@scale@bar@maior%
2171 \gre@changeonedimenfactor{bar@maior}{#1}{#2}%
2172 \fi%
2173 \ifgre@scale@bar@finalis%
2174 \gre@changeonedimenfactor{bar@finalis}{#1}{#2}%
2175 \fi%
2176 \ifgre@scale@bar@finalfinalis%
2177 \gre@changeonedimenfactor{bar@finalfinalis}{#1}{#2}%
2178 \fi%
2179 \ifgre@scale@bar@virgula@standalone@text%
2180 \gre@changeonedimenfactor{bar@virgula@standalone@text}{#1}{#2}%
2181 \fi%
2182 \ifgre@scale@bar@virgula@standalone@text@short%
2183 \gre@changeonedimenfactor{bar@virgula@standalone@text@short}{#1}{#2}%
2184 \fi%
2185 \ifgre@scale@bar@minimis@standalone@text%
2186 \gre@changeonedimenfactor{bar@minimis@standalone@text}{#1}{#2}%
2187 \fi%
2188 \ifgre@scale@bar@minimis@standalone@text@short%
2189 \gre@changeonedimenfactor{bar@minimis@standalone@text@short}{#1}{#2}%
2190 \fi%
2191 \ifgre@scale@bar@minima@standalone@text%
2192 \gre@changeonedimenfactor{bar@minima@standalone@text}{#1}{#2}%
2193 \fi%
2194 \ifgre@scale@bar@minima@standalone@text@short%
2195 \gre@changeonedimenfactor{bar@minima@standalone@text@short}{#1}{#2}%
2196 \fi%
2197 \ifgre@scale@bar@minor@standalone@text%
2198 \gre@changeonedimenfactor{bar@minor@standalone@text}{#1}{#2}%
2199 \fi%
2200 \ifgre@scale@bar@minor@standalone@text%
2201 \gre@changeonedimenfactor{bar@dominican@standalone@text}{#1}{#2}%
2202 \fi%
2203 \ifgre@scale@bar@maior@standalone@text%
2204 \gre@changeonedimenfactor{bar@maior@standalone@text}{#1}{#2}%
2205 \fi%
2206 \ifgre@scale@bar@finalis@standalone@text%
2207 \gre@changeonedimenfactor{bar@finalis@standalone@text}{#1}{#2}%
2208 \fi%
2209 \ifgre@scale@bar@virgula@standalone@notext%
2210 \gre@changeonedimenfactor{bar@virgula@standalone@notext}{#1}{#2}%
2211 \fi%
2212 \ifgre@scale@bar@virgula@standalone@notext@short%
2213 \gre@changeonedimenfactor{bar@virgula@standalone@notext@short}{#1}{#2}%
2214 \fi%
2215 \ifgre@scale@bar@minimis@standalone@notext%
2216 \gre@changeonedimenfactor{bar@minimis@standalone@notext}{#1}{#2}%
2217 \fi%
2218 \ifgre@scale@bar@minimis@standalone@notext@short%
2219 \gre@changeonedimenfactor{bar@minimis@standalone@notext@short}{#1}{#2}%
2220 \fi%
2221 \ifgre@scale@bar@minima@standalone@notext%
2222 \gre@changeonedimenfactor{bar@minima@standalone@notext}{#1}{#2}%
2223 \fi%
2224 \ifgre@scale@bar@minima@standalone@notext@short%
2225 \gre@changeonedimenfactor{bar@minima@standalone@notext@short}{#1}{#2}%
2226 \fi%
2227 \ifgre@scale@bar@minor@standalone@notext%
2228 \gre@changeonedimenfactor{bar@minor@standalone@notext}{#1}{#2}%
2229 \fi%
2230 \ifgre@scale@bar@minor@standalone@notext%
2231 \gre@changeonedimenfactor{bar@dominican@standalone@notext}{#1}{#2}%
2232 \fi%
2233 \ifgre@scale@bar@maior@standalone@notext%
2234 \gre@changeonedimenfactor{bar@maior@standalone@notext}{#1}{#2}%
2235 \fi%
2236 \ifgre@scale@bar@finalis@standalone@notext%
2237 \gre@changeonedimenfactor{bar@finalis@standalone@notext}{#1}{#2}%
2238 \fi%
2239 \ifgre@scale@spacearoundclefbars%
2240 \gre@changeonedimenfactor{spacearoundclefbars}{#1}{#2}%
2241 \fi%
2242 \ifgre@scale@textbartextspace%
2243 \gre@changeonedimenfactor{textbartextspace}{#1}{#2}%
2244 \fi%
2245 \ifgre@scale@notebarspace%
2246 \gre@changeonedimenfactor{notebarspace}{#1}{#2}%
2247 \fi%
2248 \ifgre@scale@maximumspacewithoutdash%
2249 \gre@changeonedimenfactor{maximumspacewithoutdash}{#1}{#2}%
2250 \fi%
2251 \ifgre@scale@afterclefnospace%
2252 \gre@changeonedimenfactor{afterclefnospace}{#1}{#2}%
2253 \fi%
2254 \ifgre@scale@afterinitialshift%
2255 \gre@changeonedimenfactor{afterinitialshift}{#1}{#2}%
2256 \fi%
2257 \ifgre@scale@beforeinitialshift%
2258 \gre@changeonedimenfactor{beforeinitialshift}{#1}{#2}%
2259 \fi%
2260 \ifgre@scale@minimalspaceatlinebeginning%
2261 \gre@changeonedimenfactor{minimalspaceatlinebeginning}{#1}{#2}%
2262 \fi%
2263 \ifgre@scale@manualinitialwidth%
2264 \gre@changeonedimenfactor{manualinitialwidth}{#1}{#2}%
2265 \fi%
2266 \ifgre@scale@minimalinitialwidth%
2267 \gre@changeonedimenfactor{minimalinitialwidth}{#1}{#2}%
2268 \fi%
2269 \ifgre@scale@annotationseparation%
2270 \gre@changeonedimenfactor{annotationseparation}{#1}{#2}%
2271 \fi%
2272 \ifgre@scale@annotationraise%
2273 \gre@changeonedimenfactor{annotationraise}{#1}{#2}%
2274 \fi%
2275 \ifgre@scale@noclefspace%
2276 \gre@changeonedimenfactor{noclefspace}{#1}{#2}%
2277 \fi%
2278 \ifgre@scale@clefchangespace%
2279 \gre@changeonedimenfactor{clefchangespace}{#1}{#2}%
2280 \fi%
2281 \ifgre@scale@clivisalignmentmin%
2282 \gre@changeonedimenfactor{clivisalignmentmin}{#1}{#2}%
2283 \fi%
2284 \ifgre@scale@choralsigndownshift%
2285 \gre@changeonedimenfactor{choralsigndownshift}{#1}{#2}%
2286 \fi%
2287 \ifgre@scale@choralsignupshift%
2288 \gre@changeonedimenfactor{choralsignupshift}{#1}{#2}%
2289 \fi%
2290 \ifgre@scale@translationheight%
2291 \gre@changeonedimenfactor{translationheight}{#1}{#2}%
2292 \fi%
2293 \ifgre@scale@spaceabovelines%
2294 \gre@changeonedimenfactor{spaceabovelines}{#1}{#2}%
2295 \fi%
2296 \ifgre@scale@spacelinestext%
2297 \gre@changeonedimenfactor{spacelinestext}{#1}{#2}%
2298 \fi%
2299 \ifgre@scale@spacebeneathtext%
2300 \gre@changeonedimenfactor{spacebeneathtext}{#1}{#2}%
2301 \fi%
2302 \ifgre@scale@abovelinestextraise%
2303 \gre@changeonedimenfactor{abovelinestextraise}{#1}{#2}%
2304 \fi%
2305 \ifgre@scale@abovelinestextheight%
2306 \gre@changeonedimenfactor{abovelinestextheight}{#1}{#2}%
2307 \fi%
2308 \ifgre@scale@braceshift%
2309 \gre@changeonedimenfactor{braceshift}{#1}{#2}%
2310 \fi%
2311 \ifgre@scale@curlybraceaccentusshift%
2312 \gre@changeonedimenfactor{curlybraceaccentusshift}{#1}{#2}%
2313 \fi%
2314 \ifgre@scale@maxbaroffsettextright%
2315 \gre@changeonedimenfactor{maxbaroffsettextright}{#1}{#2}%
2316 \fi%
2317 \ifgre@scale@maxbaroffsettextleft%
2318 \gre@changeonedimenfactor{maxbaroffsettextleft}{#1}{#2}%
2319 \fi%
2320 \ifgre@scale@maxbaroffsettextright@nobar%
2321 \gre@changeonedimenfactor{maxbaroffsettextright@nobar}{#1}{#2}%
2322 \fi%
2323 \ifgre@scale@maxbaroffsettextleft@nobar%
2324 \gre@changeonedimenfactor{maxbaroffsettextleft@nobar}{#1}{#2}%
2325 \fi%
2326 \ifgre@scale@maxbaroffsettextleft@eol%
2327 \gre@changeonedimenfactor{maxbaroffsettextleft@eol}{#1}{#2}%
2328 \fi%
2329 \ifgre@scale@maxbaroffsettextright@eol%
2330 \gre@changeonedimenfactor{maxbaroffsettextright@eol}{#1}{#2}%
2331 \fi%
2332 \ifgre@scale@bar@rubber%
2333 \gre@changeonedimenfactor{bar@rubber}{#1}{#2}%
2334 \fi%
2335 \ifgre@scale@moraadjustment%
2336 \gre@changeonedimenfactor{moraadjustment}{#1}{#2}%
2337 \fi%
2338 \ifgre@scale@moraadjustmentbar%
2339 \gre@changeonedimenfactor{moraadjustment}{#1}{#2}%
2340 \fi%
2341 \ifgre@scale@alterationadjustmentbar%
2342 \gre@changeonedimenfactor{alterationadjustmentbar}{#1}{#2}%
2343 \fi%
2344 \ifgre@scale@divisiofinalissep%
2345 \gre@changeonedimenfactor{divisiofinalissep}{#1}{#2}%
2346 \fi%
2347 \ifgre@scale@stafflinefactor%
2348 \gre@count@temp@two = \numexpr((\gre@stafflinefactor * #2) / #1)\relax%
2349 \xdef\gre@stafflinefactor{\the\gre@count@temp@two}%
2350 \fi%
2351 \ifgre@scale@noteadditionalspacelinestext%
2352 \gre@changeonedimenfactor{noteadditionalspacelinestext}{#1}{#2}%
2353 \fi%
2354 \relax %
2355 \gre@trace@end%
2356 }%