1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 19:51:17 +00:00

sourceHanPackages: add variable fonts

Variable fonts are much smaller than static Super OTC fonts (36M vs 112M) and has two formats (OTF and TTF)
This commit is contained in:
linsui 2023-10-05 02:53:54 +08:00
parent 349bdd9653
commit 185cef4cc0
2 changed files with 67 additions and 7 deletions

View file

@ -5,7 +5,7 @@
}:
let
makePackage =
makeSuperOTC =
{ family
, description
, rev
@ -13,9 +13,10 @@ let
, zip ? ""
, prefix ? ""
}:
let Family =
lib.toUpper (lib.substring 0 1 family) +
lib.substring 1 (lib.stringLength family) family;
let
Family =
lib.toUpper (lib.substring 0 1 family) +
lib.substring 1 (lib.stringLength family) family;
in
stdenvNoCC.mkDerivation rec {
pname = "source-han-${family}";
@ -49,9 +50,36 @@ let
maintainers = with lib.maintainers; [ taku0 emily ];
};
};
makeVariable =
{ family
, version
, hash
, format
}:
let
Family =
lib.toUpper (lib.substring 0 1 family) +
lib.substring 1 (lib.stringLength family) family;
in
fetchurl {
pname = "source-han-${family}-vf-${format}";
inherit version hash;
url = "https://raw.githubusercontent.com/adobe-fonts/source-han-${family}/${version}R/Variable/OTC/SourceHan${Family}-VF.${format}.ttc";
recursiveHash = true;
downloadToTemp = true;
postFetch = "install -Dm444 $downloadedFile $out/share/fonts/variable/SourceHan${Family}-VF.${format}.ttc";
meta = {
description = "An open source Pan-CJK ${Family} typeface";
homepage = "https://github.com/adobe-fonts/source-han-${family}";
license = lib.licenses.ofl;
maintainers = with lib.maintainers; [ taku0 emily ];
};
};
in
{
sans = makePackage {
sans = makeSuperOTC {
family = "sans";
description = "sans-serif";
rev = "2.004R";
@ -59,7 +87,7 @@ in
zip = ".zip";
};
serif = makePackage {
serif = makeSuperOTC {
family = "serif";
description = "serif";
rev = "2.001R";
@ -68,10 +96,38 @@ in
prefix = "01_";
};
mono = makePackage {
mono = makeSuperOTC {
family = "mono";
description = "monospaced";
rev = "1.002";
hash = "sha256-DBkkSN6QhI8R64M2h2iDqaNtxluJZeSJYAz8x6ZzWME=";
};
sans-vf-otf = makeVariable {
family = "sans";
version = "2.004";
hash = "sha256-V7PE09c7h4RDS8Ij4PSI36Gy+LM+PVDi73Rcs+4DfHo=";
format = "otf";
};
sans-vf-ttf = makeVariable {
family = "sans";
version = "2.004";
hash = "sha256-mXTG/d30gUxzxkJpaH4vOawRXMSxxTXlHCvHEsfGqbc=";
format = "ttf";
};
serif-vf-otf = makeVariable {
family = "serif";
version = "2.002";
hash = "sha256-8sD4bU6w7HBm4vBuPAjcjpxN2rtEJugAw+X0bAOcmjA=";
format = "otf";
};
serif-vf-ttf = makeVariable {
family = "serif";
version = "2.002";
hash = "sha256-dmTZFRsD55WCOg2+sqd8bkmTSnSNn5xUYf0PgzIvzww=";
format = "ttf";
};
}

View file

@ -30208,6 +30208,10 @@ with pkgs;
source-han-sans = sourceHanPackages.sans;
source-han-serif = sourceHanPackages.serif;
source-han-mono = sourceHanPackages.mono;
source-han-sans-vf-otf = sourceHanPackages.sans-vf-otf;
source-han-sans-vf-ttf = sourceHanPackages.sans-vf-ttf;
source-han-serif-vf-otf = sourceHanPackages.serif-vf-otf;
source-han-serif-vf-ttf = sourceHanPackages.serif-vf-ttf;
spleen = callPackage ../data/fonts/spleen { };