From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id gIw/HUHJMmMeFQAAbAwnHQ (envelope-from ) for ; Tue, 27 Sep 2022 11:58:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id sFh2HEHJMmNttAAAG6o9tA (envelope-from ) for ; Tue, 27 Sep 2022 11:58:25 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2F8E43AAE1 for ; Tue, 27 Sep 2022 11:58:25 +0200 (CEST) Received: from localhost ([::1]:60038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od7M8-0005I0-9U for larch@yhetil.org; Tue, 27 Sep 2022 05:58:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od7Js-0001jg-96 for guix-patches@gnu.org; Tue, 27 Sep 2022 05:56:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od7Jr-0007sZ-Op for guix-patches@gnu.org; Tue, 27 Sep 2022 05:56:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1od7Jq-0004tc-6w for guix-patches@gnu.org; Tue, 27 Sep 2022 05:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57963] [PATCH v3] home: fontutils: Support user's fontconfig. References: <20220921002721.23511-1-higashi@taiju.info> In-Reply-To: <20220921002721.23511-1-higashi@taiju.info> Resent-From: Taiju HIGASHI Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 27 Sep 2022 09:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57963 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: ludo@gnu.org, liliana.prikler@gmail.com, andrew@trop.in Cc: 57963@debbugs.gnu.org, Taiju HIGASHI Received: via spool by 57963-submit@debbugs.gnu.org id=B57963.166427255618801 (code B ref 57963); Tue, 27 Sep 2022 09:56:02 +0000 Received: (at 57963) by debbugs.gnu.org; 27 Sep 2022 09:55:56 +0000 Received: from localhost ([127.0.0.1]:52894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1od7Jj-0004tB-EY for submit@debbugs.gnu.org; Tue, 27 Sep 2022 05:55:55 -0400 Received: from mail-pg1-f181.google.com ([209.85.215.181]:45862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1od7Je-0004st-0z for 57963@debbugs.gnu.org; Tue, 27 Sep 2022 05:55:53 -0400 Received: by mail-pg1-f181.google.com with SMTP id r62so5109880pgr.12 for <57963@debbugs.gnu.org>; Tue, 27 Sep 2022 02:55:49 -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:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=cdWhS+Qz1yPjvOsmI4PrFoJjJb50CRiXBRa7uh833xM=; b=cboOiLfKV/b9ZiLbf/H9Wc8hnSYsb8so3anDivj5atFL4nK5nzbYHInS32ZMcSb5cZ Y2cowMVqikC/pEM4pX0qU/lyvN/XpHEpDk6z9tyJEdVBNoA9BflpnioB2zMuHaXUCweX ehzXq1MGokG5UpTGLtUSdj3ACkUpHdXy4nKrPR8/XBb/mmDtx0l3ay83tftUuhTTxWPs 9wKijQMGGIucpc0kK9ooy9FI819y2EsIk5V7owsfkOPcIF+H3KRgRgXp3YVohrQ0T/2a dPDjUjX6YW1BRzMACmQKahU58dmws6bS+WfJPfEPg1pAcZipY0/w20I8xtJXvnGy90qn ZGSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=cdWhS+Qz1yPjvOsmI4PrFoJjJb50CRiXBRa7uh833xM=; b=OoyjPciM+rcrcTKYmikzoefZ8SVy4lEsgf9CP9Q8Is0rlC0MFEQboe/Li2Twvkiu7Y hqwWs5gV9iOtAURp1fRMMxc1fKnnnhpc+QLrHMbBTrOcoYQTQECLd+gpKzuafjPA2zAk QZ018Q0Jo4Amtok5Pyvr1psvrLxzNxnV/PQu52Zn+nY/l53uHW6owJKJw2hsglKn138i omqCrPE84n1GzIIvOdEfD586iUNbVbDnJlIeqDgRhwpQ0aIvjLWywJr+e4Oh0S0Mk2/Z uEnMg3RkmClgN7IpNC5ooe8rpOd0DX+Dw++QoAXe+v30V8AtmOrUUbh88jNXcRlN+xQF xNIQ== X-Gm-Message-State: ACrzQf2aMorCO0c3vZftSG2eRdgP+3nm/HACBsUsvjKREWRrWqHrYNzF aj8UT1C8Eifdnkq+sVxRgz1Gdg== X-Google-Smtp-Source: AMsMyM5Y4nhjHtJW75fSPJzU++Zp8vXHE6UwdsbBd/HSZNnvPzEpqCCO0yMmDf4Y6H0eDubRaw0dFA== X-Received: by 2002:a62:e20f:0:b0:556:4265:5de2 with SMTP id a15-20020a62e20f000000b0055642655de2mr23896644pfi.57.1664272544140; Tue, 27 Sep 2022 02:55:44 -0700 (PDT) Received: from Taix.flets-west.jp ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id u16-20020a170902e5d000b00172f6726d8esm1067770plf.277.2022.09.27.02.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 02:55:43 -0700 (PDT) From: Taiju HIGASHI Date: Tue, 27 Sep 2022 18:55:25 +0900 Message-Id: <20220927095525.26431-1-higashi@taiju.info> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664272705; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=cdWhS+Qz1yPjvOsmI4PrFoJjJb50CRiXBRa7uh833xM=; b=aYDEZfrIi0YAQSfb+V+t+WsB4a3L7TKgwiTr/T6Dk4TT3kX7K2p6VvZdFNTMGMiQS7fday PEFAleQfUPfhR9FgGCH4BuprJCYfQzdPaHD+/kQYcuPqvuWwW04JvoC3vUnjLH1wNb+3FJ oEi5AltnNkhbVtS1wg7iBneicTb6KhYCkUYY2h+fTwC/iTXbH/3RzLEGqIwh8bmcEOKZEr xtEnCsVQkfbzcdqgvsaCMeXpVlmi6mse35WcMNA17z+0RHiXgrhH5xzMBh2m5h0LM2Hroz N/5eH505roBRUas59QNeJaBr4d3wY/MQ7sHlrBq4aEVbc6Xx8LfyHEO9HV8kgw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664272705; a=rsa-sha256; cv=none; b=bmQeE4sbz+eQcow1jO2sMhj+FPRPzv10iYbEaX3L41TZEbEEnOSySN62z3CRk/MXM5ce3B c3F9teF8cxZOrnQSP0mCR/FhiLywM56xH7WT4J3BjZrYQgiM/wiqtsJuFHRHnOueBO5ZuS dvt3LpLStyHY6wIEp4G3M0fZ/ry34r4Ya2H4UF0BJbPp61/XXndexmZjyunOEr43yM14k2 DbgH5f7yT8euF9JvtSkxK0yuJqYJUB1cSLlL9Hc+3xZ4x8rIVZq/z86gEQFylY3sSfHv06 3YzyToTbLYPlvcqQd9HN0lVrP5vQGitklVhJTWznwH8ZcoOoUZRiTdt1IKnSMQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=cboOiLfK; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.16 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=taiju-info.20210112.gappssmtp.com header.s=20210112 header.b=cboOiLfK; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 2F8E43AAE1 X-Spam-Score: 5.16 X-Migadu-Scanner: scn1.migadu.com X-TUID: 3SHdj5S+0VXa * gnu/home/services/fontutils.scm (add-fontconfig-config-file): Support user's fontconfig. --- gnu/home/services/fontutils.scm | 103 ++++++++++++++++++++++++++++++-- 1 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 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2021 Andrew Tropin ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2022 Taiju HIGASHI ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,9 +21,16 @@ (define-module (gnu home services fontutils) #:use-module (gnu home services) #:use-module (gnu packages fontutils) + #:use-module (gnu services configuration) #:use-module (guix gexp) + #:use-module (guix records) + #:use-module (srfi srfi-1) + #:use-module (sxml simple) + #:use-module (ice-9 match) - #:export (home-fontconfig-service-type)) + #:export (home-fontconfig-service-type + home-fontconfig-configuration + default-font)) ;;; Commentary: ;;; @@ -33,15 +41,96 @@ (define-module (gnu home services fontutils) ;;; ;;; Code: -(define (add-fontconfig-config-file he-symlink-path) +(define-record-type* default-font + make-default-font + default-font? + (serif default-font-serif (default "")) + (sans-serif defalut-font-sans-serif (default "")) + (monospace default-font-monospace (default ""))) + +(define (sxml->xmlstring sxml) + (if (null? sxml) + "" + (call-with-output-string + (lambda (port) + (sxml->xml sxml port) + (newline port))))) + +(define font-directories? list?) + +(define (serialize-font-directories field-name value) + (sxml->xmlstring + (append + '((dir "~/.guix-home/profile/share/fonts")) + (map + (lambda (path) + `(dir ,path)) + value)))) + +(define extra-config-list? list?) + +(define (serialize-extra-config-list field-name value) + (sxml->xmlstring + (map (match-lambda + ((? pair? sxml) sxml) + ((? string? xml) (xml->sxml xml)) + (_ (error "extra-config value must be xml string or sxml list."))) + value))) + +(define (serialize-default-font field-name value) + (match value + (($ serif sans-serif monospace) + (sxml->xmlstring + (fold (lambda (pair sxml) + (if (string-null? (cdr pair)) + sxml + (append sxml + `((alias + (family ,(car pair)) + (prefer + (family ,(cdr pair)))))))) + '() + `((serif . ,serif) + (sans-serif . ,sans-serif) + (monospace . ,monospace))))))) + +(define-configuration home-fontconfig-configuration + (font-directories + (font-directories '()) + "The directory list that provides fonts.") + (preferred-default-font + (default-font (default-font)) + "The preffered default fonts for serif, sans-serif, and monospace.") + (extra-config + (extra-config-list '()) + "Extra configuration values to append to the fonts.conf.")) + +(define (home-fontconfig-extend original-config extend-configs) + (home-fontconfig-configuration + (inherit original-config) + (font-directories + (append + (home-fontconfig-configuration-font-directories original-config) + (append-map home-fontconfig-configuration-font-directories extend-configs))) + (preferred-default-font + (home-fontconfig-configuration-preferred-default-font + (if (null? extend-configs) + original-config + (last extend-configs)))) + (extra-config + (append + (home-fontconfig-configuration-extra-config original-config) + (append-map home-fontconfig-configuration-extra-config extend-configs))))) + +(define (add-fontconfig-config-file user-config) `(("fontconfig/fonts.conf" ,(mixed-text-file "fonts.conf" " - - ~/.guix-home/profile/share/fonts -")))) +\n" + (serialize-configuration user-config home-fontconfig-configuration-fields) + "\n")))) (define (regenerate-font-cache-gexp _) `(("profile/share/fonts" @@ -49,6 +138,8 @@ (define (regenerate-font-cache-gexp _) (define home-fontconfig-service-type (service-type (name 'home-fontconfig) + (compose identity) + (extend home-fontconfig-extend) (extensions (list (service-extension home-xdg-configuration-files-service-type @@ -59,7 +150,7 @@ (define home-fontconfig-service-type (service-extension home-profile-service-type (const (list fontconfig))))) - (default-value #f) + (default-value (home-fontconfig-configuration)) (description "Provides configuration file for fontconfig and make fc-* utilities aware of font packages installed in Guix Home's profile."))) -- 2.37.3