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 28 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.
@rpspringuel
Copy link
Contributor Author

Full automation is going to require a full rewrite of how line drawing is handled, so I'm going to separate out that feature for now.

@henryso what's the easiest way to access the total height of a specific line of a score (as determined on the previous run)?

@rpspringuel
Copy link
Contributor Author

I'm working on accounting for actual line heights and came across a "magic number" in the \gre@calculate@additionalspaces: 15750 sp (it also appears in \gre@calculate@glyphraisevalue).

Based on how it's being used, it appears to be like it's supposed to be the amount of additional space to add for excessively high/low elements. Does any one know why this calculation isn't using noteadditionalspacelinestext? @henryso @eroux? The value is not exactly the same (once scaled for the default 17 staff size) but is really close (0.1436cm vs the 0.14413cm in notesadditionalspacelinestext).

@rpspringuel
Copy link
Contributor Author

After some painstaking traces through the git history concerning this magic number and noteadditionalspacelinestext it appears that the magic number was introduced when additional space above the lines for high notes was implemented while noteadditionalspacelinestext was introduced when additional space below the lines for low notes was implemented (the name being a variation of spacelinestext: the nominal distance between the lines and the lyrics baseline). It would thus appear that this magic number should be replaced by a new distance noteadditionalspaceabovelines (the name being a variation of spaceabovelines: the nominal distance above the lines). If there are no objections to this solution, I will implement it as part of this PR.

@rpspringuel rpspringuel mentioned this pull request Feb 10, 2021
@rpspringuel
Copy link
Contributor Author

Getting the line height adjustments for variable line heights right is proving much harder than expected. @henryso, can you look at the code in my most recent commit (39d9496) and see if I'm doing anything blatantly wrong. Things aren't lining up as I would expect them to and I'm trying to figure out if that's do to my not understanding the way the line height information is stored and used, or if it's because there's something more subtle in the way the spacing around lines works.

@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.

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
2 participants