Merge template-live-editor
Currently A() leaks fonts, but B() does not.
This commit is contained in:
commit
b32a60548f
4
0019-B
4
0019-B
|
@ -1,5 +1,6 @@
|
||||||
B = function()
|
B = function()
|
||||||
-- recompute various aspects based on the current viewport settings
|
-- recompute various aspects based on the current viewport settings
|
||||||
|
local font = nil
|
||||||
for _,obj in ipairs(Surface) do
|
for _,obj in ipairs(Surface) do
|
||||||
if obj.type == 'line' then
|
if obj.type == 'line' then
|
||||||
obj.zdata = {}
|
obj.zdata = {}
|
||||||
|
@ -16,7 +17,8 @@ B = function()
|
||||||
obj.zdata = love.math.newBezierCurve(zdata):render()
|
obj.zdata = love.math.newBezierCurve(zdata):render()
|
||||||
elseif obj.type == 'text' then
|
elseif obj.type == 'text' then
|
||||||
if obj.w then
|
if obj.w then
|
||||||
update_editor_box(obj)
|
update_editor_box(obj, font)
|
||||||
|
if obj.editor and obj.editor.font then font = obj.editor.font end
|
||||||
else
|
else
|
||||||
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
|
obj.text = love.graphics.newText(love.graphics.getFont(), obj.data)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
update_editor_box = function(node)
|
update_editor_box = function(node, font)
|
||||||
if node.editor == nil then return end
|
if node.editor == nil then return end
|
||||||
edit.update_font_settings(node.editor, scale(20))
|
edit.update_font_settings(node.editor, scale(20), font)
|
||||||
node.editor.left = math.floor(vx(node.x))
|
node.editor.left = math.floor(vx(node.x))
|
||||||
node.editor.right = math.ceil(vx(node.x+node.w))
|
node.editor.right = math.ceil(vx(node.x+node.w))
|
||||||
node.editor.width = node.editor.right - node.editor.left
|
node.editor.width = node.editor.right - node.editor.left
|
||||||
|
|
4
edit.lua
4
edit.lua
|
@ -379,9 +379,9 @@ end
|
||||||
function edit.key_release(State, key, scancode)
|
function edit.key_release(State, key, scancode)
|
||||||
end
|
end
|
||||||
|
|
||||||
function edit.update_font_settings(State, font_height)
|
function edit.update_font_settings(State, font_height, font)
|
||||||
State.font_height = font_height
|
State.font_height = font_height
|
||||||
State.font = love.graphics.newFont(State.font_height)
|
State.font = font or love.graphics.newFont(State.font_height)
|
||||||
State.line_height = math.floor(font_height*1.3)
|
State.line_height = math.floor(font_height*1.3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue