Skip to content

Commit

Permalink
fix(packages): Correct chord line height and chord font use
Browse files Browse the repository at this point in the history
Another item from #1351:
Remove undocumented chormode.lineheight setting.
Its 4mm default where dubious anyway... But it turns how there
was other problems:
- Hook chordmode:chordfont was not applied where expected
- A proper line height computation is likely what one would expect
  so as to avoid overlaps with previous content...
  • Loading branch information
Omikhleia authored and Didier Willis committed May 3, 2023
1 parent a2f3416 commit 65961c6
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/chordmode/init.lua
Expand Up @@ -18,30 +18,29 @@ function package.declareSettings (_)
help = "Vertical offset between the chord name and the text."
})

SILE.settings:declare({
parameter = "chordmode.lineheight",
type = "length",
default = SILE.length("4mm"),
help = "Length of the chord name line."
})
end

function package:registerCommands ()

self:registerCommand("ch", function (options, content)
local chordBox = SILE.typesetter:makeHbox({ options.name })
local chordBox = SILE.typesetter:makeHbox(function ()
SILE.call("chordmode:chordfont", {}, { options.name })
end)
local origWidth = chordBox.width
chordBox.width = SILE.length()
chordBox.height = SILE.settings:get("chordmode.lineheight")

SILE.call("raise", { height = SILE.settings:get("chordmode.offset") }, function ()
SILE.call("chordmode:chordfont", {}, function ()
SILE.typesetter:pushHbox(chordBox)
end)
SILE.typesetter:pushHbox(chordBox)
end)

local lyricBox = SILE.call("hbox", {}, content)
if lyricBox.width < origWidth then
lyricBox.width = origWidth + SILE.length("0.5em"):absolute()
end
local chordLineHeight = chordBox.height + SILE.settings:get("chordmode.offset"):absolute()
if chordLineHeight > lyricBox.height then
lyricBox.height = chordLineHeight
end
end, "Insert a chord name above the text")

local function _addChords (text, content)
Expand Down

0 comments on commit 65961c6

Please sign in to comment.