unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] gnu: Add font-adobe-source-han-sans.
@ 2015-02-27  6:02 宋文武
  2015-02-27 10:14 ` Andreas Enge
  0 siblings, 1 reply; 5+ messages in thread
From: 宋文武 @ 2015-02-27  6:02 UTC (permalink / raw)
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-gnu-Add-font-adobe-source-han-sans.patch --]
[-- Type: text/x-patch, Size: 3837 bytes --]

From 9d600fef4f18a985c97be51a31ecd0b52bd7f148 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 27 Feb 2015 13:59:29 +0800
Subject: [PATCH] gnu: Add font-adobe-source-han-sans.

* gnu/packages/fonts.scm (font-adobe-source-han-sans): New variable.
---
 gnu/packages/fonts.scm | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 94993f0..2fa88eb 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Joshua Grant <tadni@riseup.net>
 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -303,3 +304,59 @@ The Liberation Fonts are sponsored by Red Hat.")
     (description "Terminus Font is a clean, fixed width bitmap font, designed
 for long (8 and more hours per day) work with computers.")
     (license license:silofl1.1)))
+
+(define-public font-adobe-source-han-sans
+  (package
+    (name "font-adobe-source-han-sans")
+    (version "1.001R")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/adobe-fonts/source-han-sans/archive/"
+                    version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "0cwz3d8jancl0a7vbjxhnh1vgwsjba62lahfjya9yrjkp1ndxlap"))))
+    (outputs '("out" "cn" "jp" "kr" "tw"))
+    (build-system gnu-build-system)
+    (arguments
+     '(#:modules ((guix build gnu-build-system)
+                  (guix build utils)
+                  (srfi srfi-26))
+       #:imported-modules ((guix build gnu-build-system)
+                           (guix build utils))
+       #:phases
+       (alist-replace
+        'install
+        (lambda* (#:key outputs #:allow-other-keys)
+          (define (install-opentype-font font out)
+            (let* ((font-dir (string-append out "/share/fonts/opentype"))
+                   (newfont (string-append font-dir "/" (basename font))))
+              (mkdir-p font-dir)
+              (copy-file font newfont)))
+          ;; Install OpenType/CFF collection (OTC).
+          (for-each (cut install-opentype-font <> (assoc-ref outputs "out"))
+                    (find-files "OTC" "\\.ttc"))
+          ;; Install region-specific subset OpenType/CFF (Subset OTF).
+          (for-each (cut install-opentype-font <> (assoc-ref outputs "cn"))
+                    (find-files "SubsetOTF/CN" "\\.otf"))
+          (for-each (cut install-opentype-font <> (assoc-ref outputs "jp"))
+                    (find-files "SubsetOTF/JP" "\\.otf"))
+          (for-each (cut install-opentype-font <> (assoc-ref outputs "kr"))
+                    (find-files "SubsetOTF/KR" "\\.otf"))
+          (for-each (cut install-opentype-font <> (assoc-ref outputs "tw"))
+                    (find-files "SubsetOTF/TW" "\\.otf")))
+        (map (cut assq <> %standard-phases)
+             '(set-paths unpack install)))))
+    (home-page "https://github.com/adobe-fonts/source-han-sans")
+    (synopsis "Pan-CJK fonts")
+    (description
+     "Source Han Sans is a sans serif Pan-CJK font family that is offered in
+seven weights: ExtraLight, Light, Normal, Regular, Medium, Bold, and Heavy.
+And in several OpenType/CFF-based deployment configurations to accommodate
+various system requirements or limitations.  As the name suggests, Pan-CJK
+fonts are intended to support the characters necessary to render or display
+text in Simplified Chinese, Traditional Chinese, Japanese, and Korean.
+")
+    (license license:asl2.0)))
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] gnu: Add font-adobe-source-han-sans.
  2015-02-27  6:02 [PATCH] gnu: Add font-adobe-source-han-sans 宋文武
@ 2015-02-27 10:14 ` Andreas Enge
  2015-02-27 10:16   ` Andreas Enge
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Enge @ 2015-02-27 10:14 UTC (permalink / raw)
  To: 宋文武; +Cc: Guix-devel

Great, thanks for your work!

On Fri, Feb 27, 2015 at 02:02:56PM +0800, 宋文武 wrote:
> +    (outputs '("out" "cn" "jp" "kr" "tw"))

I wondered if that was needed, but after downloading the source, I agree it
is the right thing to do!

> +    (build-system gnu-build-system)

I would go for trivial-build-system here. Or the unpack-build-system
that has not yet been written :-)

> +        (lambda* (#:key outputs #:allow-other-keys)
> +          (define (install-opentype-font font out)
> +            (let* ((font-dir (string-append out "/share/fonts/opentype"))
> +                   (newfont (string-append font-dir "/" (basename font))))
> +              (mkdir-p font-dir)
> +              (copy-file font newfont)))

I think it would be more elegant to use
  (let ((install-opentype-font (lambda (font out) ...
here; it defines a variable install-opentype-font for the expression inside
the body of "let", and this variable contains a function.

> +          ;; Install OpenType/CFF collection (OTC).
> +          (for-each (cut install-opentype-font <> (assoc-ref outputs "out"))
> +                    (find-files "OTC" "\\.ttc"))

If I see correctly, this copies each file separately, but also calls
"(mkdir-p font-dir)" each time, right? The output directories should be
created only once. You can use "copy-recursively" from (guix build utils),
see a few examples in the distribution.

Maybe add a comment what is in "out" (truetype fonts?) and in the other
outputs (open type fonts?).

Andreas

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gnu: Add font-adobe-source-han-sans.
  2015-02-27 10:14 ` Andreas Enge
