about summary refs log tree commit diff
path: root/pkgs/data
diff options
context:
space:
mode:
authorEmily <vcs@emily.moe>2020-02-10 22:59:42 +0000
committerYegor Timoshenko <yegortimoshenko@riseup.net>2020-02-29 14:57:27 +0300
commit6eb45bf38ac122a242be8bce2b9868ac72a6e0cc (patch)
treefa6f911fef7395f98101b00444d46ad7e82c6ac6 /pkgs/data
parentc580dfc0cee3a201521df41ce4c8adbdecd971c0 (diff)
source-han-{sans,serif,mono}: {update,refactor,init}
* source-han-sans: 1.004R -> 2.001
* source-han-serif: switch to Super OTC
* source-han-mono: init at 1.002

The Source Han fonts now use shared package infrastructure, and the
Super OTC distributions, which unify the various scripts into a single
bundle file, improving automatic font selection and reducing overall
disk space usage. This also means that the Traditional
Chinese—Hong Kong language variant is now included.

The old package names including language are aliased to the Super OTC
bundle packages.
Diffstat (limited to 'pkgs/data')
-rw-r--r--pkgs/data/fonts/source-han-sans/default.nix52
-rw-r--r--pkgs/data/fonts/source-han-serif/default.nix52
-rw-r--r--pkgs/data/fonts/source-han/default.nix54
3 files changed, 54 insertions, 104 deletions
diff --git a/pkgs/data/fonts/source-han-sans/default.nix b/pkgs/data/fonts/source-han-sans/default.nix
deleted file mode 100644
index 87e24c0e23c3e..0000000000000
--- a/pkgs/data/fonts/source-han-sans/default.nix
+++ /dev/null
@@ -1,52 +0,0 @@
-{ lib, fetchzip }:
-
-let
-  makePackage = {variant, language, region, sha256}: let
-    version = "1.004R";
-    revision = "5f5311e71cb628321cc0cffb51fb38d862b726aa";
-  in fetchzip {
-    name = "source-han-sans-${variant}-${version}";
-
-    url = "https://github.com/adobe-fonts/source-han-sans/raw/${revision}/SubsetOTF/SourceHanSans${region}.zip";
-
-    postFetch = ''
-      mkdir -p $out/share/fonts
-      unzip -j $downloadedFile \*.otf -d $out/share/fonts/opentype
-    '';
-
-    inherit sha256;
-
-    meta = {
-      description = "${language} subset of an open source Pan-CJK sans-serif typeface";
-      homepage = https://github.com/adobe-fonts/source-han-sans;
-      license = lib.licenses.ofl;
-      maintainers = with lib.maintainers; [ taku0 ];
-    };
-  };
-in
-{
-  japanese = makePackage {
-    variant = "japanese";
-    language = "Japanese";
-    region = "JP";
-    sha256 = "194zapswaqly8ycx3k66vznlapvpyhdigp3sabsl4hn87j9xsc5v";
-  };
-  korean = makePackage {
-    variant = "korean";
-    language = "Korean";
-    region = "KR";
-    sha256 = "0xij6mciiqgpwv1agqily2jji377x084k7fj4rpv6z0r5vvhqr08";
-  };
-  simplified-chinese = makePackage {
-    variant = "simplified-chinese";
-    language = "Simplified Chinese";
-    region = "CN";
-    sha256 = "038av18d45qr85bgx95j2fm8j64d72nsm9xzg0lpwr9xwni2sbx0";
-  };
-  traditional-chinese = makePackage {
-    variant = "traditional-chinese";
-    language = "Traditional Chinese";
-    region = "TW";
-    sha256 = "1mzcv5hksyxplyv5q3w5nr1xz73hdnvip5gicz35j0by4gc739lr";
-  };
-}
diff --git a/pkgs/data/fonts/source-han-serif/default.nix b/pkgs/data/fonts/source-han-serif/default.nix
deleted file mode 100644
index bb5a67c830684..0000000000000
--- a/pkgs/data/fonts/source-han-serif/default.nix
+++ /dev/null
@@ -1,52 +0,0 @@
-{ lib, fetchzip }:
-
-let
-  makePackage = {variant, language, region, sha256}: let
-    version = "1.000R";
-    revision = "f6cf97d92b22e7bd77e355a61fe549ae44b6de76";
-  in fetchzip {
-    name = "source-han-serif-${variant}-${version}";
-
-    url = "https://github.com/adobe-fonts/source-han-serif/raw/${revision}/SubsetOTF/SourceHanSerif${region}.zip";
-
-    postFetch = ''
-      mkdir -p $out/share/fonts/opentype
-      unzip -j $downloadedFile \*.otf -d $out/share/fonts/opentype
-    '';
-
-    inherit sha256;
-
-    meta = {
-      description = "${language} subset of an open source Pan-CJK serif typeface";
-      homepage = https://github.com/adobe-fonts/source-han-sans;
-      license = lib.licenses.ofl;
-      maintainers = with lib.maintainers; [ taku0 ];
-    };
-  };
-in
-{
-  japanese = makePackage {
-    variant = "japanese";
-    language = "Japanese";
-    region = "JP";
-    sha256 = "0cklcy6y3r7pg8z43fzd8zl5g46bkqa1iy0li49rm0fgdaw7kin2";
-  };
-  korean = makePackage {
-    variant = "korean";
-    language = "Korean";
-    region = "KR";
-    sha256 = "0lxrr978djsych8fmbl57n1c9c7ihl61w0b9q4plw27vd6p41fza";
-  };
-  simplified-chinese = makePackage {
-    variant = "simplified-chinese";
-    language = "Simplified Chinese";
-    region = "CN";
-    sha256 = "0k3x4kncjnbipf4i3lkk6b33zpf1ckp5648z51v48q47l3zqpm6p";
-  };
-  traditional-chinese = makePackage {
-    variant = "traditional-chinese";
-    language = "Traditional Chinese";
-    region = "TW";
-    sha256 = "00bi66nlkrargmmf4av24qfd716py7a9smcvr4xnll7fffldxv06";
-  };
-}
diff --git a/pkgs/data/fonts/source-han/default.nix b/pkgs/data/fonts/source-han/default.nix
new file mode 100644
index 0000000000000..7b6bef0198da4
--- /dev/null
+++ b/pkgs/data/fonts/source-han/default.nix
@@ -0,0 +1,54 @@
+{ stdenvNoCC
+, lib
+, fetchzip
+, fetchurl
+}:
+
+let
+  makePackage = { family, description, rev, sha256 }: let
+    Family =
+      lib.toUpper (lib.substring 0 1 family) +
+      lib.substring 1 (lib.stringLength family) family;
+
+    ttc = fetchurl {
+      url = "https://github.com/adobe-fonts/source-han-${family}/releases/download/${rev}/SourceHan${Family}.ttc";
+      inherit sha256;
+    };
+  in stdenvNoCC.mkDerivation {
+    pname = "source-han-${family}";
+    version = lib.removeSuffix "R" rev;
+
+    buildCommand = ''
+      install -m444 -Dt $out/share/fonts/opentype/source-han-${family} ${ttc}
+    '';
+
+    meta = {
+      description = "An open source Pan-CJK ${description} typeface";
+      homepage = "https://github.com/adobe-fonts/source-han-${family}";
+      license = lib.licenses.ofl;
+      maintainers = with lib.maintainers; [ taku0 emily ];
+    };
+  };
+in
+{
+  sans = makePackage {
+    family = "sans";
+    description = "sans-serif";
+    rev = "2.001R";
+    sha256 = "101p8q0sagf1sd1yzwdrmmxvkqq7j0b8hi0ywsfck9w56r4zx54y";
+  };
+
+  serif = makePackage {
+    family = "serif";
+    description = "serif";
+    rev = "1.001R";
+    sha256 = "1d968h30qvvwy3s77m9y3f1glq8zlr6bnfw00yinqa18l97n7k45";
+  };
+
+  mono = makePackage {
+    family = "mono";
+    description = "monospaced";
+    rev = "1.002";
+    sha256 = "1haqffkcgz0cc24y8rc9bg36v8x9hdl8fdl3xc8qz14hvr42868c";
+  };
+}