diff --git a/0028-A b/0028-A index 52d94cd..ef6ad2e 100644 --- a/0028-A +++ b/0028-A @@ -1,4 +1,5 @@ A = function(preserve_screen_top_of_cursor_node) + love.graphics.setFont(love.graphics.newFont(scale(20))) -- editor objects implicitly depend on current font -- translate Page to Surface while #Surface > 3 do table.remove(Surface) end -- HACK local red = false @@ -13,4 +14,4 @@ A = function(preserve_screen_top_of_cursor_node) -- continue the pipeline B(preserve_screen_top_of_cursor_node) -- TODO: ugly that we're manipulating editor objects twice -end \ No newline at end of file +end diff --git a/0030-update_editor_box b/0030-update_editor_box index 68fa010..0ef9fe1 100644 --- a/0030-update_editor_box +++ b/0030-update_editor_box @@ -1,16 +1,21 @@ update_editor_box = function(node, preserve_screen_top_of_cursor_node) if node.editor == nil then return end - if node.y > Viewport.y then + -- Compute screen_top1 in viewport coordinates because the editor's font takes scaling into account. + if vy(node.y) > 0 then if not preserve_screen_top_of_cursor_node or node ~= Cursor_node then node.editor.screen_top1.line = 1 node.editor.screen_top1.pos = 1 end node.editor.top = vy(node.y) else - node.editor.screen_top1, node.editor.top = schema1_of_y(node.editor, Viewport.y - node.y) + node.editor.screen_top1, node.editor.top = schema1_of_y(node.editor, -vy(node.y)) + end + if node.editor.font_height ~= scale(20) then + edit.update_font_settings(node.editor, scale(20)) end node.editor.left = math.floor(vx(node.x)) node.editor.right = math.ceil(vx(node.x+node.w)) + node.editor.width = node.editor.right - node.editor.left edit.update_font_settings(node.editor, scale(20)) Text.redraw_all(node.editor) -end \ No newline at end of file +end