commit e71d8bd6bcca4ff3578368d3bf65304c47fab37f
parent e089b2956ca56652a1517963fa89bcb3ae9dd677
Author: Silas Brack <silasbrack@gmail.com>
Date: Thu, 30 Apr 2026 21:45:31 +0200
feat(gaia): refactor fonts
Diffstat:
1 file changed, 38 insertions(+), 51 deletions(-)
diff --git a/hosts/gaia/configuration.nix b/hosts/gaia/configuration.nix
@@ -126,57 +126,44 @@
"spotify"
];
- fonts.packages = with pkgs; [
- nerd-fonts.jetbrains-mono
- nerd-fonts.iosevka
- font-bitstream-type1
- merriweather
- (pkgs.runCommand "cooper-hewitt-fixed" {
- nativeBuildInputs = [ pkgs.python3Packages.fonttools ];
- } ''
- mkdir -p $out/share/fonts/opentype
-
- python3 - \
- ${pkgs.cooper-hewitt}/share/fonts/opentype \
- $out/share/fonts/opentype \
- << 'EOF'
-import sys, os
-from fontTools.ttLib import TTFont
-
-# Must be ordered: longer/more-specific names first
-# to avoid e.g. "Bold" matching inside "SemiBold"
-weight_map = [
- ("Thin", 100),
- ("Light", 300),
- ("Book", 400),
- ("Medium", 500),
- ("Semibold", 600),
- ("SemiBold", 600),
- ("Bold", 700),
- ("Heavy", 800),
-]
-
-src_dir, out_dir = sys.argv[1], sys.argv[2]
-
-for fname in sorted(os.listdir(src_dir)):
- if not fname.endswith((".otf", ".ttf")):
- continue
- path = os.path.join(src_dir, fname)
- font = TTFont(path)
- old_w = font["OS/2"].usWeightClass
- matched = False
- for key, w in weight_map:
- if key in fname:
- font["OS/2"].usWeightClass = w
- print(f"{fname}: {old_w} -> {w}")
- matched = True
- break
- if not matched:
- print(f"WARNING: no weight match for {fname}", flush=True)
- font.save(os.path.join(out_dir, fname))
-EOF
- '')
- ];
+ fonts = {
+ enableDefaultPackages = true;
+ packages = with pkgs; [
+ nerd-fonts.jetbrains-mono
+ nerd-fonts.iosevka
+ # font-bitstream-type1
+ ibm-plex
+ # source-sans
+ merriweather
+ # atkinson-hyperlegible
+ libertinus
+ # noto-fonts
+ ];
+ fontconfig = {
+ enable = true;
+ hinting.style = "slight";
+ subpixel.rgba = "rgb";
+ defaultFonts = {
+ sansSerif = [ "IBM Plex Sans" ];
+ serif = [ "Merriweather" ];
+ monospace = [ "JetBrains Mono" ];
+ };
+ confPackages = [
+ (pkgs.writeTextDir "etc/fonts/conf.d/99-math.conf" ''
+ <?xml version="1.0"?>
+ <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+ <fontconfig>
+ <alias>
+ <family>math</family>
+ <prefer>
+ <family>Libertinus</family>
+ </prefer>
+ </alias>
+ </fontconfig>
+ '')
+ ];
+ };
+ };
users.users.silas = {
isNormalUser = true;