Convert gg sans to ttf

This commit is contained in:
Artemis Tosini 2023-12-17 19:19:46 +00:00
parent a5002a6881
commit 5345a28290
Signed by: artemist
GPG key ID: EE5227935FE3FF18
8 changed files with 36 additions and 42 deletions

View file

@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1692799911, "lastModified": 1701680307,
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", "rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1694310981, "lastModified": 1702840599,
"narHash": "sha256-Rf6ICXzUXfi2ILwEggBJMmVVR06AKS5DMcXZd1qi24o=", "narHash": "sha256-jjWgSOWriN0fJ/uh3kkKzQjb9O21GdTsfDo1JVg75Xg=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "49772c4112bf70d28086b459d31710408745f842", "rev": "b425dc72ad3eb4d71524c0af237fcc7a728247f6",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -5,48 +5,42 @@
nixpkgs.url = "github:nixos/nixpkgs"; nixpkgs.url = "github:nixos/nixpkgs";
}; };
outputs = { outputs = { self, nixpkgs, flake-utils, }:
self,
nixpkgs,
flake-utils,
}:
with builtins; with builtins;
with nixpkgs.lib; with nixpkgs.lib;
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
pathEndsWith = suffix: path: let pathEndsWith = suffix: path:
let
str = toString path; str = toString path;
sufLen = stringLength suffix; sufLen = stringLength suffix;
sLen = stringLength str; sLen = stringLength str;
in in sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str;
sufLen <= sLen && suffix == substring (sLen - sufLen) sufLen str;
buildFont = { buildFont = { name, files, license, author, }:
name, let
files, copyType = extension: pathName:
license, let
author,
}: let
copyType = extension: pathName: let
filteredFiles = filter (pathEndsWith ("." + extension)) files; filteredFiles = filter (pathEndsWith ("." + extension)) files;
filename = file: lists.last (strings.splitString "/" (toString file)); filename = file:
in lists.last (strings.splitString "/" (toString file));
(optionalString (filteredFiles != []) "mkdir -p $out/share/fonts/${pathName}\n") in (optionalString (filteredFiles != [ ]) ''
+ concatStringsSep "\n" (map (file: "cp -v ${file} $out/share/fonts/${pathName}/${filename file}") mkdir -p $out/share/fonts/${pathName}
'') + concatStringsSep "\n" (map (file:
"cp -v ${file} $out/share/fonts/${pathName}/${filename file}")
filteredFiles); filteredFiles);
in in pkgs.stdenvNoCC.mkDerivation {
pkgs.stdenvNoCC.mkDerivation {
inherit name; inherit name;
dontUnpack = true; dontUnpack = true;
installPhase = '' installPhase = ''
${copyType "ttf" "truetype"} ${copyType "ttf" "truetype"}
${copyType "otf" "opentype"} ${copyType "otf" "opentype"}
${copyType "woff2" "woff2"}
''; '';
meta = { meta = {
@ -59,30 +53,30 @@
fonts = [ fonts = [
{ {
name = "OCR-B"; name = "OCR-B";
files = [./OCR-B-Regular.otf]; files = [ ./OCR-B-Regular.otf ];
license = licenses.cc-by-40; license = licenses.cc-by-40;
author = "Matthew Anderson"; author = "Matthew Anderson";
} }
{ {
name = "gg sans"; name = "gg sans";
files = [./ggsans-Normal.woff2 ./ggsans-Medium.woff2 ./ggsans-SemiBold.woff2]; files =
[ ./ggsans-Normal.ttf ./ggsans-Medium.ttf ./ggsans-SemiBold.ttf ];
license = licenses.unfree; license = licenses.unfree;
author = "Colophon Foundry"; author = "Colophon Foundry";
} }
{ {
name = "Caveat"; name = "Caveat";
files = [./Caveat.ttf]; files = [ ./Caveat.ttf ];
license = licenses.ofl; license = licenses.ofl;
author = "Pablo Impallari and Alexi Vanyashin"; author = "Pablo Impallari and Alexi Vanyashin";
} }
]; ];
in { in {
packages = listToAttrs (map (font: { packages = listToAttrs (map (font: {
name = replaceStrings [" "] ["-"] (toLower font.name); name = replaceStrings [ " " ] [ "-" ] (toLower font.name);
value = buildFont font; value = buildFont font;
}) }) fonts);
fonts);
formatter = pkgs.alejandra; formatter = pkgs.nixfmt;
}); });
} }

BIN
ggsans-Medium.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
ggsans-Normal.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
ggsans-SemiBold.ttf Normal file

Binary file not shown.

Binary file not shown.