-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
In daemon mode, Spacemacs does not set the font correctly #6197
Comments
I thought it was fixed but apparently it is not the case, @StreakyCobra it seems that the magic message call is not working :-D |
Flag as duplicate of #1894 |
@syl20bnr The magic message is there to solve the specific problem when the really first emacsclient instance has the wrong font but subsequent ones use the correct font. It was not meant to solve all font-setup issue :-) @pfmoore Is it only the first emacsclient instance that has the wrong font? I would suspect this being a problem with windows, but I'm not really sure. @pfmoore Can you try to replicate your config in your linux VM and see if happens there too? Also can you try emacs 24.5 to see if there is a difference? |
@StreakyCobra It happens for every emacsclient instance - there's no font setting in I can't test in 24.5.1, as I get "This platform does not support the -daemon flag" - daemon mode is new in version 25 for Windows. As far as trying on Linux is concerned, I'll see what I can do. My Linux VM is a bit of a mess (running on a PC but has no internet access, and apparently sshd isn't installed by default, so I can't transfer files to it). My spacemacs config is little more than setting I'll report back on Linux once I get something set up. |
OK, found a PC with proper internet access... Everything works as I expected it to on Linux (ie, the bug I'm reporting here doesn't occur). The emacsclient window comes up with DehaVu Sans Mono. Strangely, though, if I set the font to one that doesn't exist ("DejaVux Sans Mono") I still don't get the "could not find font" message on startup of the daemon. But now the font in an emacsclient window is the standard Ubuntu font (which presumably means that spacemacs failed to find the font at some point, and fell back to that). I'm not sure what I can conclude from this, but if you need me to do any more experiments, let me know. |
So it's probably a windows related issue. The error message not being showed if the font don't exist is expected (IIRC) as we are delaying the configuration of the font after the display has been initiated ( |
Ha. Found the issue, Whether that's a bug, I'm not sure. I'll report it as such and see what happens. |
I've just submitted PR #6227 to work around this issue. The initial response from the emacs bugs list was
I'm still discussing the situation, so that may change, but even so the PR seems to work on current versions of emacs 25 on Windows, so it'll save people having to upgrade their Emacs to get fixed behaviour, at least. |
Response from Eli Zaretskii (and my reply) on the emacs bugs list:
|
If we can get a hook for this we would be really happy :-) |
I still seem to be getting odd issues with this. I've put some log messages in, and I can see that my chosen font is now getting selected, but frames are being opened which don't use that font. I can't yet see any pattern to this. I'm opening Emacs using One question - it doesn't look like spacemacs uses |
That seems to be a bug. I was able to open frames with incorrect fonts but if I set it in default-frame-alist that doesn't happen. |
Hmm, I added the change, and I still sometimes get the incorrect font. Checking default-frame-alist, it's got the wrong font in there. And yet, my logging shows 'Found "DejaVu Sans Mono-12"'. This definitely looks like some sort of race condition, with the font getting selected after the frame has been created somehow. I wonder if hooking Maybe the real answer is to get a new hook specifically for this, but that would presumably not work for people on older versions of Emacs, so we'd end up needing to support both methods... I'll keep digging when I have the time. |
Thank you for the investigation, this is a dark corner of Spacemacs where we try to make GUI related config to work with The minimum version supported by Spacemacs is now 24.4 so we could try the |
OK. Here's an update on my investigations. The issue basically seems to be that I'm currently looking at two changes - first, change It may be that a more radical change (such as forcibly selecting a GUI frame) would work, but I'm concerned I'd break something else (this is all very low level, and I'm very new to elisp/emacs internals). On the other hand, there's a pretty good user-level solution. In (defun reset-default-font ()
(unless (spacemacs/set-default-font dotspacemacs-default-font)
(spacemacs-buffer/warning
"Cannot find any of the specified fonts (%s)! Font settings may not be correct."
(mapconcat 'car dotspacemacs-default-font ", ")))
(remove-hook 'focus-in-hook #'reset-default-font)) Then, in |
Interesting hypothesis, would make sense!
You already went far further than me! |
I'm stubborn :-) |
Not sure if I am seeing the same bug or not - but after I updated all packages a couple of days back and installed the themes-megapack, and now my font settings are completely ignored. I run emacs in daemon mode, and am running debian unstable. I tried the workaround suggested by @pfmoore , but while my font settings while applied, the size is quite off - it's really small! Any hints on how to analyze this problem further will be much appreciated! |
I find size handling is very odd. If I use I just play with the numbers till I get something I like... |
Seeing this on Linux too - the |
I should have read the docs:
|
I might have an improved version of the font-setting code that works properly in daemon mode on Windows. At the moment it's just sitting in a branch on my fork, at https://github.com/pfmoore/spacemacs/tree/font_test. I'll do some more testing before submitting it as a PR, but if anyone feels like trying it out and reporting any issues (especially on non-Windows systems) that'd be great. One thing that bothers me is that I'm seeing occasional odd messages in the Anyway - any feedback would be gratefully accepted, otherwise I'll put a PR together when I've tested the change out a little more. |
I have observed same issue on ubuntu too. Following comments helped #6197 (comment) |
Was trying to use the hack font and just got the message The fix from #6197 (comment) worked in my case on Windows as well. Emacs version: |
For me font goes back to normal, when cycling themes |
FWIW, I've recently started experiencing this issue as well (under Arch Linux + Gnome3), regardless of whether I start Emacs in daemon mode or not. As far as I'm aware, this wasn't tied to any update either of Emacs or Spacemacs. I think it started manifesting itself after a Wayland crash, but it may very well be that the two are only tangentially related (at any rate, the behavior is now the same when using either of Wayland or Xorg as the window server). Running |
OK, and now the issue disappeared as mysteriously as it appeared, huh? The only thing I did was log in with a new user to see if the problem would persist on a fresh clone of Spacemacs + package install (it didn't), then I switch back to my normal user's session, restart Spacemacs, and the issue's gone. Go figure. (I realize this is not terribly useful, but just to illustrate the heisenbug nature of the issue.) |
Still have this issue. The workaround fix above works for me aswell. If it is at all possible, we can consider only loading the font when a client is launched. Having a separate config for the client can add other functionality aswell. I dont know if this is possible at the level spacemacs operate. |
Still have this issue on Ubuntu 17.10. |
* Found suggested fix here: syl20bnr/spacemacs#6197 (comment)
This occurs to me on CentOS7 and openSUSE Tumbleweed, it worked fine well, and then it just suddenly doesn't load my own font correctly anymore, and no other warning or error message in Message buffer or anywhere. #6197 (comment) works for me. And I found a simpler solution, put something like
in |
Confirming that this is an issue NixOS unstable (19). To find your current font which you are using with all the setting call describe-font function
copy the full name |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid! |
The issue still exists. Please reopen this bug. |
In my
~/.spacemacs.d/init.el
I have:This works fine if I start Emacs normally. However, if I do
emacs.exe --daemon
I see the following in the output:... and when I open a frame via
emacsclient -c
the default font (Courier New) is used rather than my configured font. Checkingdefault-frame-alist
, my font preference has not been set.The problem seems to lie in this code in
core-spacemacs.el
:I know that
find-font
will not find GUI fonts when called early in the initialisation in Daemon mode on Windows. At that point, there's no GUI frame and so the "current frame" used by default byfind-font
doesn't have access to the fonts available on the GUI display for some reason. However, I'm not sure that's everything that is going on here, as I checkedfind-font
on a Linux machine and got a similar result.System Info 💻
The text was updated successfully, but these errors were encountered: