From f0c1d0c084350492ba17dbcc402c159af766396f Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 18 Mar 2023 18:49:20 -0400 Subject: fix font bloat Signed-off-by: Xe Iaso --- flake.lock | 52 +++++++++++++++- flake.nix | 172 +++++++--------------------------------------------- static/css/hack.css | 8 +-- 3 files changed, 76 insertions(+), 156 deletions(-) diff --git a/flake.lock b/flake.lock index d2c1824..2009f26 100644 --- a/flake.lock +++ b/flake.lock @@ -97,6 +97,25 @@ "type": "github" } }, + "iosevka": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + }, + "locked": { + "lastModified": 1679172980, + "narHash": "sha256-B9RMXNbKk6ZY1Xom/3j/psIW7xJIaWTy1hSOplvDjps=", + "owner": "Xe", + "repo": "iosevka", + "rev": "7ff508fdc3b00f822d4b8dcd14f0ed2a5eb302fd", + "type": "github" + }, + "original": { + "owner": "Xe", + "repo": "iosevka", + "type": "github" + } + }, "naersk": { "inputs": { "nixpkgs": [ @@ -132,13 +151,44 @@ "type": "indirect" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1678898370, + "narHash": "sha256-xTICr1j+uat5hk9FyuPOFGxpWHdJRibwZC+ATi0RbtE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ac718d02867a84b42522a0ece52d841188208f2c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, "root": { "inputs": { "deno2nix": "deno2nix", "flake-compat": "flake-compat_2", "flake-utils": "flake-utils", + "iosevka": "iosevka", "naersk": "naersk", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs_2" + } + }, + "utils": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 8db7b09..29f5851 100644 --- a/flake.nix +++ b/flake.nix @@ -20,9 +20,12 @@ inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; + + # Explicitly pulling from that version of nixpkgs to avoid font duplication. + iosevka.url = "github:Xe/iosevka"; }; - outputs = { self, nixpkgs, flake-utils, naersk, deno2nix, ... }: + outputs = { self, nixpkgs, flake-utils, naersk, deno2nix, iosevka, ... }: flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system: let pkgs = import nixpkgs { @@ -113,163 +116,29 @@ }; iosevka = pkgs.stdenvNoCC.mkDerivation { - name = "custom-iosevka"; + name = "xesite-iosevka"; + buildInputs = with pkgs; [ python311Packages.brotli python311Packages.fonttools ]; dontUnpack = true; buildPhase = - let - metric-override = { - cap = 790; - ascender = 790; - xHeight = 570; - }; - iosevka-term = pkgs.iosevka.override { - set = "curly"; - privateBuildPlan = { - family = "Iosevka Term Iaso"; - spacing = "term"; - serifs = "sans"; - no-ligation = false; - ligations = { - "inherit" = "default-calt"; - }; - no-cv-ss = true; - variants = { - inherits = "ss01"; - design = { - tilde = "low"; - number-sign = "slanted-tall"; - at = "fourfold-solid-inner-tall"; - }; - }; - slopes.upright = { - angle = 0; - shape = "upright"; - menu = "upright"; - css = "normal"; - }; - weights.regular = { - shape = 400; - menu = 400; - css = 400; - }; - widths.normal = { - shape = 600; - menu = 7; - css = "expanded"; - }; - inherit metric-override; - }; - }; - iosevka-aile = pkgs.iosevka.override { - set = "aile"; - privateBuildPlan = { - family = "Iosevka Aile Iaso"; - spacing = "quasi-proportional-extension-only"; - no-ligation = true; - no-cv-ss = true; - variants = { - inherits = "ss01"; - design = { - tilde = "low"; - number-sign = "slanted-tall"; - at = "fourfold-solid-inner-tall"; - }; - }; - slopes = { - upright = { - angle = 0; - shape = "upright"; - menu = "upright"; - css = "normal"; - }; - italic = { - angle = 9.4; - shape = "italic"; - menu = "italic"; - css = "italic"; - }; - }; - weights.regular = { - shape = 400; - menu = 400; - css = 400; - }; - widths.normal = { - shape = 550; - menu = 7; - css = "expanded"; - }; - inherit metric-override; - }; - }; - iosevka-etoile = pkgs.iosevka.override { - set = "etoile"; - privateBuildPlan = { - family = "Iosevka Etoile Iaso"; - spacing = "quasi-proportional"; - serifs = "slab"; - no-ligation = true; - no-cv-ss = true; - variants = { - inherits = "ss01"; - design = { - capital-w = "straight-flat-top"; - f = "flat-hook-serifed"; - j = "flat-hook-serifed"; - t = "flat-hook"; - capital-t = "serifed"; # not part of original Iosevka Aile - w = "straight-flat-top"; - #capital-g = "toothless-rounded-serifless-hooked"; - r = "corner-hooked"; - - tilde = "low"; - number-sign = "slanted-tall"; - at = "fourfold-solid-inner-tall"; - }; - italic = { - f = "flat-hook-tailed"; - }; - }; - slopes = { - upright = { - angle = 0; - shape = "upright"; - menu = "upright"; - css = "normal"; - }; - italic = { - angle = 9.4; - shape = "italic"; - menu = "italic"; - css = "italic"; - }; - }; - weights.regular = { - shape = 400; - menu = 400; - css = 400; - }; - widths.normal = { - shape = 600; - menu = 7; - css = "expanded"; - }; - inherit metric-override; - }; - }; - in '' - mkdir -p ttf - for ttf in ${iosevka-term}/share/fonts/truetype/*.ttf ${iosevka-aile}/share/fonts/truetype/*.ttf ${iosevka-etoile}/share/fonts/truetype/*.ttf; do - cp $ttf . - ${pkgs.woff2}/bin/woff2_compress *.ttf - mv *.ttf ttf + mkdir -p out + for ttf in ${self.inputs.iosevka.packages.${system}.default}/*.ttf; do + cp $ttf out + name=`basename -s .ttf $ttf` + pyftsubset \ + $ttf \ + --output-file=out/"$name".woff2 \ + --flavor=woff2 \ + --layout-features=* \ + --no-hinting \ + --desubroutinize \ + --unicodes="U+0000-00A0,U+00A2-00A9,U+00AC-00AE,U+00B0-00B7,U+00B9-00BA,U+00BC-00BE,U+00D7,U+00F7,U+2000-206F,U+2074,U+20AC,U+2122,U+2190-21BB,U+2212,U+2215,U+F8FF,U+FEFF,U+FFFD" done + ''; installPhase = '' mkdir -p $out/static/css/iosevka - cp *.woff2 $out/static/css/iosevka - cp ttf/*.ttf $out/static/css/iosevka + cp out/* $out/static/css/iosevka ''; }; @@ -349,6 +218,7 @@ # tools ispell pandoc + python311Packages.fonttools ]; SITE_PREFIX = "devel."; diff --git a/static/css/hack.css b/static/css/hack.css index c8be19c..e3615aa 100644 --- a/static/css/hack.css +++ b/static/css/hack.css @@ -11,9 +11,9 @@ } @font-face { - font-family: "Iosevka Term Iaso"; + font-family: "Iosevka Curly Iaso"; font-weight: 100 900; - src: local("Iosevka Term Iaso"), url("iosevka/iosevka-curly-regular.woff2") format("woff2"); + src: local("Iosevka Curly Iaso"), url("iosevka/iosevka-curly-regular.woff2") format("woff2"); } html { @@ -49,10 +49,10 @@ pre code { text-shadow: none; margin: 1.75rem 0; font-size: 1.5rem; - font-family: "Iosevka Term Iaso", Menlo, monospace; + font-family: "Iosevka Curly Iaso", Menlo, monospace; } code { - font-family: "Iosevka Term Iaso", Menlo, monospace; + font-family: "Iosevka Curly Iaso", Menlo, monospace; } iframe { max-width: 100%; -- cgit v1.2.3