From 2594d54ec414b55da3f5fa1950abb24c08db935a Mon Sep 17 00:00:00 2001 From: jgmdev Date: Mon, 31 May 2021 20:24:25 -0400 Subject: Fix scale plugin to work with latest lite-xl font. --- plugins/scale.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'plugins/scale.lua') diff --git a/plugins/scale.lua b/plugins/scale.lua index b63611c..0d07286 100644 --- a/plugins/scale.lua +++ b/plugins/scale.lua @@ -15,11 +15,24 @@ local scale_level = 0 local scale_steps = 0.1 local font_cache = setmetatable({}, { __mode = "k" }) +-- default lite fonts +local regular_font = "font.ttf" +local monospace_font = "monospace.ttf" + +-- Set font names properly to work with latest lite-xl changes +if io.open(DATADIR .. "/fonts/FiraSans-Regular.ttf", "r") then + regular_font = "FiraSans-Regular.ttf" +end + +if io.open(DATADIR .. "/fonts/JetBrainsMono-Regular.ttf", "r") then + monospace_font = "JetBrainsMono-Regular.ttf" +end + -- the following should be kept in sync with core.style's default font settings -font_cache[style.font] = { DATADIR .. "/fonts/font.ttf", 14 * SCALE } -font_cache[style.big_font] = { DATADIR .. "/fonts/font.ttf", 34 * SCALE } +font_cache[style.font] = { DATADIR .. "/fonts/" .. regular_font, 14 * SCALE } +font_cache[style.big_font] = { DATADIR .. "/fonts/" .. regular_font, 34 * SCALE } font_cache[style.icon_font] = { DATADIR .. "/fonts/icons.ttf", 14 * SCALE } -font_cache[style.code_font] = { DATADIR .. "/fonts/monospace.ttf", 13.5 * SCALE } +font_cache[style.code_font] = { DATADIR .. "/fonts/" .. monospace_font, 13.5 * SCALE } local load_font = renderer.font.load -- cgit v1.2.3