Repository navigation
feat(rendering): place hammer-on, pull-off and slide labels above the staff and improve effect annotation spacing - #2945
Merged
Conversation
…staff The H/P/sl. labels were painted on the slur arcs, which put them below or inside the staff for lower arcs, lost labels of other notes in a chord and even showed effect labels on regular slurs. Like Guitar Pro and MuseScore the labels are now effect bands above the staff (standard notation, tab and numbered): one label per beat for all notes of a chord, centered between the beats of the segment (or up to the system end when the effect continues on the next system), with slide labels stacked above hammer-on/pull-off labels.
The height the effect bands add to a bar's overflow was the growth of the staff skyline in the bar's range during placement. The skyline before placement also holds content of other bars reaching into the bar (ties, brackets) and misses content registered as overflow only, so the reserved height was too small (bands cut at the top of the system) or too large (extra space between staves). The bands now reserve what they need from their final position relative to the bar's own content overflow.
Only vertical spacing drift: identical content, every gap changed by at most 2px (the reserved band height is now rounded once instead of twice).
Different texts of one label kind (H on one string, P on another) were joined side by side; they are now stacked, the label of the higher note on top. The end of a segment starting on a grace note was not found, because grace notes share the display start of their main note.
Bands were placed with the union of all their glyphs in a bar, so markers of another effect could never use the gaps between them (e.g. a slide label between hammer-on/pull-off labels, or a tap marker next to them). Note-attached bands now place each glyph on its own range, all glyphs of a band still share one height. A glyph can keep a wider range clear than it occupies: the slur labels keep their whole segment clear, so they stay above fret numbers and noteheads of the segment while other markers can still sit next to them.
…t effects The text was centered on the font's middle line at half its measured (ink) height. For texts without descenders (Fine, To Coda) the ink then reached above the glyph and was cut at the top of the system.
Placing note-attached markers glyph by glyph and checking the content of adjacent staves only compared the skylines at the same x positions, so content right next to each other could touch (pick strokes next to stems, fingering numbers next to stems of the staff above). The clearance range of placed markers and the staff content padding check are widened by their padding.
Widening the staff content check by the full vertical staff padding treated content up to a stave-space next to each other as stacked and added space where none is needed. Horizontally the half stave-space minimum distance between characters (beat content padding, Behind Bars) is used instead.
…kers horizontally Widening the clearance range of every note-attached marker by the band padding moved markers like bar numbers up for content nearby that they do not belong to. Markers attached to a beat now keep the noteheads and stems of their own beat clear (e.g. a pick stroke above the stem of its note); markers placed per bar are not widened.
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.
Note
AI-authored disclosure (
alphatab-ai-authored-v1)Portions of this content were authored by an AI agent. The agent has read
AGENTS.md and the human submitter accepts responsibility for
compliance with the rules in that document.
Issues
Fixes #2944
Proposed changes
H / P / sl. labels as effect bands above the staff
The labels were painted on the slur arcs, which put them below the tab staff for lower arcs, lost labels when a
chord mixed kinds and showed a label per arc. Like Guitar Pro and MuseScore they are now annotations above the
staff for standard notation, tab and numbered notation:
existing
EffectHammerOnPullOffText/EffectSlideTextnotation elements keep controlling their visibility.one kind (H on one string, P on another) and different kinds ("sl." above "H") are stacked with the usual band
padding.
system, centered up to the system end; the continuation gets no label.
glyphs. The label code of the tie/slur glyphs is removed, which also stops regular slurs from showing effect
labels.
Effect band placement and spacing
reserved height was derived from the skyline growth during placement, which also contained content of other
bars (ties, brackets) and missed content registered only as overflow. Bands could be cut at the top of a
system or leave too much space (e.g. sustain pedal markings). The height is now rounded once instead of twice,
which moves many references by 1–2px.
as one block per bar, so markers of different effects can share a row in the gaps between each other. All
glyphs of a band still share one height.
fret numbers and noteheads of the segment), markers attached to a beat keep the noteheads and stems of their
own beat clear (e.g. a pick stroke above the stem of its note).
½ stave-space (Behind Bars), not only content at the same x position.
middle line their ink reached above the reserved space.
Known limitations (not addressed here)
padding this occasionally adds a stave-space where the ink of two annotations is just far enough apart.
Tests
breaks.
Checklist
AI authorship disclosure
(
alphatab-ai-authored-v1) is present at the top of this body, and I havepersonally reviewed every change and can explain each one
Further details