@ 2015-02-27 10:16   ` Andreas Enge
  2015-02-28  3:23     ` 宋文武
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Enge @ 2015-02-27 10:16 UTC (permalink / raw)
  To: 宋文武; +Cc: Guix-devel

On Fri, Feb 27, 2015 at 11:14:05AM +0100, Andreas Enge wrote:
> You can use "copy-recursively" from (guix build utils),
> see a few examples in the distribution.

PS: And actually then, I think the function install-opentype-font disappears.
    So my previous point becomes moot.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gnu: Add font-adobe-source-han-sans.
  2015-02-27 10:16   ` Andreas Enge
@ 2015-02-28  3:23     ` 宋文武
  2015-02-28  9:46       ` Andreas Enge
  0 siblings, 1 reply; 5+ messages in thread
From: 宋文武 @ 2015-02-28  3:23 UTC (permalink / raw)
  To: Andreas Enge; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

2015-02-27 18:16 GMT+08:00 Andreas Enge <andreas@enge.fr>:
> On Fri, Feb 27, 2015 at 11:14:05AM +0100, Andreas Enge wrote:
>> You can use "copy-recursively" from (guix build utils),
>> see a few examples in the distribution.
Yes.
>
> PS: And actually then, I think the function install-opentype-font disappears.
>     So my previous point becomes moot.
>
Updated patch:

[-- Attachment #2: 0001-gnu-Add-font-adobe-source-han-sans.patch --]
[-- Type: text/x-patch, Size: 3699 bytes --]

From 344400aadb474061f18a1fe5e6b8d514d80689eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 27 Feb 2015 13:59:29 +0800
Subject: [PATCH] gnu: Add font-adobe-source-han-sans.

* gnu/packages/fonts.scm (font-adobe-source-han-sans): New variable.
---
 gnu/packages/fonts.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 94993f0..bb5bdec 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Joshua Grant <tadni@riseup.net>
 ;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -303,3 +304,58 @@ The Liberation Fonts are sponsored by Red Hat.")
     (description "Terminus Font is a clean, fixed width bitmap font, designed
 for long (8 and more hours per day) work with computers.")
     (license license:silofl1.1)))
+
+(define-public font-adobe-source-han-sans
+  (package
+    (name "font-adobe-source-han-sans")
+    (version "1.001R")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/adobe-fonts/source-han-sans/archive/"
+                    version ".tar.gz"))
+              (file-name (string-append "source-han-sans-" version ".tar.gz"))
+              (sha256
+               (base32
+                "0cwz3d8jancl0a7vbjxhnh1vgwsjba62lahfjya9yrjkp1ndxlap"))))
+    (outputs '("out"                 ; OpenType/CFF Collection (OTC), 119MiB.
+               "cn" "jp" "kr" "tw")) ; Region-specific Subset OpenType/CFF.
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+         (use-modules (guix build utils))
+         (let ((tar  (string-append (assoc-ref %build-inputs
+                                               "tar")
+                                    "/bin/tar"))
+               (PATH (string-append (assoc-ref %build-inputs
+                                               "gzip")
+                                    "/bin"))
+               (install-opentype-fonts
+                (lambda (fonts-dir out)
+                  (copy-recursively fonts-dir
+                                    (string-append (assoc-ref %outputs out)
+                                                   "/share/fonts/opentype")))))
+           (setenv "PATH" PATH)
+           (system* tar "xvf" (assoc-ref %build-inputs "source"))
+           (chdir (string-append "source-han-sans-" ,version))
+           (install-opentype-fonts "OTC" "out")
+           (install-opentype-fonts "SubsetOTF/CN" "cn")
+           (install-opentype-fonts "SubsetOTF/JP" "jp")
+           (install-opentype-fonts "SubsetOTF/KR" "kr")
+           (install-opentype-fonts "SubsetOTF/TW" "tw")))))
+    (native-inputs
+     `(("gzip" ,gzip)
+       ("tar" ,tar)))
+    (home-page "https://github.com/adobe-fonts/source-han-sans")
+    (synopsis "Pan-CJK fonts")
+    (description
+     "Source Han Sans is a sans serif Pan-CJK font family that is offered in
+seven weights: ExtraLight, Light, Normal, Regular, Medium, Bold, and Heavy.
+And in several OpenType/CFF-based deployment configurations to accommodate
+various system requirements or limitations.  As the name suggests, Pan-CJK
+fonts are intended to support the characters necessary to render or display
+text in Simplified Chinese, Traditional Chinese, Japanese, and Korean.
+")
+    (license license:asl2.0)))
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] gnu: Add font-adobe-source-han-sans.
  2015-02-28  3:23     ` 宋文武
@ 2015-02-28  9:46       ` Andreas Enge
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Enge @ 2015-02-28  9:46 UTC (permalink / raw)
  To: 宋文武; +Cc: Guix-devel

On Sat, Feb 28, 2015 at 11:23:59AM +0800, 宋文武 wrote:
> Updated patch:

Looks good from reading it (I did not try to compile), so please push!

Andreas

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-28  9:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27  6:02 [PATCH] gnu: Add font-adobe-source-han-sans 宋文武
2015-02-27 10:14 ` Andreas Enge
2015-02-27 10:16   ` Andreas Enge
2015-02-28  3:23     ` 宋文武
2015-02-28  9:46       ` Andreas Enge

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).