Closed hgkamath closed 3 years ago
The error message:
Unable to load a font matching one of your font_rules: wezterm.font('Source Code Pro Medium', {bold=true, italic=false}). Note that wezterm will synthesize font_rules to select bold and italic fonts based on your primary font configuration. Fallback(s) are being used instead, and the terminal may not render as intended. A bold or italic variant of the font was requested; TrueType and OpenType fonts don't have an automatic way to produce these font variants, so a separate font file containing the bold or italic variant must be installed. See https://wezfurlong.org/wezterm/config/fonts.html for more information
tries to explain what is happening, but there's a lot to convey.
Here's the issue broken down:
Your config specified:
font = wezterm.font("Source Code Pro Medium"),
which matches for a font whose "full name" is literally Source Code Pro Medium
.
That is, a font in the family Source Code Pro
that has a Medium
font weight.
Because you don't have any explicitly specified font_rules
to tell wezterm what fonts
it should use for bold or italic text, wezterm synthesizes some default font_rules
by
taking your configured font
and adding the bold and italic attributes, so it is as though
you also had this in your config:
font_rules = {
{
intensity = "Bold",
font = wezterm.font("Source Code Pro Medium", {bold=true, italic=false}),
},
-- and other similar things for italic, and bold+italic
}
the error message comes from that synthesized config. Why?
In that case it is effectively trying to resolve Source Code Pro Medium Bold
which
is non-sensical; Medium
and Bold
are different font-weight specifiers.
So, what to do?
There are two ways to tackle this:
font = wezterm.font("Source Code Pro"),
(with no weight) and the inferred font_rules
should be able to find your bold font variant (assuming that there is a bold version of Source Code Pro
installed on your system!)font_rules
so that they match your desired bold/italic combinations.I think it's reasonable for wezterm to try to be a bit smarter when producing those inferred font_rules
; for example, it could take the font family name rather than the literal name specified and expand from there, but hopefully a minor tweak to your config is all you need for now!
Either the font detection isn't working right, or there is no standard naming to identify bold, italic and other variants in a family.
I ended creating a big switch case like block to find and set the correct font config parameters for each font family I may use.
Something did change between the two versions of wezterm, that it required all this configuration.
Ever with much experimenting it complains about DejaVu Sans mono Book
Currently, Fira code is my preferred font, except that it does not have an italic variant.
While making the configuration, for Virtuabox-fedoralinux, which I did by slowly pacifying each font error, I found it odd that I had to create the plain font section in the font_rules, Wezterm was trying to determine the non-bold font from the bold font. This was weird.
local wezterm = require 'wezterm';
local default_prog;
local set_environment_variables = {}
if wezterm.target_triple == "x86_64-pc-windows-msvc" then
set_environment_variables["GROOT"] = "E:\\groot_02"
-- set default_prog
-- command prompt + inject clink into the command prompt
-- default_prog = {"cmd.exe", "/s", "/k", "c:/clink_0.4.9/clink_x64.exe", "inject", "-q"}
-- powershell
default_prog = {"pwsh.exe"}
-- The font size, measured in points
-- default: font_size = 10.0
font_size = 11.0
-- The font family name. The default is "Menlo" on macOS,
-- "Consolas" on Windows and "monospace" on X11 based systems.
-- You may wish to download and try either "JetBrains Mono" or
-- "Fira Code" to enjoy ligatures without buying an expensive font!
-- font = wezterm.font("Operator SSm Lig Medium"),
-- font = wezterm.font("Source Code Pro Medium"),
-- font = wezterm.font("Courier New"),
-- font = wezterm.font("Fira Code Medium"),
-- font = wezterm.font("Consolas"),
-- font_family_name = "Source Code Pro"
-- font_family_name = "Fira Code"
-- font_family_name = "Consolas"
font_family_name = "Fira Code"
if font_family_name == "Source Code Pro" then
plain_font= "Source Code Pro Semibold"
font = wezterm.font(plain_font)
font_antialias = "Subpixel"
font_hinting = "Full"
font_shaper = "Harfbuzz"
-- The DPI to assume, measured in dots-per-inch
-- This is not automatically probed! If you experience blurry text
-- or notice slight differences when comparing with other terminal
-- emulators, you may wish to tune this value!
-- dpi = 96.0,
dpi = 96.0
font_rules={
{
intensity="Bold",
font=wezterm.font("Source Code Pro Bold", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
{
italic=true,
font=wezterm.font("Source Code Pro Medium Italic", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
}
elseif font_family_name == "Fira Code" then
plain_font= "Fira Code Medium"
font = wezterm.font(plain_font)
font_antialias = "Subpixel"
font_hinting = "Full"
font_shaper = "Harfbuzz"
dpi = 96.0
font_rules={
{
intensity="Bold",
font=wezterm.font("Fira Code Bold", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
{
italic=true,
font=wezterm.font("Source Code Pro Medium Italic", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
}
elseif font_family_name == "Consolas" then
plain_font= "Consolas"
font = wezterm.font(plain_font)
font_antialias = "Subpixel"
font_hinting = "Full"
font_shaper = "Harfbuzz"
dpi = 96.0
-- font_rules = {}
end
elseif wezterm.target_triple == "x86_64-unknown-linux-gnu" then
-- The font size, measured in points
-- default: font_size = 10.0
font_size = 11.0
-- The font family name. The default is "Menlo" on macOS,
-- "Consolas" on Windows and "monospace" on X11 based systems.
-- You may wish to download and try either "JetBrains Mono" or
-- "Fira Code" to enjoy ligatures without buying an expensive font!
-- font_family_name = "Source Code Pro"
font_family_name = "Fira Code"
if font_family_name == "Source Code Pro" then
plain_font= "Source Code Pro Medium"
font = wezterm.font(plain_font)
font_antialias = "Subpixel"
font_hinting = "Full"
font_shaper = "Harfbuzz"
-- The DPI to assume, measured in dots-per-inch
-- This is not automatically probed! If you experience blurry text
-- or notice slight differences when comparing with other terminal
-- emulators, you may wish to tune this value!
-- dpi = 96.0,
dpi = 96.0
font_rules={
{
font=wezterm.font("Source Code Pro Medium", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
{
intensity="Bold",
font=wezterm.font("Source Code Pro Bold", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
{
italic=true,
font=wezterm.font("Source Code Pro Medium Italic", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
}
elseif font_family_name == "Fira Code" then
plain_font= "Fira Code Medium"
font = wezterm.font(plain_font)
font_antialias = "Subpixel"
font_hinting = "Full"
font_shaper = "Harfbuzz"
dpi = 96.0
font_rules={
{
font=wezterm.font("Fira Code Medium", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
{
intensity="Bold",
font=wezterm.font("Fira Code Bold", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
{
italic=true,
font=wezterm.font("Source Code Pro Medium Italic", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
}
elseif font_family_name == "Liberation Mono" then
plain_font= "Liberation Mono"
font = wezterm.font(plain_font)
font_antialias = "Subpixel"
font_hinting = "Full"
font_shaper = "Harfbuzz"
dpi = 96.0
-- font_rules = {}
elseif font_family_name == "DejaVu Sans Mono" then
plain_font= "DejaVu Sans Mono"
font = wezterm.font(plain_font)
font_antialias = "Subpixel"
font_hinting = "Full"
font_shaper = "Harfbuzz"
dpi = 96.0
font_rules={
{
font=wezterm.font("DejaVu Sans Mono", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
{
intensity="Bold",
font=wezterm.font("DejaVu Sans Mono Bold", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
{
italic=true,
font=wezterm.font("DejaVu Sans Mono Oblique", {
-- you can override the default bold text color with this
-- foreground="tomato",
})
},
}
end
end
return {
-- Default shell
default_prog = default_prog ,
set_environment_variables = set_environment_variables,
color_scheme = "Material_GK2",
-- Example light themes:
-- "3024 Day", "ayu_light", "Belafonte Day", "CLRS", "AtomOneLight", "Github", "Man Page", "Material",
-- "OneHalfLight", "Night Owlish Light", "Novel", "PencilLight", "Spring", "Tango Adapted",
-- "Terminal Basic", "Violet Light"
-- color_scheme = "Builtin Solarized Light",
-- color_scheme = "Builtin Solarized Dark",
font_size = font_size,
font = font,
font_antialias = font_antialias,
font_hinting = font_hinting,
font_shaper = font_shaper,
dpi=dpi,
font_rules= font_rules,
-- ratelimit_output_bytes_per_second=4289999998,
}
Even with all the attempts the wezterm in windows looks different from wezterm in Virtualbox-FedoraLinux which renders using llvmpipe . I will need to check sometime how it looks when booted into FedoraLinux directly .
The virtualbox/Linux-llvmpipe rendering does not seem as good/satisfactory as Windows and is disconcerting.
Windows
VirtualBox-FedoraLinux
Comments not rendering as italics Furthermore, When a program/script, such as wezterm.lua is opened in nvim editor, the comments should render using italics, which they don't, neither in windows not in virtualbox-fedoralinux gnome-terminal seems to do the italic rendering
Summary
I'd like to keep this issue focused on the font configuration itself; please open separate issues for each other distinct issue so that it is easier to track things!
Regarding the configuration, there's a lot in your config sample that isn't necessary; it can be simplified to something like this, which uses a lua table to map from your font_family_name
to the alternate font_rules, rather than the fairly verbose chain of if-then-else statements.
I don't believe that it is strictly required to specify the font_rules for most of the fonts in your config, if you use the family name rather than the full name. eg: Source Code Pro
rather than Source Code Pro Medium
. If you do use a full name then you will need to specify the font_rules in order to suppress the warning about not finding alternative fonts.
If you don't care to specify those, then I think it is reasonable to introduce a new separate dont_warn_about_missing_fonts = true
config to simply suppress the warning.
local wezterm = require 'wezterm';
local default_prog;
local set_environment_variables = {}
local font_map = {
["Fira Code"] = {
font = wezterm.font("Fira Code"),
font_rules={
{
intensity="Bold",
font=wezterm.font("Fira Code", {bold=true}),
},
{
intensity="Bold",
italic=true,
font=wezterm.font("Source Code Pro", {bold=true, italic=true}),
},
{
italic=true,
font=wezterm.font("Source Code Pro", {italic=true}),
},
}
},
}
if wezterm.target_triple == "x86_64-pc-windows-msvc" then
set_environment_variables["GROOT"] = "E:\\groot_02"
-- set default_prog
-- command prompt + inject clink into the command prompt
-- default_prog = {"cmd.exe", "/s", "/k", "c:/clink_0.4.9/clink_x64.exe", "inject", "-q"}
-- powershell
default_prog = {"pwsh.exe"}
-- The font size, measured in points
-- default: font_size = 10.0
font_size = 11.0
-- The font family name. The default is "Menlo" on macOS,
-- "Consolas" on Windows and "monospace" on X11 based systems.
-- You may wish to download and try either "JetBrains Mono" or
-- "Fira Code" to enjoy ligatures without buying an expensive font!
-- font = wezterm.font("Operator SSm Lig Medium"),
-- font = wezterm.font("Source Code Pro Medium"),
-- font = wezterm.font("Courier New"),
-- font = wezterm.font("Fira Code Medium"),
-- font = wezterm.font("Consolas"),
-- font_family_name = "Source Code Pro"
-- font_family_name = "Fira Code"
-- font_family_name = "Consolas"
font_family_name = "Fira Code"
elseif wezterm.target_triple == "x86_64-unknown-linux-gnu" then
-- The font size, measured in points
-- default: font_size = 10.0
font_size = 11.0
-- The font family name. The default is "Menlo" on macOS,
-- "Consolas" on Windows and "monospace" on X11 based systems.
-- You may wish to download and try either "JetBrains Mono" or
-- "Fira Code" to enjoy ligatures without buying an expensive font!
-- font_family_name = "Source Code Pro"
font_family_name = "Fira Code"
end
local font_rules;
local font;
local font_info = font_map[font_family_name];
if font_info then
font = font_info.font;
font_rules = font_info.font_rules
else
font = wezterm.font(font_family_name);
end
return {
-- Default shell
default_prog = default_prog ,
set_environment_variables = set_environment_variables,
color_scheme = "Material_GK2",
-- Example light themes:
-- "3024 Day", "ayu_light", "Belafonte Day", "CLRS", "AtomOneLight", "Github", "Man Page", "Material",
-- "OneHalfLight", "Night Owlish Light", "Novel", "PencilLight", "Spring", "Tango Adapted",
-- "Terminal Basic", "Violet Light"
-- color_scheme = "Builtin Solarized Light",
-- color_scheme = "Builtin Solarized Dark",
font_size = font_size,
font = font,
font_antialias = "Subpixel",
font_rules= font_rules,
-- ratelimit_output_bytes_per_second=4289999998,
}
I incorporated your changes into my config
text_background_opacity
and window_background_opacity
to 1.0 to fix that, echo -e "\e[1mbold\e[0m"
echo -e "\e[3mitalic\e[0m"
echo -e "\e[3m\e[1mbold italic\e[0m"
echo -e "\e[4munderline\e[0m"
echo -e "\e[9mstrikethrough\e[0m"
echo -e "\e[31mHello World\e[0m"
echo -e "\x1B[31mHello World\e[0m"
I noticed that the default font selection for no configuration wezterm is "liberation mono" on linux.
The default font in wezterm on all platforms is JetBrains Mono
.
There is some translucency by-default.
There isn't, but perhaps you ran into https://github.com/wez/wezterm/issues/470 which is alpha-bleed-through and should now be fixed in master
Are you sure italics is working for you ?
Yep:
The fedora/windows system doesn't have jetbrains mono, So, in the absence of any wezterm.lua config file, its picking up liberation-mono. I confirm that italics is working with liberation mono, but bold-italic is rendered italic without being bold. liberation-mono being a fairly simple font with only 4 variants should have been automatically matched up.
Here's what I wan the font map to do
I got the below working for source code pro and Fira Code
local font_map = {
["Fira Code"] = {
font = wezterm.font("Fira Code"),
font_rules={
{
intensity="Bold",
italic=true,
font=wezterm.font("Source Code Pro Semibold", {bold=true, italic=true}),
},
{
italic="true",
font=wezterm.font("Source Code Pro Semibold", {italic=true}),
},
{
intensity="Bold",
font=wezterm.font("Fira Code", {bold=true, italic=false}),
},
{
font=wezterm.font("Fira Code Medium", {italic=false}),
},
}
},
["Source Code Pro Semibold"] = {
font = wezterm.font("Source Code Pro Semibold"),
font_rules={
{
intensity="Bold",
italic=true,
font=wezterm.font("Source Code Pro", {bold=true, italic=true}),
},
{
italic="true",
font=wezterm.font("Source Code Pro Semibold", {italic=true}),
},
{
intensity="Bold",
font=wezterm.font("Source Code Pro", {bold=true, italic=false}),
},
}
},
["Liberation Mono"] = {
font = wezterm.font("Liberation Mono"),
},
}
Is there a better way to make it happen? IS there redundancy that can be simplified? It took me a lot of trial and error, and got it after I assumed order fall-through in the font_rules So according to that assumption, font specification for bold-italic should appear before bold or italic. without which the bold-italic echo-text would only render as italic but not bold
note that I wrote the font map config entries for fira code and source-code-pro a little differently, with source code pro directly indexing into a semibold font. I am not too sure of the logic behind all of this But I got the end effect I wanted
I'm glad you got things working!
The fedora/windows system doesn't have jetbrains mono, So, in the absence of any wezterm.lua config file, its picking up liberation-mono.
FWIW, wezterm bundles a copy of JetBrains Mono
and that is what is used as the default font, and for fallback if your preferred font is not found. That font is compiled in as an in-memory fallback, along with a fallback emoji and unicode last resort font.
If you want to reduce complexity and just have one configuration that works in multiple machines, you may want to consider putting your preferred fonts in a directory and keep them alongside your wezterm config; if you make a fonts
directory in the same location as you keep your wezterm.lua
, and put your preferred fonts inside it, you can tell wezterm to search that directory directly:
-- This is explained at the top of https://wezfurlong.org/wezterm/config/fonts.html
return {
-- Relative paths in `font_dirs` are resolved relative to the `wezterm.lua` file
font_dirs = { "fonts" },
}
With your fonts being synchronized in the same way that you synchronize your wezterm.lua
file, you can simplify your config file to list just the fonts you want to use.
If you want to keep the flexibility of having multiple different sets of fonts with different italic variants, then I don't think you can get much simpler than using the map as you are now.
For the Source Code Pro Semibold
case, I think we could do a bit better; one of the things we don't do today is provide much flexibility with font weights; we only really understand "not bold" and "bold". If we could expand our understanding to a font weight then the synthesized font_rules
could be done in terms of relative weights; the "Bold" rule would be "bolder than the specified base font" rather than "the base font but weight=bold" that it is today. With that, you wouldn't need to specify font_rules
at all for that particular font selection, just something like wezterm.font("Source Code Pro", {weight=600})
One we have that foundation, your Fira Code
with Source Code Pro
fallback might be more simply expressed as something like:
wezterm.font_with_fallback({
"Fira Code",
{family="Source Code Pro", weight=600}
})
Neighter of those work today, but that's probably the right direction to move in.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Describe the bug
In the previous version of wezterm, the font was loaded properly In the new version of wezterm, font not found and defaults to scrawny looking font
Has something changed? Am I missing something basic?
Issue seen in both windows and linux
On windows I had "Fira Code" in wezterm.lua I updated wezterm on windows using package manager
scoop update -g "*"
On Virtualbox/Linux-fedora-33 I had "Source Code Pro Medium" in wezterm.lua I updated wezterm on fedora using
rpm -Uvh "https://..github link"
Since linux is in a VM with no GPU, wezterm uses llvmpipe.A clear and concise description of what the bug is. Font not found
I have made not changes to configuration files between the update, feel like I need to downgrade
logs
Before wezterm update
After wezterm update
Wezterm Message in linux (similar in windows)
Environment (please complete the following information):
OS: [e.g. Linux X11, Linux Wayland, macOS, Windows] both win10-20H2 , linux fc33
Version: please run
wezterm -V
and include its output hereConfiguration
Be sure to include the relevant section(s) of your
wezterm.lua
configuration file.