Open edonv opened 6 days ago
Can you share a small sample song (+ config) so I can reproduce this?
Adding overflow="visible"
won't help since that is not handled by the SVG processor that ChordPro uses. But maybe there are other alternatives.
Here's a zip containing all the relevant files. Let me know if something is weird. I'm not passing any extra arguments to the command, just specifying the primary "chordpro.json" file I included, the .cho
file is the input, and I'm outputting to the same file name but with .pdf
.
I cannot reproduce this. Can you also share crave.pdf
?
Thanks. As you already assumed the problem is a mismatch of font metrics. LilyPond is formatting with the metrics of Times Bold and ChordPro is rendering the resultant SVG with font RobotoSerif.
If you run ChordPro with --define debug.svg=1
you'll see a couple of messages:
vb -0.0600 -5.1653 90.8544 13.6483 => bb -0.06 -8.48 90.79 5.17
SVG: Font LilyPond Serif (bold) ....
SVG: Font robotobolditalic|normal|normal ....
(The exact names may depend on your system font config)
So when you specify TabNoteHead.font-family = #'roman
, LilyPond uses Times-Bold metrics and uses font family LilyPond Serif
with style bold
in the SVG. In the fontconfig you can map this:
"lilypond serif": {
"bold": "Times-Bold",
}
Now LilyPond and ChordPro use the same font metrics and the image will not be clipped.
Awesome, thanks!
I'm actually not having much luck. Should I still be setting TabNoteHead.font-family = #'roman
or using #(define fonts (set-global-fonts ...))
too? Between different combinations, I'm either still getting the cut-off, or just getting Times-Bold instead.
For me, this works (I have LilyPond 2.25):
In the preamble:
\paper {
property-defaults.fonts.serif = "Roboto Serif"
...
}
\context {
\TabStaff
...
\override TabNoteHead.font-family = #'serif"
}
In the fontconfig:
"Roboto Serif" : {
"": "RobotoSerif-Regular.ttf"
"bold": "RobotoSerif-Bold.ttf"
}
Running ChordPro with --def debug.svg=1
shows:
vb -0.0600 -5.1478 90.8554 13.6352 => bb -0.06 -8.49 90.80 5.15
SVG: Font roboto serif|normal|bold found in font config: /home/jv/.fonts/RobotoSerif-Bold.ttf
SVG: Font robotobolditalic|normal|normal found in font config: /home/jv/.fonts/Roboto-BoldItalic.ttf
The end result uses Roboto Serif for the TabNoteHeads, and there is no clipping.
LilyPond uses fontconfig so you can verify that it does use the right font:
% fc-match "roboto serif :style=bold"
RobotoSerif-Bold.ttf: "Roboto Serif" "Bold"
Does this help?
Describe the bug
Sometimes, the output SVG from Lilypond isn't perfectly in the bounds of the cropped SVG. This might be due to the possibility of it not knowing the size of the text due to the font changing once embedded in the PDF and uses the PDF's font settings.
The solution might just be to add
overflow="visible"
to the SVG itself once generated?Or I also could just set the right font for Lilypond in its settings, but this might be more easily fixable at the start.
Attachments
System information
Additional context
In my situation, I have
TabNoteHead.font-family = #'roman
, which internally defaults to Times New Roman. But in ChordPro'spdf.fontconfig
, theserif
family is set to Roboto Serif.