Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline initial #1491

Open
wants to merge 65 commits into
base: ctan
Choose a base branch
from

Conversation

rpspringuel
Copy link
Contributor

With some significant refactoring and bug-fixing along the way, this PR is about supporting initials of an arbitrary number of lines explicitly.

Right now I've got two "modes" for doing so:

  1. manual - each line which wraps the initial must be manually ended in the gabc (z or Z). This is the way 2-line initials are currently supported and so is set as the default.
  2. semi-manual - the last line that wraps the initial must be manually ended in the gabc. Should be slightly easier to use, but can lead to the initial overlapping full width staves when the manual line ending is far too early.

I'd like to make something which is fully automatic, but have yet to come up with a good way of tracking the automatic line endings. I've identified a point in the post_linebreak function where the line numbers are increasing as expected, but I'm not sure how, or even if, I can resize the lines on the lua side. Hence, I'm posting this here for some feedback.

Note: This still needs some documentation work and so is not ready for merge.

There was a whole bunch of repeated code on both branches of several if statements.  I've pulled that code out to reduce the if branches down to the absolute minimum.
The gre@biginitial flag is redundant.  The same information can be found out by checking the value of gre@count@initiallines.
I don't know what circumstances led to this backup being put into place, but I the whole test suite passes without it, so I don't think it's necessary anymore.
We want to identify gre@knownline as a count
Also adding in debug messages associated with knownline to help with the identification of when lines are processed (eventually so we can adjust the staff lines at the right places).
initialraise is already accounted for when \gre@dimen@temp@five is first established (line 402).  It doesn't need to be double counted for the large initial.
This makes the height placement of the initial a function of the number of lines which wrap it rather than a fixed amount.  It doesn't change anything for the 1 or 2 line initials, just makes it so that when 3 (or more) line initials are implemented, this calculation will be ready for them.
As staff lines with fewer or more than 4 lines have different heights so the position of the initial needs to be adapted as appropriate.  This change fixes the new tests introduced in gregorio-project/gregorio-test@8713c85 (and amended in gregorio-project/gregorio-test@d8829fc).
We already calculate the staffheight and don't need to calculate it again here.
Note: making this change reveals an off-by-one error in the manual calculation: there was an extra interstafflinespace.  The number of spaces between the lines is one less than the number of lines: line-space-line
In line with 8106316 these are calculations which should have been using staffheight but weren't.
Also found another off-by-one error in the placement of the above lines text.  This was hidden by the fact that the size of the lyrics wasn't being taken into account.
The change in gregoriotex-signs.tex did not have an off-by-one error because we're drawing the ledger line exactly one interstafflinespace above the staff.  Hence, when we change to using staffheight, we still need one more factor of interstafflinespace
A pretty basic simplification of a calculation.
In semi-manual mode, only the last line of the lines wrapping the initial needs to be indicated manually (as opposed to the manual mode, where each line must be indicated).
@rpspringuel
Copy link
Contributor Author

Hmm... Another thing I noticed that still needs fixing:

Right now the placement of the initial is based purely on the height of the first line (multiplied by the appropriate number of lines to lower the initial when the initial is wrapped by more than one line). Since the subsequent lines could be slightly taller or shorter, this means that 2 or more line initials may be slightly higher or lower than they ought to be (in the test case, they're all higher). Ideally I should access the actual heights of the second (and later) lines when they wrap the initial.

@rpspringuel
Copy link
Contributor Author

I've done some more research on this and am rapidly coming to the conclusion that implementing the fully automatic multi-line initial may require changing how the lines are drawn: going from using \localleftbox to having post_linebreak do it. That's a bit beyond my current skills, but I'll keep plugging away at it.

@rpspringuel rpspringuel linked an issue Feb 4, 2021 that may be closed by this pull request
Accidentally removed this when merging other branches in.
Since there are only two possible states, the code can be simplified if this flag is a boolean.
@henryso
Copy link
Contributor

henryso commented Jan 20, 2024

@rpspringuel I realize this is way late. I've been off the scene for a while due to family issues. I looked at your commit, and I can't tell why it's not working. Maybe it's some collapsed measurement in TeX, but I don't think I understand TeX at that level to give a good answer.

At least on my system, the folder created is `_minted` with nothing appended.  In case other systems append something (like a version number) I retain the wildcard, but remove the hyphen separator.
Even though there's nothing to be done during a build operation in these folders, they need to have a Makefile generated so that the files they contain will be properly added to a distribution.
For each line, baselineskip forms a minimum line height, so we need to check against that on a line by line basis and adjust our initial placement by that if it's bigger than the nominal height of the line.  Since we're already looping over the lines in Lua, this is much easier on the Lua side, but that means Lua needs to look at the fixed height stuff too, so while we still calculate the base amount in TeX, we no longer add it directly to the initial position adjustment amount there.
When there is no line height information (either because it's the first pass and thus no gaux file exists or because the score simply has no elements which would require that information) the initial still needs to align down with the lower line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arbitrary number for \gresetinitiallines
5 participants