unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Hilton Chain via Guix-patches via <guix-patches@gnu.org>
To: 69424@debbugs.gnu.org
Cc: "Hilton Chain" <hako@ultrarare.space>,
	"Jiwei YANG" <yangjiwei@protonmail.com>,
	"Zhu Zihao" <all_but_last@163.com>, 宋文武 <iyzsong@envs.net>
Subject: [bug#69424] [PATCH v3 2/5] gnu: font-google-noto: Prefer variable fonts and split outputs.
Date: Wed, 28 Feb 2024 21:32:19 +0800	[thread overview]
Message-ID: <5eada4da5298fdaba9d6a05b411161637b3a42a4.1709126510.git.hako@ultrarare.space> (raw)
In-Reply-To: <cover.1709126509.git.hako@ultrarare.space>

* gnu/packages/fonts.scm (font-google-noto)[outputs]: Add "ttf".
[arguments]<#:phase>: Move hinted TTFs into it.
Prefer variable fonts.

Suggested-by: Jiwei YANG <yangjiwei@protonmail.com>
Change-Id: Icac2927fb6c35d08504c379e273a5fc03b08ac46
---
 gnu/packages/fonts.scm | 45 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 72bf0124c4..4f9400047f 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -1092,6 +1092,51 @@ (define-public font-google-noto
        (sha256
         (base32 "087jg8ahpq35xwyrmvm9ivxl0wjic2j4r28bbrwqmgdva9brms40"))))
     (build-system font-build-system)
+    (arguments
+     (list
+      #:modules
+      '((guix build font-build-system)
+        (guix build utils)
+        (ice-9 ftw))
+      #:phases
+      #~(modify-phases %standard-phases
+          (replace 'install
+            (lambda _
+              (define* (install source #:optional (output #$output))
+                (let ((%install (assoc-ref %standard-phases 'install)))
+                  (with-directory-excursion source
+                    (%install #:outputs `(("out" . ,output))))))
+
+              (define (scan-directory name)
+                (scandir name (lambda (file)
+                                (not (member file '("." ".." "LICENSE"))))))
+
+              (define (install-font-variant variant)
+                "Given font variant VARIANT, install one of its formats,
+variable TTF or OTF or TTF."
+                (with-directory-excursion variant
+                  (let ((formats (scan-directory ".")))
+                    (cond
+                     ((member "variable-ttf" formats)
+                      (install "variable-ttf"))
+                     ((member "otf" formats)
+                      (install "otf"))
+                     ((member "ttf" formats)
+                      (install "ttf"))))))
+
+              (define (install-font font)
+                "Given FONT, install one of its variants, either full or
+unhinted, and install its hinted variant into 'ttf' output.  According to the
+source, unhinted and hinted variants are always available."
+                (with-directory-excursion font
+                  (if (member "full" (scan-directory "."))
+                      (install-font-variant "full")
+                      (install-font-variant "unhinted"))
+                  (install "hinted" #$output:ttf)))
+
+              (with-directory-excursion "fonts"
+                (for-each install-font (scan-directory "."))))))))
+    (outputs '("out" "ttf"))
     (home-page "https://www.google.com/get/noto/")
     (synopsis "Fonts to cover all languages")
     (description "Google Noto Fonts is a family of fonts designed to support
-- 
2.41.0





  parent reply	other threads:[~2024-02-28 13:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 12:49 [bug#69424] [PATCH 0/5] Update Noto fonts and switch them to variable fonts (77% size reduced) Hilton Chain via Guix-patches via
2024-02-27 12:54 ` [bug#69424] [PATCH 1/5] gnu: font-google-noto: Update to 24.2.1 Hilton Chain via Guix-patches via
2024-02-27 12:54 ` [bug#69424] [PATCH 2/5] gnu: font-google-noto: Keep only variable fonts when available Hilton Chain via Guix-patches via
2024-02-27 12:54 ` [bug#69424] [PATCH 3/5] gnu: font-google-noto-emoji: Update to 2.042 Hilton Chain via Guix-patches via
2024-02-27 12:54 ` [bug#69424] [PATCH 4/5] gnu: font-google-noto-sans-cjk: Switch to variable fonts Hilton Chain via Guix-patches via
2024-02-27 12:54 ` [bug#69424] [PATCH 5/5] gnu: font-google-noto-serif-cjk: Update to 2.002 Hilton Chain via Guix-patches via
2024-02-28  3:08 ` [bug#69424] [PATCH v2 0/5] Update Noto fonts and switch them to variable fonts (77% size reduced) Hilton Chain via Guix-patches via
2024-02-28  3:08 ` [bug#69424] [PATCH v2 1/5] gnu: font-google-noto: Update to 24.2.1 Hilton Chain via Guix-patches via
2024-02-28  3:08 ` [bug#69424] [PATCH v2 2/5] gnu: font-google-noto: Prefer variable fonts and split outputs Hilton Chain via Guix-patches via
2024-02-28  3:08 ` [bug#69424] [PATCH v2 3/5] gnu: font-google-noto-emoji: Update to 2.042 Hilton Chain via Guix-patches via
2024-02-28  3:08 ` [bug#69424] [PATCH v2 4/5] gnu: font-google-noto-sans-cjk: Switch to variable fonts Hilton Chain via Guix-patches via
2024-02-28  3:08 ` [bug#69424] [PATCH v2 5/5] gnu: font-google-noto-serif-cjk: Update to 2.002 Hilton Chain via Guix-patches via
2024-02-28 12:19 ` [bug#69424] (No Subject) Jiwei YANG via Guix-patches via
2024-02-29  5:16   ` Hilton Chain via Guix-patches via
2024-02-28 13:31 ` [bug#69424] [PATCH v3 0/5] Update Noto fonts and switch them to variable fonts (77% size reduced) Hilton Chain via Guix-patches via
2024-02-28 13:32   ` [bug#69424] [PATCH v3 1/5] gnu: font-google-noto: Update to 24.2.1 Hilton Chain via Guix-patches via
2024-02-28 13:32   ` Hilton Chain via Guix-patches via [this message]
2024-02-28 13:32   ` [bug#69424] [PATCH v3 3/5] gnu: font-google-noto-emoji: Update to 2.042 Hilton Chain via Guix-patches via
2024-02-28 13:32   ` [bug#69424] [PATCH v3 4/5] gnu: font-google-noto-sans-cjk: Switch to variable fonts Hilton Chain via Guix-patches via
2024-02-28 13:32   ` [bug#69424] [PATCH v3 5/5] gnu: font-google-noto-serif-cjk: Update to 2.002 Hilton Chain via Guix-patches via
2024-03-17  1:09 ` bug#69424: [PATCH 0/5] Update Noto fonts and switch them to variable fonts (77% size reduced) Hilton Chain via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5eada4da5298fdaba9d6a05b411161637b3a42a4.1709126510.git.hako@ultrarare.space \
    --to=guix-patches@gnu.org \
    --cc=69424@debbugs.gnu.org \
    --cc=all_but_last@163.com \
    --cc=hako@ultrarare.space \
    --cc=iyzsong@envs.net \
    --cc=yangjiwei@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).