aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-03-11 06:57:40 -0400
committerjgmdev <jgmdev@gmail.com>2022-05-22 13:16:10 -0400
commitcb965ffffc17804c57832d1871d56d37a6f8f5e1 (patch)
treed831bcaeae5b6bfe2358b3f95bba6d8218f182c6 /plugins
parentb05f35fef02d51e210c20b09fcd3e042c5d8ef20 (diff)
downloadlite-xl-plugins-cb965ffffc17804c57832d1871d56d37a6f8f5e1.tar.gz
lite-xl-plugins-cb965ffffc17804c57832d1871d56d37a6f8f5e1.zip
bigclock: fixed fonts loading and improved performance by copying only on scale changes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/bigclock.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/bigclock.lua b/plugins/bigclock.lua
index a7b4958..1f38b02 100644
--- a/plugins/bigclock.lua
+++ b/plugins/bigclock.lua
@@ -21,6 +21,7 @@ function ClockView:new()
ClockView.super.new(self)
self.time_text = ""
self.date_text = ""
+ self.last_scale = 0
end
@@ -30,14 +31,18 @@ end
function ClockView:update_fonts()
+ if self.last_scale ~= config.plugins.bigclock.scale then
+ self.last_scale = config.plugins.bigclock.scale
+ else
+ return
+ end
local size = math.floor(self.size.x * 0.15 / 15) * 15 * config.plugins.bigclock.scale
if self.font_size ~= size then
- self.time_font = renderer.font.load(DATADIR .. "/fonts/font.ttf", size)
- self.date_font = renderer.font.load(DATADIR .. "/fonts/font.ttf", size * 0.3)
+ self.time_font = renderer.font.copy(style["font"], size)
+ self.date_font = renderer.font.copy(style["font"], size * 0.3)
self.font_size = size
collectgarbage()
end
- return self.font
end