pothi.love/0317-box_height

22 lines
866 B
Plaintext
Raw Normal View History

box_height = function(node)
-- return the height of a node. The result is scaled.
print('computing box height based on font size', node.scaled_fontsize, node.editor.font_height, node.editor.line_height)
if #node.editor.lines > 1 then Box_heights = {} end
local y = 0
for i=1,#node.editor.lines do
local line = node.editor.lines[i]
if node.editor.line_cache[i] == nil then
node.editor.line_cache[i] = {}
end
node.editor.line_cache[i].fragments = nil
node.editor.line_cache[i].screen_line_starting_pos = nil
Text.compute_fragments(node.editor, i)
Text.populate_screen_line_starting_pos(node.editor, i)
y = y + node.editor.line_height*#node.editor.line_cache[i].screen_line_starting_pos
if #node.editor.lines > 1 then
table.insert(Box_heights, y)
end
Text.clear_screen_line_cache(node.editor, i)
end
return y
end