From 542d329c245ab2a1e283fe417d5fcba9e44a995a Mon Sep 17 00:00:00 2001 From: Madeleine Sydney Date: Sun, 2 Feb 2025 11:52:10 -0700 Subject: [PATCH] feat: Configure fonts --- users/crumb/programs/emacs.nix | 19 +++++++++-- users/crumb/programs/emacs/modules/syd-ui.el | 33 ++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/users/crumb/programs/emacs.nix b/users/crumb/programs/emacs.nix index 1d35a79..5089555 100755 --- a/users/crumb/programs/emacs.nix +++ b/users/crumb/programs/emacs.nix @@ -30,6 +30,12 @@ let emacsCacheDir = "${emacsDataDir}/cache"; straightBaseDir = "${emacsDataDir}/straight"; + fontPackages = [ + pkgs.julia-mono + (pkgs.nerdfonts.override { fonts = [ "VictorMono" ]; }) + pkgs.overpass + ]; + emacsWrapper = pkgs.symlinkJoin { name = "emacs-wrapper"; paths = [ emacsPackage ]; @@ -38,12 +44,15 @@ let pkgs.git # Dependency of Straight.el. ]; postBuild = '' + # The binary called `emacs` is actually a symlink to `emacs-«version»`, so + # we needn't wrap it. for i in $out/bin/emacs-*; do wrapProgram "$i" \ --add-flags "--init-directory \"${emacsConfigDir}\"" \ --set EMACS_STRAIGHT_BASE_DIR "${straightBaseDir}" \ --set EMACS_CACHE_DIR "${emacsCacheDir}" \ - --set EMACS_DATA_DIR "${emacsDataDir}" + --set EMACS_DATA_DIR "${emacsDataDir}" \ + --prefix PATH : "${pkgs.git}/bin" done ''; }; @@ -53,7 +62,13 @@ in { (lib.removePrefix config.home.homeDirectory straightBaseDir) ]; - home.packages = [ emacsWrapper ]; + home.packages = [ + emacsWrapper + ] ++ fontPackages; + + # There's probably a better place to put this, but the current setup demands + # Fontconfig for Emacs to find my fonts. + fonts.fontconfig.enable = true; # TODO: Make sure this is using the right package for Emacs... services.emacs = { diff --git a/users/crumb/programs/emacs/modules/syd-ui.el b/users/crumb/programs/emacs/modules/syd-ui.el index 81139e1..e6dd7ba 100755 --- a/users/crumb/programs/emacs/modules/syd-ui.el +++ b/users/crumb/programs/emacs/modules/syd-ui.el @@ -1,12 +1,20 @@ ;;; syd-ui.el -*- lexical-binding: t; -*- +(defvar syd-fixed-pitch-font + (font-spec :family "VictorMono NF" :size 13) + "Default fixed-pitch (monospace) font.") + +(defvar syd-variable-pitch-font + (font-spec :family "Overpass" :size 15) + "Default variable-pitch font.") + ;; Beautiful theme in dark and light. (use-package kanagawa-themes :config (load-theme 'kanagawa-wave t)) -;; Display (relative) line numbers only in prog-mode derivatives. (use-package emacs + ;; Display (relative) line numbers only in prog-mode derivatives. :hook ((prog-mode-hook . display-line-numbers-mode)) :custom ((display-line-numbers-type 'relative) ;; Always ask "y/n"; never "yes/no". @@ -28,9 +36,30 @@ ;; Disable the menu bar, scroll bar, and tool bar. (menu-bar-mode -1) (scroll-bar-mode -1) - (tool-bar-mode -1)) + (tool-bar-mode -1) + + ;; Configuring the defaults for newly-created frames: + ;; Set default font. + ;; (add-to-list 'default-frame-alist '(font . "VictorMono NF")) + ;; Disable the titlebar and borders (decorations). + (add-to-list 'default-frame-alist '(undecorated . t)) + ;; Maximise the window. + ;; (add-to-list 'default-frame-alist '(fullscreen . maximized)) + + ;; Set the default font... again? No! Earlier, we said "when creating a new + ;; frame use this font." This call instead defines the face used for + ;; "default" text to use this font. + (set-face-attribute 'default nil :font syd-fixed-pitch-font) + + (set-face-attribute 'variable-pitch nil :font syd-variable-pitch-font) + + ;; Use JuliaMono as a fallback for some glyphs that VictorMono does not cover. + (dolist (char-range '((#x0250 . #x02af) ; IPA extensions + (#x2200 . #x22FF))) ; Mathematical operators + (set-fontset-font "fontset-default" char-range "JuliaMono"))) (use-package persp-mode + :disabled :unless noninteractive :commands persp-switch-to-buffer :hook (on-init-ui . persp-mode)