Add configurable NABC horizontal alignment#1722
Open
lbssousa wants to merge 7 commits intogregorio-project:developfrom
Open
Add configurable NABC horizontal alignment#1722lbssousa wants to merge 7 commits intogregorio-project:developfrom
lbssousa wants to merge 7 commits intogregorio-project:developfrom
Conversation
When \gresetnabcalignment{neume}{center} is active, NABC neumes were
centered over the width of the first glyph only. For multi-glyph
elements (e.g. tristropha jjj) and multi-element neumes (e.g. scandicus
flexus fh/ji), this produced visually wrong centering.
The fix defers NABC placement when center alignment is active. The
element advance (all glyph widths + inter-glyph/inter-element spacing)
is accumulated through GreEndOfGlyph and GreEndOfElement. At end of
syllable (or next GreNABCNeumes), the deferred NABC is placed centered
over the full accumulated advance.
During the boxing pass and tight rendering, immediate placement is used
(no deferral) since the element advance is not meaningful there.
When center alignment is active and a voice's NABC is empty on the
next element, the centering now extends to span that element as well.
Previously, \GreNABCNeumes flushed ALL pending voices at once; now it
flushes only the voice being replaced, allowing other voices to keep
accumulating advance.
Changes:
- Add per-voice advance start registers (\gre@dimen@nabc@advance@start@i/ii)
that record the element advance at the moment each voice enters
pending state
- New \gre@nabc@flush@deferred@voice{<suffix>} macro flushes a single
voice: kerns back by (advance - start), centers, kerns forward
- \gre@nabc@flush@deferred@halign now delegates to per-voice flush
- \GreNABCNeumes flushes only the voice matching #1 instead of all
- \gre@nabc@place@voice@i/ii record advance start when entering pending
The @now placement macros overwrite \gre@dimen@temp@five with the vertical raise amount. Using that same register for the horizontal span caused the kern-forward after placement to use the wrong value, breaking NABC line 2 (below-staff) positioning. Switch to \gre@dimen@temp@one which is not touched by @now.
When center-aligning NABC glyphs over elements (neume mode), voices that had no NABC on a subsequent element would remain pending across element boundaries. This caused their centering span to grow to include the inter-element space and the next element's width, resulting in NABC glyphs displaced far from their correct position. Fix: call \gre@nabc@flush@deferred@halign at the very beginning of \GreEndOfElement, before penalty/space insertion. This ensures each voice's centering span is bounded by its element's glyphs. Note: the \ifgre@nabc@halign@pending block that accumulated inter-element space into elementadvance is now dead code (since we flush before reaching it), but is kept for forward compatibility with the nabcinterglyphmingap branch, which replaces it with \gre@nabc@reduce@rightbalance.
When font resolution combines an LS (significative letter) with the base neume into a single combined glyph (e.g. 'pulsnt3' in grelaon), the post-resolution lwidths loop finds ls[i]='' and accumulates zero width. This caused lwidths[12] (right overflow) to be 0 even when the neume has right-side LS, making the centering formula in neume mode center the entire glyph (including LS) instead of just the neume part. Fix: compute LS widths from the original ls[] entries BEFORE font resolution clears them for combined glyphs. Use these pre-resolution widths (overflow_left, overflow_right) for the alignment overflow dimensions passed to TeX, while keeping the post-resolution lwidths for add_ls positioning of separately-rendered LS parts.
When center-aligned NABC placement is deferred across element boundaries, a line break at GreEndOfElement can move pending NABC rendering to the next line, visually detaching neumes from their corresponding GABC notes (e.g. ves(...hh|ds1|bv...)). Force end-of-element to be unbreakable while NABC halign is pending so the deferred flush stays on the same line as its glyph context.
eb30277 to
734fa4a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Only
leftandcenteralignment options were implemented. It's possible to add arightoption as well, but I believe this is unlikely to be useful.Fixes #1665.