Skip to content

Chordrest accidental layout is sub-par #32

@ajyoon

Description

@ajyoon

Chordrest currently uses a very basic algorithm for laying out accidentals - it works through the accidentals from top to bottom, and if a bounding rect collision with the previous accidental is found (and that previous accidental is not shifted), it shifts the accidental to the left edge of the previous accidental's bounding rect. This works for many cases, but causes bad results for some common cases like these:

accidentals

Users can currently work around this by manually adjusting X positions of accidental glyphs with something like:

staff = Staff(ORIGIN, None, Mm(100))
Clef(ZERO, staff, "treble")
c = Chordrest(Mm(10), staff, ["gb", "an", "bb"], (1, 8))
c.accidentals[0].x -= ...

But this is very tedious and modifications don't survive chord rebuilds (which can be triggered by things like beaming). We should implement an accidental layout algorithm according to standard notation conventions. From what I've seen the rules are pretty complicated, so it may be an involved fix. A proper solution should also take into account glyph cutouts provided by SMuFL for this purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions