From 61428a5c8b45e11268aa5560274f280f36b639e4 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 16 Sep 2023 14:59:12 +0000 Subject: [PATCH] unify fonts across sway and sxmo --- hosts/by-name/moby/polyfill.nix | 2 +- hosts/common/programs/conky/conky.conf | 14 +++--- hosts/common/programs/fontconfig.nix | 65 +++++++++++++++++++++++--- hosts/modules/gui/sxmo/default.nix | 8 +--- 4 files changed, 68 insertions(+), 21 deletions(-) diff --git a/hosts/by-name/moby/polyfill.nix b/hosts/by-name/moby/polyfill.nix index 32183013..997a3e73 100644 --- a/hosts/by-name/moby/polyfill.nix +++ b/hosts/by-name/moby/polyfill.nix @@ -107,7 +107,7 @@ "--center --margin 45" "--no-spacing" # XXX: font size doesn't seem to take effect (would prefer larger) - "--fn 'Sxmo 14' --line-height 22 --border 3" + "--fn 'monospace 14' --line-height 22 --border 3" "--bdr '${accent0}'" # border "--scf '${accent2}' --scb '${accent0}'" # scrollbar "--tb '${accent0}' --tf '${fg0}'" # title diff --git a/hosts/common/programs/conky/conky.conf b/hosts/common/programs/conky/conky.conf index 3b493122..32d6feca 100644 --- a/hosts/common/programs/conky/conky.conf +++ b/hosts/common/programs/conky/conky.conf @@ -27,7 +27,7 @@ conky.config = { default_shade_color = '#beebe5', default_outline_color = '#beebe5', - font = 'Sxmo:size=8', + font = 'sans-serif:size=8', use_xft = true, default_color = '#ffffff', @@ -37,14 +37,14 @@ conky.config = { -- texeci : run the command periodically, _in a separate thread_ so as not to block rendering conky.text = [[ -${color1}${shadecolor 707070}${font Sxmo:size=50:style=Bold}${alignc}${exec date +"%H:%M"}${font} -${color2}${shadecolor a4d7d0}${font Sxmo:size=20}${alignc}${exec date +"%a %d %b"}${font} +${color1}${shadecolor 707070}${font sans-serif:size=50:style=Bold}${alignc}${exec date +"%H:%M"}${font} +${color2}${shadecolor a4d7d0}${font sans-serif:size=20}${alignc}${exec date +"%a %d %b"}${font} -${color1}${shadecolor}${font Sxmo:size=22:style=Bold}${alignc}${exec @bat@ }${font} -${color1}${shadecolor}${font Sxmo:size=20:style=Bold}${alignc}${texeci 600 @weather@ }${font} +${color1}${shadecolor}${font sans-serif:size=22:style=Bold}${alignc}${exec @bat@ }${font} +${color1}${shadecolor}${font sans-serif:size=20:style=Bold}${alignc}${texeci 600 @weather@ }${font} -${color2}${shadecolor a4d7d0}${font Sxmo:size=16}${alignc}⇅ ${downspeedf wlan0}K/s${font} -${font Sxmo:size=16}${alignc}☵ $memperc%  $cpu%${font} +${color2}${shadecolor a4d7d0}${font sans-serif:size=16}${alignc}⇅ ${downspeedf wlan0}K/s${font} +${font sans-serif:size=16}${alignc}☵ $memperc%  $cpu%${font} ]] diff --git a/hosts/common/programs/fontconfig.nix b/hosts/common/programs/fontconfig.nix index 41c87f53..3d040491 100644 --- a/hosts/common/programs/fontconfig.nix +++ b/hosts/common/programs/fontconfig.nix @@ -1,15 +1,68 @@ +# to preview fonts: +# - `font-manager` (gui) +# - useful to determine official name; codepoint support { config, lib, pkgs, ... }: +let + # nerdfonts takes popular open fonts and patches them to support a wider range of glyphs, notably emoji. + # any nerdfonts font includes icons such as these: + # - 󱊥 (battery charging) + # - 󰃝 (brightness) + # -  (gps / crosshairs) + # - 󰎈 (music note) + # - 󰍦 (message bubble) + # - 󰏲 (phone) + # -  (weather/sun-behind-clouds) + # used particularly by sxmo utilities, but also a few of my own (e.g. conky) + # + # nerdfonts is very heavy. each font is 20-900 MiB (2 MiB per "variation") + # lots of redundant data inside there, but no deduplication except whatever nix or the fs does implicitly. + wantedNerdfonts = [ + # used explicitly by SXMO + # "DejaVuSansMono" # 25 MiB + # good terminal/coding font. grab via nerdfonts for more emoji/unicode support + "Hack" # 26 MiB + "Noto" # 861 MiB + ]; + nerdfontPkgs = builtins.map + (f: pkgs.nerdfonts.override { fonts = [ f ]; }) + wantedNerdfonts; +in { fonts = lib.mkIf config.sane.programs.fontconfig.enabled { fontconfig.enable = true; fontconfig.defaultFonts = { - emoji = [ "Font Awesome 6 Free" "Noto Color Emoji" ]; - monospace = [ "Hack" ]; - serif = [ "DejaVu Serif" ]; - sansSerif = [ "DejaVu Sans" ]; + emoji = [ + "Noto Color Emoji" + "Font Awesome 6 Free" + "Font Awesome 6 Brands" + ]; + monospace = [ + "Hack Nerd Font Propo" + # "DejaVuSansM Nerd Font Propo" + "NotoMono Nerd Font Propo" + ]; + serif = [ + "NotoSerif Nerd Font" + "DejaVu Serif" + ]; + sansSerif = [ + "NotoSans Nerd Font" + "DejaVu Sans" + ]; }; #vvv enables dejavu_fonts, freefont_ttf, gyre-fonts, liberation_ttf, unifont, noto-fonts-emoji - enableDefaultPackages = true; - packages = with pkgs; [ font-awesome noto-fonts-emoji hack-font ]; + enableDefaultPackages = false; + packages = with pkgs; [ + # TODO: reduce this font set. + # - probably need only one of dejavu/freefont/liberation + dejavu_fonts # 10 MiB; DejaVu {Sans,Serif,Sans Mono,Math TeX Gyre}; also available as a NerdFonts (Sans Mono only) + font-awesome # 2 MiB; Font Awesome 6 {Free,Brands} + freefont_ttf # 11 MiB; Free{Mono,Sans,Serif} + gyre-fonts # 4 MiB; Tex Gyre *; ttf substitutes for standard PostScript fonts + # hack-font # 1 MiB; Hack; also available as a NerdFonts + liberation_ttf # 4 MiB; Liberation {Mono,Sans,Serif}; also available as a NerdFonts + noto-fonts-color-emoji # 10 Mib; Noto Color Emoji + unifont # 16 MiB; Unifont; provides LOTS of unicode coverage + ] ++ nerdfontPkgs; }; } diff --git a/hosts/modules/gui/sxmo/default.nix b/hosts/modules/gui/sxmo/default.nix index 93dfedf3..8bb59480 100644 --- a/hosts/modules/gui/sxmo/default.nix +++ b/hosts/modules/gui/sxmo/default.nix @@ -209,7 +209,7 @@ in # - `bindsym $mod+Shift+p exec sxmo_appmenu.sh sys` # - `input * xkb_options compose:ralt` # these could be added, but i don't see much benefit. - font = "Sxmo 10"; + font = "pango:monospace 10"; mod = "Mod1"; # prefer Alt xwayland = false; # disable to reduce RAM usage. workspace_layout = "tabbed"; @@ -282,12 +282,6 @@ in security.doas.enable = true; security.doas.wheelNeedsPassword = false; - # TODO: nerdfonts is 4GB. it accepts an option to ship only some fonts: probably want to use that. - # sxmo needs nerdfonts for: - # - waybar icons - # - dmenu/bemenu icons - fonts.packages = [ pkgs.nerdfonts ]; - # lightdm-mobile-greeter: "The name org.a11y.Bus was not provided by any .service files" services.gnome.at-spi2-core.enable = true;