From patchwork Thu Dec 14 14:01:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Saku Laesvuori X-Patchwork-Id: 57601 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 34D3527BBE9; Thu, 14 Dec 2023 14:03:14 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 845F727BBE2 for ; Thu, 14 Dec 2023 14:03:11 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDmIs-0001E9-U7; Thu, 14 Dec 2023 09:03:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDmIr-0001Dg-Hs for guix-patches@gnu.org; Thu, 14 Dec 2023 09:03:05 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rDmIr-0006eJ-8s; Thu, 14 Dec 2023 09:03:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rDmIo-0004cH-1h; Thu, 14 Dec 2023 09:03:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67808] [PATCH v3 1/3] gnu: Add nerd-font-patcher References: <123127b6a5bf1c94ff62b0779837a6e54975c81f.1702454367.git.saku@laesvuori.fi> In-Reply-To: <123127b6a5bf1c94ff62b0779837a6e54975c81f.1702454367.git.saku@laesvuori.fi> Resent-From: Saku Laesvuori Original-Sender: "Debbugs-submit" Resent-CC: lars@6xq.net, marius@gnu.org, me@bonfacemunyoki.com, jgart@dismail.de, guix-patches@gnu.org Resent-Date: Thu, 14 Dec 2023 14:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67808 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67808@debbugs.gnu.org Cc: Saku Laesvuori , Lars-Dominik Braun , Marius Bakke , Munyoki Kilyungi , jgart X-Debbugs-Original-Xcc: Lars-Dominik Braun , Marius Bakke , Munyoki Kilyungi , jgart Received: via spool by 67808-submit@debbugs.gnu.org id=B67808.170256252817654 (code B ref 67808); Thu, 14 Dec 2023 14:03:02 +0000 Received: (at 67808) by debbugs.gnu.org; 14 Dec 2023 14:02:08 +0000 Received: from localhost ([127.0.0.1]:49028 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDmHv-0004af-Ll for submit@debbugs.gnu.org; Thu, 14 Dec 2023 09:02:08 -0500 Received: from vmi571514.contaboserver.net ([75.119.130.101]:50752 helo=mail.laesvuori.fi) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rDmHt-0004aU-7q for 67808@debbugs.gnu.org; Thu, 14 Dec 2023 09:02:06 -0500 Received: from X-kone.org.aalto.fi (unknown [130.233.144.30]) by mail.laesvuori.fi (Postfix) with ESMTPSA id DBACF343635; Thu, 14 Dec 2023 15:02:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=laesvuori.fi; s=mail; t=1702562530; bh=ggb90R0vV2ypGbqjwJBrj6hD1vSsKUxXB0W4c6wZ2Cw=; h=From:To:Cc:Subject:Date; b=Mkd+8VOxgysuCB5+MWWCh2eyf9ZgpacjgNylm+gNUr8hS6MeMRIefQo34YMnhN6Hp K5tgzxT1ewnNLz8Iu2rwTOox4MN7hhYWkJ/j6l+G9Nv3+UsFtP1opeKQ99fND/5mL2 KDKPsJ73DsBd8lAIRMDUHUq+ut4QH6qBgoZRwdDk= Date: Thu, 14 Dec 2023 16:01:12 +0200 Message-ID: <173b07571f7417cc23d53e9557e7ce2871075346.1702561323.git.saku@laesvuori.fi> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Saku Laesvuori X-ACL-Warn: , Saku Laesvuori via Guix-patches X-Patchwork-Original-From: Saku Laesvuori via Guix-patches via From: Saku Laesvuori Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/python-xyz.scm (nerd-font-patcher): New variable. * gnu/packages/patches/nerd-font-patcher-convert-to-python-package.patch: New file Change-Id: I5f0b99b5120dfa8835727f4ea9f01c235962eed9 --- ...nt-patcher-convert-to-python-package.patch | 85 +++++++++++++++++++ gnu/packages/python-xyz.scm | 47 ++++++++++ 2 files changed, 132 insertions(+) create mode 100644 gnu/packages/patches/nerd-font-patcher-convert-to-python-package.patch base-commit: 4bf4e340b74b66a0fc319aeb100fb1f948a67211 diff --git a/gnu/packages/patches/nerd-font-patcher-convert-to-python-package.patch b/gnu/packages/patches/nerd-font-patcher-convert-to-python-package.patch new file mode 100644 index 0000000000..400c608f88 --- /dev/null +++ b/gnu/packages/patches/nerd-font-patcher-convert-to-python-package.patch @@ -0,0 +1,85 @@ +This patch + +* Creates a pyproject.toml file +* Changes paths to be more sensible. + +It requires extra work in a snippet to work properly, because moving the +files in a patch would effectively duplicate all the code. + + font-patcher | 13 ++++--------- + bin/scripts/name_parser/FontnameParser.py | 2 +- + pyproject.toml | 13 +++++++++++++ + 3 files changed, 18 insertions(+), 10 deletions(-) + create mode 100644 pyproject.toml + +diff --git a/font-patcher b/font-patcher +index 4cbf46c..89ae402 100755 +--- a/font-patcher ++++ b/font-patcher +@@ -38,13 +38,9 @@ except ImportError: + ) + ) + +-sys.path.insert(0, os.path.abspath(os.path.dirname(sys.argv[0])) + '/bin/scripts/name_parser/') +-try: +- from FontnameParser import FontnameParser +- from FontnameTools import FontnameTools +- FontnameParserOK = True +-except ImportError: +- FontnameParserOK = False ++from nerd_font_patcher.name_parser.FontnameParser import FontnameParser ++from nerd_font_patcher.name_parser.FontnameTools import FontnameTools ++FontnameParserOK = True + + class TableHEADWriter: + """ Access to the HEAD table without external dependencies """ +@@ -1897,7 +1893,7 @@ def setup_arguments(): + expert_group.add_argument('--custom', dest='custom', default=False, type=str, help='Specify a custom symbol font, all glyphs will be copied; absolute path suggested') + + expert_group.add_argument('--dry', dest='dry_run', default=False, action='store_true', help='Do neither patch nor store the font, to check naming') +- expert_group.add_argument('--glyphdir', dest='glyphdir', default=__dir__ + "/src/glyphs/", type=str, help='Path to glyphs to be used for patching') ++ expert_group.add_argument('--glyphdir', dest='glyphdir', default=__dir__ + "/share/fonts/nerd-font-glyphs", type=str, help='Path to glyphs to be used for patching') + expert_group.add_argument('--has-no-italic', dest='noitalic', default=False, action='store_true', help='Font family does not have Italic (but Oblique), to help create correct RIBBI set') + expert_group.add_argument('-l', '--adjust-line-height', dest='adjustLineHeight', default=False, action='store_true', help='Whether to adjust line heights (attempt to center powerline separators more evenly)') + expert_group.add_argument('--metrics', dest='metrics', default=None, choices=get_metrics_names(), help='Select vertical metrics source (for problematic cases)') +@@ -2068,5 +2064,4 @@ def main(): + + + if __name__ == "__main__": +- __dir__ = os.path.dirname(os.path.abspath(__file__)) + main() +diff --git a/bin/scripts/name_parser/FontnameParser.py b/bin/scripts/name_parser/FontnameParser.py +index 5768c42..1d95fdc 100644 +--- a/bin/scripts/name_parser/FontnameParser.py ++++ b/bin/scripts/name_parser/FontnameParser.py +@@ -2,7 +2,7 @@ + # coding=utf8 + + import re +-from FontnameTools import FontnameTools ++from nerd_font_patcher.name_parser.FontnameTools import FontnameTools + + class FontnameParser: + """Parse a font name and generate all kinds of names""" +diff --git a/pyproject.toml b/pyproject.toml +new file mode 100644 +index 0000000..e039e68 +--- /dev/null ++++ b/pyproject.toml +@@ -0,0 +1,13 @@ ++[build-system] ++requires = ["setuptools"] ++build-backend = "setuptools.build_meta" ++ ++[project] ++name = "font_patcher" ++version = "3.1.1" ++ ++[project.scripts] ++font-patcher = "nerd_font_patcher:main" ++ ++[tool.setuptools] ++packages = ["nerd_font_patcher", "nerd_font_patcher.name_parser"] +-- +2.41.0 + diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index 86f8d81689..320fd4cb69 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -146,6 +146,7 @@ ;;; Copyright © 2023 Janneke Nieuwenhuizen ;;; Copyright © 2023 Attila Lendvai ;;; Copyright © 2023 Troy Figiel +;;; Copyright © 2023 Saku Laesvuori ;;; ;;; This file is part of GNU Guix. ;;; @@ -13611,6 +13612,52 @@ (define-public python-fonttools python-zopfli)) (properties (alist-delete 'hidden? (package-properties base)))))) +(define-public nerd-font-patcher + (package + (name "nerd-font-patcher") + (version "3.1.1") + (source + (origin + (method url-fetch/zipbomb) + (uri + (string-append + "https://github.com/ryanoasis/nerd-fonts/releases/download/v" + version "/FontPatcher.zip")) + (sha256 + (base32 "1wp41ljxa5sjgxhw97cm06icw9n03nmpygr3j9qq3zs5wsxvs4bv")) + (snippet #~(begin + (rename-file "bin/scripts" "nerd_font_patcher") + (rename-file "font-patcher" "nerd_font_patcher/__init__.py"))) + (patches + (search-patches "nerd-font-patcher-convert-to-python-package.patch")))) + (build-system pyproject-build-system) + (arguments + (list + #:tests? #f ;no tests available + #:phases + #~(modify-phases %standard-phases + (add-before 'build 'patch-__dir__ + (lambda _ + (substitute* "nerd_font_patcher/__init__.py" + (("__dir__") + (string-append "\"" #$output "\"\n"))))) + (add-after 'install 'install-glyphs + (lambda _ + (let ((font-directory (string-append #$output "/share/fonts"))) + (mkdir-p font-directory) + (copy-recursively "src/glyphs" (string-append font-directory "/nerd-font-glyphs")))))))) + (inputs (list python fontforge)) + (native-inputs (list python-setuptools)) + (home-page "https://github.com/ryanoasis/nerd-fonts/#option-9-patch-your-own-font") + (synopsis "Script for adding Nerd Fonts glyphs into fonts") + (description "This package provides a python script that can be used to add the +Nerd Fonts glyphs to any font file.") + (license (list license:asl2.0 + license:cc-by4.0 + license:expat + license:silofl1.1 + license:unlicense)))) + (define-public python-ly (package (name "python-ly")