Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
02ec952
Move syllable rewriting to Lua. The new algorithm works slightly diff…
davidweichiang Feb 19, 2026
4fa508d
Recalculate syllablefinalskip in Lua. The syllablefinalskip is still …
davidweichiang Feb 19, 2026
ec4e22c
Continue working on syllable spacing in Lua:
davidweichiang Mar 9, 2026
a48c861
Intra-syllable hyphenation in Lua. If there is sufficient space betwe…
davidweichiang Mar 10, 2026
13d8dbb
Merge and resolve conflict
davidweichiang Mar 19, 2026
a6ffb1e
Merge remote-tracking branch 'upstream/develop' into lua-syllable-spa…
davidweichiang Mar 24, 2026
2e28189
Merge branch 'develop' into lua-syllable-spacing
davidweichiang Apr 20, 2026
1c11d5c
Correct and expand documentation
davidweichiang Apr 20, 2026
58b85fb
fix bug in rewriting plus eol hyphen
davidweichiang Apr 28, 2026
775a4cd
Minor reorganization
davidweichiang Apr 29, 2026
5770765
Unify attributes on skips in note and bar syllables
davidweichiang Apr 29, 2026
1fd30bb
- Mark skips with skip type attribute more completely
davidweichiang Apr 29, 2026
4caf9a9
Improve spacing before clef changes without bars
davidweichiang Apr 29, 2026
9fbf332
Fix typos
davidweichiang Apr 30, 2026
f0fe40d
Remove dash attribute 4 (which had little to do with dashes)
davidweichiang May 1, 2026
be39ebb
CHANGELOG and version
davidweichiang May 3, 2026
fb961ed
Merge branch 'develop' into lua-syllable-spacing
davidweichiang May 4, 2026
ea045b9
In \gre@newlinecommon, try to explain better why so many kerns are ne…
davidweichiang May 5, 2026
6b2c637
Remove \gre@attr@score from docs
davidweichiang May 5, 2026
6cd087f
Merge branch 'develop' into lua-syllable-spacing
davidweichiang May 5, 2026
e60e3d4
Merge branch 'develop' into lua-syllable-spacing
davidweichiang May 6, 2026
f256ea3
Fix syllable rewriting, which was broken by commit a48c861348f42654c1…
davidweichiang May 7, 2026
e28d651
Previously, point-and-click inserted markers that were blocking kerni…
davidweichiang May 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed a bug that could cause problems with headers/footers by generalizing the fix for fancyhdr (see [#1610](https://github.com/gregorio-project/gregorio/pull/1610) to work with any headers/footers. In particular, it fixes a similar problem with the `memoir` class. See [#1753](https://github.com/gregorio-project/gregorio/pull/1753).
- Fixed some typos that would cause a handful of spaces to be scaled incorrectly. See [PR #1746](https://github.com/gregorio-project/gregorio/pull/1746).
- Fixed a few bugs related to horizontal spacing around bars and clef changes. See issues [#1191](https://github.com/gregorio-project/gregorio/issues/1191), case 3 of [#1724](https://github.com/gregorio-project/gregorio/issues/1724), [PR #1743](https://github.com/gregorio-project/gregorio/pull/1743), and [#1745](https://github.com/gregorio-project/gregorio/issues/1745).
- Code for several features related to horizontal spacing (spacing between non-bar syllables, syllable rewriting, clearing, and hyphenation) was moved into Lua. This results in some changes in horizontal spacing, which, if perceptible, should be improvements. See [#1720](https://github.com/gregorio-project/gregorio/issues/1720).

## [Unreleased][CTAN]
*Note:* 6.2.0 was not released to CTAN and is not compatible with 6.1.0 which is on CTAN. Please make all changes against develop until this is resolved.
Expand Down
2 changes: 2 additions & 0 deletions VersionManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"tex/gregoriotex-symbols.tex",
"tex/gregoriotex-symbols.lua",
"tex/gregoriotex-syllable.tex",
"tex/gregoriotex-syllable.lua",
"tex/gregoriotex-main.tex",
"tex/gregoriotex-nabc.tex",
"tex/gregoriotex-nabc.lua",
Expand All @@ -78,6 +79,7 @@
"tex/Makefile.am",
"tex/gregoriotex-common.tex",
"tex/gregoriotex-syllable.tex",
"tex/gregoriotex-syllable.lua",
"tex/gregoriotex.lua",
"tex/gregoriotex.sty",
"tex/gregoriosyms.sty",
Expand Down
3 changes: 0 additions & 3 deletions doc/Command_Index_gregorio.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1352,9 +1352,6 @@ \section{Gregorio Controls}
\macroname{\textbackslash GreNoBreak}{}{gregoriotex-spaces.tex}
Macro used to prevent a line break from occurring at a given position.

\macroname{\textbackslash GreScoreId}{}{gregoriotex-main.tex}
A Lua\TeX\ attribute which designates a unique identifier for each score.

\macroname{\textbackslash GreNABCNeumes}{\#1\#2\#3\#4}{gregoriotex-nabc.tex}
Macro called by the generated \texttt{.gtex} file to typeset the neumes of one
NABC voice for a GABC element. Dispatches to \verb=\GreSetNabcAboveLines= or
Expand Down
74 changes: 10 additions & 64 deletions doc/Command_Index_internal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,13 @@ \section{Gregorio\TeX{} Controls}
\macroname{\textbackslash gre@calculate@additionalspaces}{}{gregoriotex-spaces.tex}
Macro which initializes various dimensions and counts used for variable line height computation.

\macroname{\textbackslash gre@calculate@textaligncenter}{\#1\#2\#3\#4}{gregoriotex-spaces.tex}
\macroname{\textbackslash gre@calculate@textaligncenter}{\#1\#2\#3}{gregoriotex-spaces.tex}
Macro for calculating \verb=\gre@textaligncenter=.

\begin{argtable}
\#1 & string & The carry-over letters from the previous syllable that should be moved to the current.\\
\#2 & string & The first part of the syllable (any preceding consonants in Latin).\\
\#3 & string & The middle part of the syllable (the vowel in Latin, the whole syllable in English).\\
\#4 & \texttt{0} & Calculation is being performed for the current syllable.\\
\#1 & string & The first part of the syllable (any preceding consonants in Latin).\\
\#2 & string & The middle part of the syllable (the vowel in Latin, the whole syllable in English).\\
\#3 & \texttt{0} & Calculation is being performed for the current syllable.\\
& \texttt{1} & Calculation is being performed for the next syllable.\\
\end{argtable}

Expand Down Expand Up @@ -248,16 +247,15 @@ \section{Gregorio\TeX{} Controls}
\#2 & integer & the factor the distances are to be put into\\
\end{argtable}

\macroname{\textbackslash gre@calculate@nextbegindifference}{\#1\#2\#3\#4\#5\#6}{gregoriotex-spaces.tex}
\macroname{\textbackslash gre@calculate@nextbegindifference}{\#1\#2\#3\#4\#5}{gregoriotex-spaces.tex}
Macro to calculate \texttt{nextbegindifference}.

\begin{argtable}
\#1 & string & the carry-over letters for the next syllable\\
\#2 & string & the first letters of the next syllable\\
\#3 & string & the middle letters of the next syllable (the vowel in Latin, the whole syllable in English)\\
\#4 & string & the end letters of the next syllable\\
\#5 & integer & the type of notes alignment. See \Nameref{notesalign}.\\
\#6 & integer & the type of alteration. See \Nameref{alterationtype}.\\
\#1 & string & the first letters of the next syllable\\
\#2 & string & the middle letters of the next syllable (the vowel in Latin, the whole syllable in English)\\
\#3 & string & the end letters of the next syllable\\
\#4 & integer & the type of notes alignment. See \Nameref{notesalign}.\\
\#5 & integer & the type of alteration. See \Nameref{alterationtype}.\\
\end{argtable}

\macroname{\textbackslash gre@strip@pt}{\#1}{gregoriotex.sty \textup{and} gregoriotex.tex}
Expand Down Expand Up @@ -1152,43 +1150,6 @@ \section{Gregorio\TeX{} Controls}
\#1 & string & The syllable (usually built as \texttt{\small\pmac{gre@nextfirstsyllablepart}\linebreak[1]\pmac{gre@nextmiddlesyllablepart}\linebreak[1]\pmac{gre@nextendsyllablepart}})\\
\end{argtable}

\macroname{\textbackslash gre@if@rewritesyllable}{\#1\#2}{gregoriotex-syllable.tex}
Performs \#1 if the syllable should be rewritten, else \#2.

\begin{argtable}
\#1 & \TeX\ code & Code to perform when rewriting the syllable\\
\#2 & \TeX\ code & Code to perform when \emph{not} rewriting the syllable\\
\end{argtable}

\macroname{\textbackslash gre@push@endsyllable}{\#1}{gregoriotex-syllable.tex}
Sets the save aliases to push the end-syllable part of the current syllable to the next syllable if necessary.

\begin{argtable}
\#1 & link target & line:char:column for the link to use for the pushed syllable part\\
\end{argtable}

\macroname{\textbackslash gre@emit@syllabletext}{\#1}{gregoriotex-syllable.tex}
Emits the text for the syllable, prepending the carry-over syllable part if necessary and consolidating the fixed text styles if possible.

\begin{argtable}
\#1 & \TeX\ code & Code that emits the syllable text\\
\end{argtable}

\macroname{\textbackslash gre@emit@endsyllablepart}{}{gregoriotex-syllable.tex}
Emits the text for the end syllable part if it \emph{is not} to be moved to the next syllable.

\macroname{\textbackslash gre@emit@endsyllablepartfornextsyllable}{}{gregoriotex-syllable.tex}
Emits the text for the end syllable part if it \emph{is} to be moved to the next syllable. This is used when projecting the next syllable text while processing some syllable.

\macroname{\textbackslash gre@syllable@args}{}{gregoriotex-syllable.tex}
Saves the arguments to \verb=\GreSyllable=. Needed so that \verb=\GreSyllable= can look forward to see if the next token is \verb=\GreBarSyllable=.

\macroname{\textbackslash gre@syllable@expand}{}{gregoriotex-syllable.tex}
Calls \verb=\gre@syllable@act=, passing the arguments saved in \verb=gre@syllable@args=. Needed so that \verb=\GreSyllable= can look forward to see if the next token is \verb=\GreBarSyllable=.

\macroname{\textbackslash gre@syllable@act}{\#1\#2\#3\#4\#5\#6\#7\#8\#9}{gregoriotex-syllable.tex}
Typesets the syllable. Same arguments as \verb=\GreSyllable=. See the description of that macro for more information. Needed so that \verb=\GreSyllable= can look forward to see if the next token is \verb=\GreBarSyllable=.

\macroname{\textbackslash gre@gabcname}{}{gregoriotex-main.tex}
Macro which holds the point-and-click file name.

Expand Down Expand Up @@ -1884,9 +1845,6 @@ \subsection{Flags}
\macroname{\textbackslash ifgre@rewritesyllables}{}{gregoriotex-syllable.tex}
Boolean that enables moving the last part of a syllable to the next if there is no hyphen.

\macroname{\textbackslash gre@attr@dash}{}{gregoriotex-main.tex}
A Lua\TeX\ attribute which indicates whether a syllable takes a dash if it ends a line.

\macroname{\textbackslash gre@attr@center}{}{gregoriotex-main.tex}
A Lua\TeX\ attribute which indicates the type of translation centering.

Expand Down Expand Up @@ -2430,18 +2388,6 @@ \subsection{Distances}
\macroname{\textbackslash gre@skip@minNotesDistance}{}{gregoriotex-spaces.tex}
Minimum distance between notes.

\macroname{\textbackslash gre@dimen@curTextDistance}{}{gregoriotex-spaces.tex}
Current distance between text.

\macroname{\textbackslash gre@dimen@curNotesDistance}{}{gregoriotex-spaces.tex}
Current distance between notes.

\macroname{\textbackslash gre@skip@minShiftText}{}{gregoriotex-spaces.tex}
Minimum shift required for the text.

\macroname{\textbackslash gre@skip@minShiftNotes}{}{gregoriotex-spaces.tex}
Minimum shift required for the notes.

\macroname{\textbackslash gre@scaledist}{}{gregoriotex-spaces.tex}
Working alias for \verb=\gre@skip@temp@one= or \verb=\gre@dimen@temp@one=, as appropriate, used when rescaling a distance due to a change in \verb=\gre@factor=.

Expand Down
48 changes: 30 additions & 18 deletions tex/gregoriotex-main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,28 @@
% an attribute to mark various parts of the score
% 1 = commentary, 2 = stafflines, 3 = initial
% 4 = lyrics, 5 = translation, 6 = alt, 7 = nabc, 8 = nabc below
% 9 = annotation, 10 = notes
\newattribute\gre@attr@part
\edef\gre@attrid@part{\the\allocationnumber}

% an attribute we put on the text nodes.
% if it is 1, it means that there may be a dash here if this syllable is at the end of a line
% if it is 2, it means that it's never useful to typeset a dash
% if it is 0, it just means that we are in a score...
\newattribute\gre@attr@dash

% an attribute used for translation centering
\newattribute\gre@attr@center

\newattribute\GreScoreId

% attributes for tracking glyph heights
\newattribute\gre@attr@glyph@top
\newattribute\gre@attr@glyph@bottom

% attribute for syllable tracking
\newattribute\gre@attr@syllable@id

% attributes for horizontal spacing
% 1 = syllablefinalskip after syllable and penalty
% 2 = from syllable left to text left
% 3 = from text right to notes left
% 4 = from notes right to syllable right
% 5 = clearsyllable
\newattribute\gre@attr@skip@type

% attributes for soft alterations

% Alterations are numbered consecutively starting from 1. If an
Expand Down Expand Up @@ -220,7 +221,11 @@
\ifgre@boxing\else%
\global\gre@lastoflinecount=2\relax %
\ifnum#2=0\relax %
% we have to repeat the end of syllable shifts here because the manual line breaks will occur before we get to the regular shifting code in \GreSyllable
% Place the penalty similarly to how the end-of-syllable penalty
% is placed. However, if the line break occurs mid-syllable,
% these kerns as well as the end-of-syllable kerns will be
% incorrect because they use the enddifference of the whole
% syllable (issue #1738).
\ifdim\gre@dimen@enddifference <0pt\relax%
%% important, else we are not really at the end of the syllable
\kern -\gre@dimen@enddifference\relax%
Expand Down Expand Up @@ -249,6 +254,17 @@
\hfill
\fi
\gre@penalty{-10001}%
% Having placed the penalty, we now return to where we were
% before. Because the penalty is guaranteed to cause a line
% break, these kerns will be discarded because they are at the
% beginning of a line. But we do this so that Lua pre_linebreak
% can measure distances accurately.
\ifdim\gre@dimen@enddifference<0pt
\kern \gre@dimen@enddifference
\fi
\ifgre@eolshiftsenabled
\kern \gre@dimen@eolshift
\fi
\fi
\fi %
%%
Expand Down Expand Up @@ -650,6 +666,7 @@
% #2: 0 = text, 1 = nabc
\def\gre@typesettextabovelines#1#2{%
\gre@trace{gre@typesettextabovelines{#1}{#2}}%
{% localize change to \gre@attr@part
\ifnum#2=0\relax%
\gre@attr@part=6\relax
\else%
Expand Down Expand Up @@ -681,7 +698,7 @@
\endgre@style@abovelinestext
\hss}%
\fi%
\unsetattribute{\gre@attr@part}%
}% restore \gre@attr@part
\gre@trace@end%
}%

Expand Down Expand Up @@ -720,12 +737,10 @@

% Phase 2: Place voice 1 (above staff)
\def\gre@nabc@place@voice@i{%
\gre@attr@part=7\relax%
\gre@dimen@temp@five=\dimexpr(\gre@dimen@staffheight %
+ \gre@space@dimen@spacebeneathtext %
+ \gre@space@dimen@spacelinestext)\relax%
\leavevmode\raise\gre@dimen@temp@five\hbox to 0pt{\unhbox\gre@box@nabc@voice@i\hss}%
\unsetattribute{\gre@attr@part}%
\leavevmode\raise\gre@dimen@temp@five\hbox attr \gre@attrid@part=7 to 0pt{\unhbox\gre@box@nabc@voice@i\hss}%
}%

% Phase 2: Place voice 2 (below staff)
Expand Down Expand Up @@ -1118,8 +1133,6 @@
}%
\gresetnoteadditionalspacelinestext{automatic}%default setting

% gre@attr@dash (see its definition in gregorio-syllable) is 0 when we are in a score, and unset when we are not

\newif\ifgre@beginningofscore%

\newcount\gre@count@stafflines
Expand Down Expand Up @@ -1241,7 +1254,6 @@
\fi %
\gre@computespaces%
\gre@cancelpenalties %
\gre@attr@dash=0\relax %
\gre@generatelines %
\noindent%
\gre@calculate@additionalspaces
Expand Down Expand Up @@ -1289,7 +1301,6 @@
\setbox\gre@box@commentary=\box\voidb@x%
\directlua{gregoriotex.at_score_end()}%
\gre@unset@glyph@heights
\unsetattribute{\gre@attr@dash}%
\xdef\gre@bolshiftcleftypelocal{\gre@bolshiftcleftypeglobal}%
\ifnum\gre@count@lastline=0\relax
\parfillskip=\gre@saved@parfillskip\relax%
Expand All @@ -1301,6 +1312,7 @@
\def\gre@endafterbar#1{%
\gre@trace{gre@endafterbar{#1}}%
\gre@penalty{\the\gre@space@count@endafterbarpenalty }\relax %
{\gre@attr@skip@type=1
\ifnum#1=1\relax %
\gre@debugmsg{ifdim}{ enddifference > 0pt}%
\ifdim\gre@dimen@enddifference > 0 pt\relax%
Expand All @@ -1322,7 +1334,7 @@
\gre@hskip\gre@skip@temp@four %
\fi %
\fi %
\fi %
\fi}%
%\gre@penalty{\the\gre@space@count@endafterbarpenalty }\relax
%\global\gre@dimen@enddifference=0pt
\relax %
Expand Down
Loading