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

Ledger Line confusion #79

Open
bitsybabe opened this issue May 19, 2023 · 2 comments
Open

Ledger Line confusion #79

bitsybabe opened this issue May 19, 2023 · 2 comments

Comments

@bitsybabe
Copy link

bitsybabe commented May 19, 2023

I am attempting to create a dynamic staff that adds ledger lines above or below the staff, as needed by the pitch.

I am using characters E010-E014 to represent 1 - 4 lines. The code I wrote was tested using E012, the 3 ledger line glyph, because that's roughly the maximum I'd use. The code places the glyph at a certain y-offset to the staff and adds +1 to the note's x-offset so it looks centered on the note.

Then I tested the 2-line glyph, E011. Instead of being at the same offset, it's at a completely different offset. In fact EACH of the ledger lines has a UNIQUE offset!

This is completely odd to me. WHY wouldn't you have kept the lines in the same place as you add them? They are the same distance apart, why could they not be the same position in the glyph frame?

I'm sure if Steinberg is using this font, there must be a better way to add ledger lines than what I thought: determine the offset and just change the glyph as the pitch rises or falls. Now, it looks like I not only have to change the glyph, but its offset! No bueno. WHY? Shouldn't glyphs in a font all have a common baseline?

Can someone please explain to me why this is awesome?

Screen Shot 2023-05-19 at 5 47 56 PM
@bitsybabe
Copy link
Author

bitsybabe commented May 19, 2023

Just as additional context, I'll paste my code here. It's in Swift.

  var body: some View {
    VStack() {
      ZStack() {
        Text(ledger3).offset(x: 41, y:(-1 * (staffMult*trebleLedgers[2])))
        HStack() {
          Text(accidental + " " + (stemUp ? halfNoteUp : halfNoteDn)).offset(x: 40, y:(4.5*5))
        }
        Text(ledger3).offset(x: 41, y: (staffMult*bassLeddgers[2]))
      }
      Text("\(noteOffset)")
    }.font(.custom("Bravura", size: 36))
    .onChange(of: semitones) { _ in
      updateValues()
    }
  }
}

In the attached screenshots, you can see the result of this exact code. Then, you can see the result if I remove one line and use E011 instead of E012. The lines are in completely different positions, making not only the note invalid, but the notation invalid!

Screen Shot 2023-05-19 at 6 00 48 PM

@StephenBuley
Copy link

StephenBuley commented May 26, 2023

Ah @bitsybabe I finally got around to reading your issue - you are using E011 offset to be two ledger lines together, but E011 is actually "staff2Lines", whereas "legerLine" is E022. See this page for what I am talking about. Maybe this answers both of our questions? I can use what you've been using and you can use what I've been using?

Edit: Just realized I already tried offsetting the staff using staffPosRaise[x], staffPosLower[x] etc., but it doesn't work - were you doing this by offsetting the actual font instead of the glyph?

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

No branches or pull requests

2 participants