declantsien / emacs-ng

Emacs Webrender front
https://github.com/declantsien/emacs-webrender
GNU General Public License v3.0
8 stars 0 forks source link

Font 'Monospace' is not defined #1

Closed SKyletoft closed 1 year ago

SKyletoft commented 1 year ago

Running emacs webrender as built by the nix flake on NixOS results in missing fonts.

Font ‘Monospace’ is not defined

This happens when running with nix run and just running the resulting binary (result/bin/emacs).

~/.config/fontconfig/fonts.conf: https://pastebin.com/bPwvbZKy

/etc/fonts/fonts.conf: https://pastebin.com/gCBFECaS

as generated by this section of /etc/nixos/configuration.nix:

    fonts = {
        fonts = with pkgs; [
            cascadia-code
            fantasque-sans-mono
            (nerdfonts.override {fonts = [
                "FiraCode"
                "DroidSansMono"
                "FantasqueSansMono"
            ];})
        ];
        fontconfig.defaultFonts = {
            monospace = [ "DroidSansMono Nerd Font" ];
        };
    };

Pastebin links because code blocks don't work with <details>

Passing the filepath to the local config via the FONTCONFIG_FILE environment variable has no effect, same with -fn "Fira Code Nerd Font-11" (which is what I have in my emacs config)

declantsien commented 1 year ago

Can you try FiraCode Nerd Font instead of Fira Code Nerd Font? Difference here is FiraCode vs Fira Code.

We are using a simple string equal when matching font, not as flexable/tolerant as fontconfig @SKyletoft

SKyletoft commented 1 year ago

I thought I'd tried that but apparently not enough. This works with -fn, but still not from fonts.conf

declantsien commented 1 year ago

I think DroidSansMono should be Droid Sans Mono.

SKyletoft commented 1 year ago

Maybe so, I just copied the formatting from LibreOffice

SKyletoft commented 1 year ago

No, -fn "DroidSansMono Nerd Font-11" works. I'm apparently just bad at testing

SKyletoft commented 1 year ago

But that still leaves the issue with loading from fontconfig, but that could be me missing something nix specific

declantsien commented 1 year ago

Font alias defined in your fontconfig file is wrong, I think. You can find the exact family name using fc-match lik this

fc-match " DroidSansMono"
DroidSansMono.ttf: "Droid Sans Mono" "Regular"
SKyletoft commented 1 year ago
$ fc-match "Monospace"
Droid Sans Mono Nerd Font Complete.otf: "DroidSansMono Nerd Font" "Book"

No, that seems to work. I think it's a flake isolation thing

declantsien commented 1 year ago

Can you try this https://pastebin.com/jJ9m7VH9

Edits: Removed traing/traing spaces

declantsien commented 1 year ago
$ fc-match "Monospace"
Droid Sans Mono Nerd Font Complete.otf: "DroidSansMono Nerd Font" "Book"

No, that seems to work. I think it's a flake isolation thing

The issue here is not with nix flake, it's Emacs Webrender been strict with font family name pass to it.

SKyletoft commented 1 year ago

Can you try this https://pastebin.com/jJ9m7VH9

Edits: Removed traing/traing spaces

