Last active
June 2, 2020 08:09
-
-
Save 6r1d/cbda84c5acbd11ba53a6cb3a6b4d0008 to your computer and use it in GitHub Desktop.
Lite font update experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- style.lua | |
-- First, I tried altering `style.lua` to add `fscale` attribute and a function to update style. | |
style.set_font = function() | |
style.padding = { x = common.round(14 * style.fscale), y = common.round(7 * style.fscale) } | |
style.divider_size = common.round(1 * style.fscale) | |
style.scrollbar_size = common.round(4 * style.fscale) | |
style.caret_width = common.round(2 * style.fscale) | |
style.tab_width = common.round(170 * style.fscale) | |
style.font = renderer.font.load(EXEDIR .. "/data/fonts/font.ttf", 14 * style.fscale) | |
style.big_font = renderer.font.load(EXEDIR .. "/data/fonts/font.ttf", 34 * style.fscale) | |
style.icon_font = renderer.font.load(EXEDIR .. "/data/fonts/icons.ttf", 14 * style.fscale) | |
style.code_font = renderer.font.load(EXEDIR .. "/data/fonts/monospace.ttf", 13.5 * style.fscale) | |
end | |
style.fscale = SCALE | |
style.set_font() | |
-- view.lua | |
-- I modified view to add "zoom in", "zoom out" and "zoom reset" functionality | |
function View:zoom_in() | |
style.fscale = style.fscale + 0.5 | |
style.set_font() | |
end | |
function View:zoom_out() | |
style.fscale = style.fscale - 0.5 | |
style.set_font() | |
end | |
function View:zoom_base() | |
style.fscale = SCALE | |
style.set_font() | |
end | |
-- Keymap.lua | |
["ctrl++"] = "view:zoom_in", | |
["ctrl+-"] = "view:zoom_out", | |
["ctrl+0"] = "view:zoom_base" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment