From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 28 20:31:22 2022 Received: (at 57963) by debbugs.gnu.org; 29 Sep 2022 00:31:22 +0000 Received: from localhost ([127.0.0.1]:35272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odhST-0001cz-Ax for submit@debbugs.gnu.org; Wed, 28 Sep 2022 20:31:21 -0400 Received: from mail-pl1-f180.google.com ([209.85.214.180]:45917) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odhSR-0001cg-5w for 57963@debbugs.gnu.org; Wed, 28 Sep 2022 20:31:19 -0400 Received: by mail-pl1-f180.google.com with SMTP id w20so13057092ply.12 for <57963@debbugs.gnu.org>; Wed, 28 Sep 2022 17:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=taiju-info.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date; bh=1qiSRL14IGgDIO3d7G+gdNNoZBFryycjEeoedNrmwS0=; b=pDpwtZk/wNimSwWYyelybYxEGDVeopf5EdruotqI8jl9+Y6N7l0mswRywo22es8MQa A2AuqvF7J2SCx880NyiW5NrZubnm6GI1R86Vwk728lmn0nOYfAdjCAuDK2Pwhsc5auGG HBJLPXNkJhRmXiorbu6oNRU7GQdlU5mpQy5+n2D1HMqXITgO7M4KIwuFbFmhYB3ssh4i 8H9jQUmXOQ6BHjhgX186ffHc+v6piWn8AOU1id5gJt5BEtBuQ5e1JFFDVc6e5I0UpM/a 9CNodpyitQvMwSEvbigX1t2X6YiBgDuUu2A43/VuR91H+IMIvTBub9I1R4w9izgOVS/4 q4Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date; bh=1qiSRL14IGgDIO3d7G+gdNNoZBFryycjEeoedNrmwS0=; b=VuClz1dq61Rr9oLgRvuP4m1o6k7ENSjoPh3hDEIw779kJwTJxF4Zt79K4oaiz15m1S u1HRK4hN3pBARQGcG1hTWtrClCj5ZzVbrYJb/3sGbQsUqIDZfEGnDm36UE/PlM6jJWg+ 32DWzRcAybUMtNI1k9ft9rnuPP0GYq91fdQYFms78MHw1fXWPlIGu+iU+YsVs/0k7BXN Fr/STghBSPbTHPI40xEU9kJbPP0DktfvykWxaXrYGtga4svyH6caeovKfj+7jN3tfCL/ 6vDwSIE/5LUYOhW0S9/Xw3DjdJEB7EtVzhx8bVoBlRotI6V6Ult7L9+9YEZYSUdetfbN X7cg== X-Gm-Message-State: ACrzQf2ITAfxDjvxVLd+AA0A7u1yefptQErGBug6BvlBu04+w5BBOrZK UWuOARWb+cM8S/usSiThKrqS+7nvBecxF42R X-Google-Smtp-Source: AMsMyM7uAtEPEPkQBNOZYw7iVlbR4cJbSm7Yz0dgTIEcxBPOMvEdmZ1Htd7DlO3p2G4uaHF/gwC7fQ== X-Received: by 2002:a17:903:442:b0:17a:ac:1b75 with SMTP id iw2-20020a170903044200b0017a00ac1b75mr632173plb.5.1664411473025; Wed, 28 Sep 2022 17:31:13 -0700 (PDT) Received: from Taix ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id y16-20020aa78f30000000b00540a3252191sm4698288pfr.28.2022.09.28.17.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 17:31:12 -0700 (PDT) From: Taiju HIGASHI To: Liliana Marie Prikler Subject: Re: [PATCH v3] home: fontutils: Support user's fontconfig. References: <20220927095525.26431-1-higashi@taiju.info> <2add7a8c83272c5bcb9aac38e63161a48f321cda.camel@gmail.com> Date: Thu, 29 Sep 2022 09:31:09 +0900 In-Reply-To: <2add7a8c83272c5bcb9aac38e63161a48f321cda.camel@gmail.com> (Liliana Marie Prikler's message of "Wed, 28 Sep 2022 21:11:30 +0200") Message-ID: <87tu4rowc2.fsf@taiju.info> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Liliana Marie Prikler writes: > Am Dienstag, dem 27.09.2022 um 18:55 +0900 schrieb Taiju HIGASHI: >> * gnu/home/services/fontutils.scm (add-fontconfig-config-file): >> Support user's >> fontconfig. >> --- >> �gnu/home/services/fon [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.214.180 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.214.180 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Debbugs-Envelope-To: 57963 Cc: ludo@gnu.org, 57963@debbugs.gnu.org, andrew@trop.in X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) Liliana Marie Prikler writes: > Am Dienstag, dem 27.09.2022 um 18:55 +0900 schrieb Taiju HIGASHI: >> * gnu/home/services/fontutils.scm (add-fontconfig-config-file): >> Support user's >> fontconfig. >> --- >> =A0gnu/home/services/fontutils.scm | 103 >> ++++++++++++++++++++++++++++++-- >> =A01 file changed, 97 insertions(+), 6 deletions(-) >> >> diff --git a/gnu/home/services/fontutils.scm >> b/gnu/home/services/fontutils.scm >> index 6062eaed6a..b02f43a4fc 100644 >> --- a/gnu/home/services/fontutils.scm >> +++ b/gnu/home/services/fontutils.scm >> @@ -1,6 +1,7 @@ >> =A0;;; GNU Guix --- Functional package management for GNU >> =A0;;; Copyright =A9 2021 Andrew Tropin >> =A0;;; Copyright =A9 2021 Xinglu Chen >> +;;; Copyright =A9 2022 Taiju HIGASHI >> =A0;;; >> =A0;;; This file is part of GNU Guix. >> =A0;;; >> @@ -20,9 +21,16 @@ >> =A0(define-module (gnu home services fontutils) >> =A0=A0 #:use-module (gnu home services) >> =A0=A0 #:use-module (gnu packages fontutils) >> +=A0 #:use-module (gnu services configuration) >> =A0=A0 #:use-module (guix gexp) >> +=A0 #:use-module (guix records) >> +=A0 #:use-module (srfi srfi-1) >> +=A0 #:use-module (sxml simple) >> +=A0 #:use-module (ice-9 match) >> >> -=A0 #:export (home-fontconfig-service-type)) >> +=A0 #:export (home-fontconfig-service-type >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 home-fontconfig-configuration >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 default-font)) >> >> =A0;;; Commentary: >> =A0;;; >> @@ -33,15 +41,96 @@ (define-module (gnu home services fontutils) >> =A0;;; >> =A0;;; Code: >> >> -(define (add-fontconfig-config-file he-symlink-path) >> +(define-record-type* default-font >> +=A0 make-default-font >> +=A0 default-font? >> +=A0 (serif default-font-serif (default "")) >> +=A0 (sans-serif defalut-font-sans-serif (default "")) >> +=A0 (monospace default-font-monospace (default ""))) > Is the empty string a meaningful value in these places? Sure, It is not meaningful. I would remove the default value. >> +(define (sxml->xmlstring sxml) >> +=A0 (if (null? sxml) >> +=A0=A0=A0=A0=A0 "" >> +=A0=A0=A0=A0=A0 (call-with-output-string >> +=A0=A0=A0=A0=A0=A0=A0 (lambda (port) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 (sxml->xml sxml port) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 (newline port))))) >> + >> +(define font-directories? list?) >> + >> +(define (serialize-font-directories field-name value) >> +=A0 (sxml->xmlstring >> +=A0=A0 (append >> +=A0=A0=A0=A0=A0=A0 '((dir "~/.guix-home/profile/share/fonts")) >> +=A0=A0=A0=A0=A0=A0 (map >> +=A0=A0=A0=A0=A0=A0=A0 (lambda (path) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 `(dir ,path)) >> +=A0=A0=A0=A0=A0=A0=A0 value)))) >> + >> +(define extra-config-list? list?) >> + >> +(define (serialize-extra-config-list field-name value) >> +=A0 (sxml->xmlstring >> +=A0=A0 (map (match-lambda >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 ((? pair? sxml) sxml) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 ((? string? xml) (xml->sxml xml)) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0 (_ (error "extra-config value must be xml s= tring or sxml >> list."))) >> +=A0=A0=A0=A0=A0=A0=A0 value))) >> + >> +(define (serialize-default-font field-name value) >> +=A0 (match value >> +=A0=A0=A0 (($ serif sans-serif monospace) >> +=A0=A0=A0=A0 (sxml->xmlstring >> +=A0=A0=A0=A0=A0 (fold (lambda (pair sxml) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (if (string-null? (cdr pair)) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 sxml >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (append sxml >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 `((alias >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 (family ,(car pair)) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 (prefer >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 (family ,(cdr pair)))))))) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 '() >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 `((serif . ,serif) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (sans-serif . ,sans-serif) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (monospace . ,monospace))))))) > You can greatly simplify these by serializing the fields to SXML and > only taking the final SXML and serializing it to a string. I see. We can define sanitizer for fields, right? >> +(define-configuration home-fontconfig-configuration >> +=A0 (font-directories >> +=A0=A0 (font-directories '()) >> +=A0=A0 "The directory list that provides fonts.") >> +=A0 (preferred-default-font >> +=A0=A0 (default-font (default-font)) >> +=A0=A0 "The preffered default fonts for serif, sans-serif, and >> monospace.") >> +=A0 (extra-config >> +=A0=A0 (extra-config-list '()) >> +=A0=A0 "Extra configuration values to append to the fonts.conf.")) >> + >> +(define (home-fontconfig-extend original-config extend-configs) >> +=A0 (home-fontconfig-configuration >> +=A0=A0 (inherit original-config) >> +=A0=A0 (font-directories >> +=A0=A0=A0 (append >> +=A0=A0=A0=A0=A0=A0=A0 (home-fontconfig-configuration-font-directories o= riginal- >> config) >> +=A0=A0=A0=A0=A0=A0=A0 (append-map home-fontconfig-configuration-font-di= rectories >> extend-configs))) >> +=A0=A0 (preferred-default-font >> +=A0=A0=A0 (home-fontconfig-configuration-preferred-default-font >> +=A0=A0=A0=A0 (if (null? extend-configs) >> +=A0=A0=A0=A0=A0=A0=A0=A0 original-config >> +=A0=A0=A0=A0=A0=A0=A0=A0 (last extend-configs)))) >> +=A0=A0 (extra-config >> +=A0=A0=A0 (append >> +=A0=A0=A0=A0=A0=A0=A0 (home-fontconfig-configuration-extra-config origi= nal-config) >> +=A0=A0=A0=A0=A0=A0=A0 (append-map home-fontconfig-configuration-extra-c= onfig >> extend-configs))))) >> + >> +(define (add-fontconfig-config-file user-config) >> =A0=A0 `(("fontconfig/fonts.conf" >> =A0=A0=A0=A0=A0 ,(mixed-text-file >> =A0=A0=A0=A0=A0=A0=A0 "fonts.conf" >> =A0=A0=A0=A0=A0=A0=A0 " >> =A0 >> - >> -=A0 ~/.guix-home/profile/share/fonts >> -")))) >> +\n" >> +=A0=A0=A0=A0=A0=A0 (serialize-configuration user-config home-fontconfig- >> configuration-fields) >> +=A0=A0=A0=A0=A0=A0 "\n")))) > Is it expected that our configuration will be pretty? If so, you might > want to use a tree fold (there sadly doesn't seem to be a built-in XML > pretty printer, which is a shame imho.) > > If not, those extra newlines do little. OK, I would remove extra newlines. >> =A0(define (regenerate-font-cache-gexp _) >> =A0=A0 `(("profile/share/fonts" >> @@ -49,6 +138,8 @@ (define (regenerate-font-cache-gexp _) >> >> =A0(define home-fontconfig-service-type >> =A0=A0 (service-type (name 'home-fontconfig) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (compose identity) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (extend home-fontconfig-e= xtend) >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (extensions >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (list (service-exten= sion >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= home-xdg-configuration-files-service-type >> @@ -59,7 +150,7 @@ (define home-fontconfig-service-type >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (s= ervice-extension >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= home-profile-service-type >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= (const (list fontconfig))))) >> -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (default-value #f) >> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (default-value (home-font= config-configuration)) >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (description >> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 "Provides configurat= ion file for fontconfig and >> make >> =A0fc-* utilities aware of font packages installed in Guix Home's >> profile."))) > > Cheers > Cheers, -- Taiju