aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco <francesco.bbt@gmail.com>2021-06-01 19:17:30 +0200
committerGitHub <noreply@github.com>2021-06-01 19:17:30 +0200
commitfee5e9d07d761e8047c93d42d7149163994d7e83 (patch)
treea466467187cc88fd66b6d34110d3b1465cd41385
parent31cca1ab3239b920c544cc80d9d702abf6920499 (diff)
parent19167f6359ab70664d7b4e6a07d535f39a2623b6 (diff)
downloadlite-xl-plugins-fee5e9d07d761e8047c93d42d7149163994d7e83.tar.gz
lite-xl-plugins-fee5e9d07d761e8047c93d42d7149163994d7e83.zip
Merge pull request #20 from jgmdev/scale-fix
Fix scale plugin to work with latest lite-xl fonts.
-rw-r--r--plugins/scale.lua22
1 files changed, 18 insertions, 4 deletions
diff --git a/plugins/scale.lua b/plugins/scale.lua
index b63611c..14648fd 100644
--- a/plugins/scale.lua
+++ b/plugins/scale.lua
@@ -15,11 +15,25 @@ 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.icon_font] = { DATADIR .. "/fonts/icons.ttf", 14 * SCALE }
-font_cache[style.code_font] = { DATADIR .. "/fonts/monospace.ttf", 13.5 * SCALE }
+font_cache[style.font] = { DATADIR .. "/fonts/" .. regular_font, 13 * SCALE }
+font_cache[style.big_font] = { DATADIR .. "/fonts/" .. regular_font, 40 * SCALE }
+font_cache[style.icon_font] = { DATADIR .. "/fonts/icons.ttf", 14 * SCALE }
+font_cache[style.icon_big_font] = { DATADIR .. "/fonts/icons.ttf", 20 * SCALE }
+font_cache[style.code_font] = { DATADIR .. "/fonts/" .. monospace_font, 13 * SCALE }
local load_font = renderer.font.load