-
-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
font_size != 12 vs initial_cols + initial_rows vs external monitor #4851
Comments
Likely a duplicate of: |
You will have a better idea what's behind #3900, so this might well be a duplicate. But to me the font-size itself is not an issue, that looks good to me. When I play around with |
There are a number of open issues that relate to getting the dpi wrong when spawning a window. In theory it shouldn't matter because we will immediately realize the difference and synthesize the correct information, but evidence shows this isn't quite true. What this commit does is: * Override Connection::default_dpi() on macOS to return the effective_dpi from the active screen instead of the default non-retina dpi * Adjust the Config::initial_size() method to accept an optional cell pixel dimension * Add a helper function to wezterm-gui to compute the cell pixel dimensions given the config and the (usually default) dpi, and feed that through to Config::initial_size * in the macos window impl, scale the computed geometry based on the ratio of the Connection::default_dpi and the default non-retina dpi. This helps to avoid needing to do a fixup in the #4966 case, and may help with the various other macos quirky issues. refs: #2958 refs: #3575 refs: #3900 refs: #4250 refs: #4285 refs: #4447 refs: #4851 refs: #4966
Please try the latest nightly build and let me know if this is still an issue! |
@wez I just tested again with:
and settings: config.font_size = 14
config.initial_cols = 137 -- width
config.initial_rows = 42 -- height On a non-retina screen I get a window with: % printf '%sx%s\n' $(tput cols) $(tput lines)
293x84 |
I'm currently using the following code (in a separate module file) as a workaround: -- window size really gets messed up when using different monitors and non-default font_size (i.e. != 12) (at least on macOS)
-- https://github.com/wez/wezterm/issues/2753
-- https://github.com/wez/wezterm/issues/3575
-- https://github.com/wez/wezterm/issues/3900
-- https://github.com/wez/wezterm/issues/4285
-- https://github.com/wez/wezterm/issues/4447
local module = {}
local wezterm = require 'wezterm'
local COLS_NON_RETINA = 80
local ROWS_NON_RETINA = 21
function module.apply_to_config(config)
-- config.dpi_by_screen = {
-- -- https://github.com/wez/wezterm/issues/4096
-- ['U32E850'] = 100,
-- ['LG Ultra HD'] = 100,
-- }
-- config that applies to retina screens
config.font_size = 14
config.initial_cols = 137 -- width
config.initial_rows = 42 -- height
end
-- https://coralpink.github.io/commentary/wezterm/dpi-detection.html
-- wezterm.on('window-focus-changed', function(window, pane)
-- local overrides = window:get_config_overrides() or {}
-- overrides.font_size = 10
--
-- window:set_config_overrides(overrides)
-- end)
-- make sure additional windows (after the initial one) are created correctly, on non-retina screens
wezterm.on('window-config-reloaded', function(window)
if wezterm.gui.screens().active.name == 'Built-in Retina Display' then
return
end
local overrides = window:get_config_overrides() or {}
overrides.initial_cols = COLS_NON_RETINA
overrides.initial_rows = ROWS_NON_RETINA
window:set_config_overrides(overrides)
end)
-- make sure the initial window is created correctly, on non-retina screens
wezterm.on('gui-startup', function(cmd)
if wezterm.gui.screens().active.name == 'Built-in Retina Display' then
return
end
-- https://wezfurlong.org/wezterm/config/lua/wezterm.mux/spawn_window.html#width-and-height
local tab, pane, window = wezterm.mux.spawn_window { width = COLS_NON_RETINA, height = ROWS_NON_RETINA }
end)
-- return our module table
return module You can see that it is a bit of a collection of trial & error code-pieces to get WezTerm to behave roughly how I want it to. Maybe it helps in testing ... or someone else who has this issue. I had this module removed before testing with the new version ( #4851 (comment) ). 🙂 |
I have been trying to track this down, but it's been tricky to keep straight where the DPI in some calculations is coming from. I can see clearly in trace logs that it is getting the correct DPI (72) for the screen that it is creating the window on, but then somewhere in the process of creating the window it gets confused and thinks the DPI is 144 (the appropriate value for the built-in display) so it blows up the window to twice what it should be, and then recognizes that the DPI is 72 again but leaves the window doubled(ish) so the number of rows and columns is now wrong. If I populate config.dpi_by_screen with the correct values for the two displays, it still works okay on the built-in 144dpi display, but then the window on the secondary screen is half the height it should be and nothing actually gets drawn within the window borders. I've attached a trace-level log that may help illuminate things. There are some WARN lines that contain 'JW' which are a few extra things I added in trying to figure things out, like dumping |
Some more spelunking: if I change (I have questions about this function. It tries to look up the DPI in config.dpi_by_screen by calling What made me suspicious is that at least one place where it is figuring the wrong DPI seems to be in It also feels like things go awry in some font metric calculations too but I haven't tracked down where it is getting the DPI to use for those. There seem to be a number of places where a couple of different methods are called to get the DPI and then there is further calculation if those methods return None, and then possibly scaling that. I wonder if there is some divergence in how those are being calculated. |
I was able to hack away at It must still be using the wrong DPI when deciding on the font metrics or something like that. The rendering gets corrected if the window is resized. |
What Operating System(s) are you seeing this problem on?
macOS
Which Wayland compositor or X11 Window manager(s) are you using?
n/a
WezTerm version
20240124-220416-642bfbb6
Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?
Yes, and I updated the version box above to show the version of the nightly that I tried
Describe the bug
Using the latest (as of today) nightly build of WezTerm, I'm trying to get a window with a (roughly) certain number of rows & columns. While this works without issue on an internal (Retina) Display on a MacBook Pro, it fails for
font_size
values other than12
.External monitor,
font_size=12
, everything as exected.However when going to
font_size=13
, on the external monitor we get a window that as roughly double the expected numbers of rows and columns:Going up one step to
14
gives even more rows & columns than expected:Going down to
font_size=8
nearly works (except for one row):If you try to fudge the expected rowXcolumn size, by adjusting the input numbers, it works ... but then if you open a window on an internal retina screen, you of course get the input numbers, so the window is too small.
To Reproduce
No response
Configuration
Expected Behavior
a window with the configured number of rows & columns, no matter the display
Logs
No response
Anything else?
I have played around with
dpi_by_screen
... did not really help, just made the rendering larger, and the font_sizes have been pretty good without that for me on both internal & external.Issue might be related to or duplicate of #4285.
The text was updated successfully, but these errors were encountered: