Skip to content

Commit

Permalink
Fix calculation of line height in StaticText.
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan Crooks authored and philer committed Mar 3, 2023
1 parent ed2d5ff commit 736f83d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/widget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,13 @@ function StaticText:init(text, args)
Text.init(self, args or {})

self._lines = {}
local _, line_count = text:gsub("[^\n]*", function(line)
text = text .. "\n"

for line in text:gmatch("(.-)\n") do
table.insert(self._lines, line)
end)
self.height = line_count * self._line_height
end

self.height = #self._lines * self._line_height
end

function StaticText:render_background(cr)
Expand Down

0 comments on commit 736f83d

Please sign in to comment.