2022-12-19 17:50:20 +01:00
|
|
|
local wezterm = require("wezterm")
|
2023-03-06 11:58:51 +01:00
|
|
|
local utils = require("utils")
|
2022-12-19 17:50:20 +01:00
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
2023-03-06 11:58:51 +01:00
|
|
|
local defaults = {
|
|
|
|
size = 16,
|
|
|
|
ui_font = "IBM Plex Sans",
|
|
|
|
}
|
|
|
|
|
2023-03-04 05:50:49 +01:00
|
|
|
-- fonts I like, with the settings I prefer
|
|
|
|
-- kept separately from the rest of the config so that I can easily change them
|
|
|
|
local fonts = {
|
2023-03-06 11:58:51 +01:00
|
|
|
berkeley = { font = "Berkeley Mono" },
|
2023-03-04 05:50:49 +01:00
|
|
|
comic = {
|
|
|
|
font = "Comic Code Ligatures",
|
2023-03-06 11:58:51 +01:00
|
|
|
ui_font = "xkcd Script",
|
2023-03-04 05:50:49 +01:00
|
|
|
},
|
|
|
|
victor = {
|
|
|
|
font = {
|
|
|
|
family = "Victor Mono",
|
|
|
|
weight = "DemiBold",
|
|
|
|
harfbuzz_features = { "ss02=1" },
|
2023-01-01 15:36:39 +01:00
|
|
|
},
|
2023-03-06 11:58:51 +01:00
|
|
|
size = defaults.size - 1,
|
2023-03-04 05:50:49 +01:00
|
|
|
},
|
|
|
|
}
|
2022-12-19 17:50:20 +01:00
|
|
|
|
2023-03-06 11:58:51 +01:00
|
|
|
for k, v in pairs(fonts) do
|
|
|
|
fonts[k] = utils.tableMerge(v, defaults)
|
|
|
|
end
|
|
|
|
|
2023-03-04 05:50:49 +01:00
|
|
|
M.get_font = function(name)
|
2023-01-01 15:36:39 +01:00
|
|
|
return {
|
2023-02-09 17:18:50 +01:00
|
|
|
font = wezterm.font_with_fallback({
|
|
|
|
fonts[name].font,
|
|
|
|
"Symbols Nerd Font",
|
|
|
|
}),
|
2023-01-01 15:36:39 +01:00
|
|
|
size = fonts[name].size,
|
2023-03-06 11:58:51 +01:00
|
|
|
ui_font = wezterm.font(fonts[name].ui_font),
|
2023-01-01 15:36:39 +01:00
|
|
|
}
|
2022-12-19 17:50:20 +01:00
|
|
|
end
|
|
|
|
|
2023-03-04 05:50:49 +01:00
|
|
|
wezterm.on("switch-font", function(window, _)
|
|
|
|
local next_font = next(fonts, wezterm.GLOBAL.font)
|
|
|
|
if next_font == nil then
|
|
|
|
next_font = next(fonts)
|
|
|
|
end
|
|
|
|
wezterm.GLOBAL.font = next_font
|
|
|
|
|
2023-03-06 11:58:51 +01:00
|
|
|
local f = M.get_font(next_font)
|
|
|
|
local window_frame = window:effective_config().window_frame
|
|
|
|
window_frame = utils.tableMerge({ font = f.ui_font }, window_frame)
|
2023-03-04 05:50:49 +01:00
|
|
|
window:set_config_overrides({
|
2023-03-06 11:58:51 +01:00
|
|
|
font = f.font,
|
|
|
|
font_size = f.size,
|
|
|
|
window_frame = window_frame,
|
2023-03-04 05:50:49 +01:00
|
|
|
})
|
|
|
|
end)
|
|
|
|
|
2023-03-05 05:40:35 +01:00
|
|
|
wezterm.GLOBAL = { font = "berkeley" }
|
|
|
|
M.apply = function(c)
|
2023-03-06 11:58:51 +01:00
|
|
|
local f = M.get_font(wezterm.GLOBAL.font)
|
|
|
|
c.font = f.font
|
|
|
|
c.font_size = f.size
|
|
|
|
if c.window_frame == nil then
|
|
|
|
c.window_frame = {}
|
|
|
|
end
|
|
|
|
c.window_frame.font = f.ui_font
|
2023-03-05 05:40:35 +01:00
|
|
|
end
|
|
|
|
|
2022-12-19 17:50:20 +01:00
|
|
|
return M
|