Nix doesn't have a profile font path and I can't figure out where global fonts live (and I definitely don't have a guix path). It looks like they're just in the nix store like every other package and I can't find any collection of symlinks to them or anything

declantsien commented 1 year ago

Can you try this https://pastebin.com/jJ9m7VH9 Edits: Removed traing/traing spaces

Nix doesn't have a profile font path and I can't figure out where global fonts live (and I definitely don't have a guix path). It looks like they're just in the nix store like every other package and I can't find any collection of symlinks to them or anything

You can remove that line. Or does it report error?

SKyletoft commented 1 year ago

Oh, I thought that line was the point of it. No, it does nothing

declantsien commented 1 year ago

https://pastebin.com/Dk26F6Y3 FONTCONFIG_FILE=[download file path here] ./emacs

Otherwise, I don't know then.

SKyletoft commented 1 year ago

Looks like I'll just have to sit down in gdb tomorrow then.

Thanks

declantsien commented 1 year ago

No, -fn "DroidSansMono Nerd Font-11" works. I'm apparently just bad at testing

If this works, you can just set the 'DroidSansMono Nerd Font' in your emacs early-init.el file like this.

  (add-to-list 'default-frame-alist '(font . "DroidSansMono Nerd Font-11")))

Sorry things didn't workout for you. Damn we need to make it complatable with fontconfig.

SKyletoft commented 1 year ago

I'm gonna dig into it tomorrow. I'm too invested now. That workaround might work, but this branch is way too slow to be usable for me right now, but that's a separate issue

declantsien commented 1 year ago

Hi, there @SKyletoft . I got sometime yesterday. Added native fontconfig support on this branch https://github.com/declantsien/emacs-ng/tree/feature/webrender Can you try it out?

You can check font loading activities with EMACSNG_LOG="wrterm::font_db=trace" ./emacs

When manually compiling, you need to add --enable-rust-debug to see the log, however nix flake already set --enable-rust-debug in place, I think.

this branch is way too slow

For me, this branch slows only when I open Emacs on linux. Maybe you can help out. Except for some unimplement functionalities (like child frame), things checked out on my Linux and Mac machines.

SKyletoft commented 1 year ago

I've been trying to setup a proper dev environment today. (Because nix build has no incremental compiles and the flake environment is missing a tonne of tools). I'm now back to fighting IncompatibleWinitWindow, despite all the libraries that got added after that. I'll have a look at the font situation when I have a working environment that doesn't take an hour to compile

SKyletoft commented 1 year ago

For me, this branch slows only when I open Emacs on linux. Maybe you can help out.

I only have NixOS-systems. But looking into performance was my plan when I got stuff setup.

declantsien commented 1 year ago

Samuel Kyletoft @.***> writes:

I've been trying to setup a proper dev environment today. (Because nix build has no incremental compiles and the flake environment is missing a tonne of tools). I'm now back to fighting IncompatibleWinitWindow, despite all the libraries that got added after that. I'll have a look at the font situation when I have a working environment that doesn't take an hour to compile

-- Reply to this email directly or view it on GitHub: https://github.com/declantsien/emacs-ng/issues/1#issuecomment-1374356568 You are receiving this because you commented.

Message ID: @.***>

What about

cd emacs-checkout
nix develop github:declantsien/emacs-webrender#emacsWebrender

./autogen.sh
./configure --with-webrender --enable-rust-debug

cd ./src
make -j12 <- replace with you num of cpus

EMACSNG_LOG="trace" ./emacs
or
EMACSNG_LOG="wrterm::font_db=trace" ./emacs
SKyletoft commented 1 year ago

Why on earth does that work but not when I clone the flake-repo and run it locally?!

declantsien commented 1 year ago

Samuel Kyletoft @.***> writes:

Why on earth does that work but not when I clone the flake-repo and run it locally?!

-- Reply to this email directly or view it on GitHub: https://github.com/declantsien/emacs-ng/issues/1#issuecomment-1374360441 You are receiving this because you commented.

Message ID: @.***>

Do you missed =.#emacsWebrender= when using =nix develop= ? It should be like this =nix develop .#emacsWebrender=

declantsien commented 1 year ago

I guess https://github.com/declantsien/emacs-webrender/blob/master/nix/commands.toml is outdated. But I never used it. Will fixed it later.

SKyletoft commented 1 year ago

Ah, that'd be it.

And yes, it works now.

declantsien commented 1 year ago

IncompatibleWinitWindow

The x11/xwayland build is broken. I am fixing. If you are on Wayland. Force emacs to use wayland by setting WINIT_UNIX_BACKEND=wayland ./emacs

declantsien commented 1 year ago

IncompatibleWinitWindow

This issue is fix. When manully compiling for x11, --enable-webrender-x11 is required. --enable-webrender-x11 is enabled in nix flake now.

declantsien commented 1 year ago

IncompatibleWinitWindow issue move to here https://github.com/emacs-ng/emacs-ng/issues/467