ChordPro / chordpro

Reference implementation of the ChordPro standard for musical lead sheets.
Other
326 stars 52 forks source link

Unable to use italic font in embedded Lilypond section #455

Open edonv opened 2 weeks ago

edonv commented 2 weeks ago

Describe the bug

I'm trying to use an italic font for chord names in an embedded Lilypond section, so it can mirror the rest of my ChordPro file, but I can't get it to render italics, no matter what font. I've tested with multiple fonts, and though different font weights work, italics in any of the fonts is either ignored or causes it to reject the font altogether.

I've also tested the exact same Lilypond content (with the intended font) directly through lilypond CLI and italics work without issue. I even tested this with the temp .ly file ChordPro creates to embed the section, and it works without issue.

Additionally, embedded Lilypond actually does read the font from the ChordPro config pdf.fontconfig (in this case I'm using sans), but it still won't take the italic version.

To Reproduce

I've tested:

Lilypond formatting (setting font name directly)

\layout {
  \context {
    \ChordNames
    \override ChordName.font-name = "Roboto Bold Italic"
  }
}

Lilypond formatting (setting font family)

\paper {
  #(define fonts
    (set-global-fonts
     #:sans "Roboto"
    ))
}
\layout {
  \context {
    \ChordNames
    \override ChordName.font-family = #'sans
    \override ChordName.font-series = #'bold
    \override ChordName.font-shape = #'italic
  }
}

Lilypond content:

\score {
  <<
    \chords {
      g1 e:m c d
    }
    \new TabStaff \relative {
      \omit Staff.Clef
      \numericTimeSignature
      \repeat volta 2 {
        \bar ".|:"
        a8\glissando b4.\3~ b4\3 \grace { \once \omit Stem \stemDown e8\2 \glissando \stemNeutral } fis4\2 |
        e1\2 |
        a,8\3 ( g4.\3)~ g4 a8\glissando d\3~ |
        d\3 d\3( c\3) c\3( b\3) b\3( a\3) a\3 |
      }
    }
  >>
}

Attachments

{start_of_ly}
\layout {
  \context {
    \ChordNames
    \override ChordName.font-family = #'sans
    \override ChordName.font-series = #'bold
    \override ChordName.font-shape = #'italic
  }
}

\score {
  <<
    \chords {
      g1 e:m c d
    }
    \new TabStaff \relative {
      \omit Staff.Clef
      \numericTimeSignature
      \repeat volta 2 {
        \bar ".|:"
        a8\glissando b4.\3~ b4\3 \grace { \once \omit Stem \stemDown e8\2 \glissando \stemNeutral } fis4\2 |
        e1\2 |
        a,8\3 ( g4.\3)~ g4 a8\glissando d\3~ |
        d\3 d\3( c\3) c\3( b\3) b\3( a\3) a\3 |
      }
    }
  >>
}
{end_of_ly}

Lilypond directly:

Lilypond directly

Embedded in ChordPro file:

Embedded in ChordPro file

System information

Additional Notes

Looks like the tablature font is different, but that's not a big deal, I actually am very happy with the font that ChordPro provides for Lilypond's tablature.

sciurius commented 2 weeks ago

You have found a subtile but nasty bug in the SVG renderer that ChordPro uses. I will fix that for the next version.

In the mean time, you can try the following workaround:

-- config file:

pdf.fontconfig.sansbolditalic {
      ""         : Helvetica-BoldOblique
      bold       : Helvetica-BoldOblique
      italic     : Helvetica-BoldOblique
      bolditalic : Helvetica-BoldOblique
}

and in the LilyPond fragment:

  \context {
    \ChordNames
    \override ChordName.font-name = "sansbolditalic"
  }
}
sciurius commented 2 weeks ago

https://github.com/sciurius/perl-SVGPDF/issues/10

edonv commented 2 weeks ago

That workaround worked! Thanks!