From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id +EqHNWXFNWPYAAEAbAwnHQ (envelope-from ) for ; Thu, 29 Sep 2022 18:18:45 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id gPZENWXFNWNYYQAAauVa8A (envelope-from ) for ; Thu, 29 Sep 2022 18:18:45 +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 71EF82B783 for ; Thu, 29 Sep 2022 18:18:45 +0200 (CEST) Received: from localhost ([::1]:36682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odwFH-0006pQ-3L for larch@yhetil.org; Thu, 29 Sep 2022 12:18:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oduet-0005hR-33 for guix-patches@gnu.org; Thu, 29 Sep 2022 10:37:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40145) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odues-0006i4-QS for guix-patches@gnu.org; Thu, 29 Sep 2022 10:37:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1odues-0007GB-LJ for guix-patches@gnu.org; Thu, 29 Sep 2022 10:37:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57963] [PATCH v4 2/2] home: fontutils: Support user's fontconfig. Resent-From: Taiju HIGASHI Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Sep 2022 14:37: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: 57963@debbugs.gnu.org Cc: ludo@gnu.org, Taiju HIGASHI , liliana.prikler@gmail.com, andrew@trop.in Received: via spool by 57963-submit@debbugs.gnu.org id=B57963.166446221727886 (code B ref 57963); Thu, 29 Sep 2022 14:37:02 +0000 Received: (at 57963) by debbugs.gnu.org; 29 Sep 2022 14:36:57 +0000 Received: from localhost ([127.0.0.1]:39223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oduen-0007Fi-3T for submit@debbugs.gnu.org; Thu, 29 Sep 2022 10:36:57 -0400 Received: from mail-pl1-f176.google.com ([209.85.214.176]:40472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oduel-0007FV-Fb for 57963@debbugs.gnu.org; Thu, 29 Sep 2022 10:36:56 -0400 Received: by mail-pl1-f176.google.com with SMTP id b21so1432705plz.7 for <57963@debbugs.gnu.org>; Thu, 29 Sep 2022 07:36:55 -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:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=S13+hkdmE3qTTNNWXiPnC38faFIhIN66eXq0OnVY+dA=; b=k3b76hA4zVXUBojdFEvcgMeaql44c6diyzu4VA1KccLef9LuKyFPcVFGg55ajh3c8r z15QFDRyfifLbnBS1omUVjgDNGOj7SZ/0x7f3VgUYRKiF3G5cHeS8OTSKC+DC4+iAr/l 2VwreusaDgLk9O/G9BAjpfGrIfK2pR3XkAz3SCPTo0lHZ6IM4eDmVF6PMXrWKAKxM0/w +g+V/6t4aO70OxJaNduV2shfmgm1ZRA/XjwMp68Gk/evPqIw0p3VzjYIlIU/NJ5I6tz5 OxpDmCofyvxz2nuX9Hcj7AjT7Oa7jpWC2enziqzSJPM3F7BAitoD/iudl4TznenxN7Ym 9pdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=S13+hkdmE3qTTNNWXiPnC38faFIhIN66eXq0OnVY+dA=; b=fomsDD6q8qbhyFd6nsqDy37I2xOb6C6Z8X5cFLMfsKHcSqG6l7tEiQjHTRlVOopW6J aFh4QY6Rk4e0helkTOfhdcc+C/2sAR3/RJj9W5FeAed8Mw5RNY1/9toI5CRFlDIALkyK qgXjrsh8AMgjlVCsXMTc18SXM/f3qDZZjBmUTP9uUjS7PmZjyJeoDCF+3Mhf41/PKqc1 2avAWxd2pOnU5dCZBhP0pMD9Q3xaII5QAzHxB2MwfqqmVLxk48WGRq4zvD9MELTH0uP6 amPP4Lsyk6McyoVhxwjZVz7J7qRbAugENt7pVykUyx6e+c/4UA6iw30Z87lu+pIyS4Oc jlTQ== X-Gm-Message-State: ACrzQf076S4Cr3UfdMEXwI19aVpV68UEaP+F5D3dp6yVPoHVSYlcW5I2 xQjW2ZGbsC1E7xHTFDyBXSuwduTERK4O3ywO X-Google-Smtp-Source: AMsMyM5AgWvYdJN9Rx/Wd0v0X4spJ3xthKMyd27PxwmTl/UsBlv3OcAACB5VJFQqIAG+DDhC2kXE4Q== X-Received: by 2002:a17:902:8c81:b0:178:a33f:8b8f with SMTP id t1-20020a1709028c8100b00178a33f8b8fmr3838073plo.50.1664462209619; Thu, 29 Sep 2022 07:36:49 -0700 (PDT) Received: from Taix.flets-west.jp ([240b:253:ec40:2400:b7d1:436e:2d61:e925]) by smtp.gmail.com with ESMTPSA id y63-20020a626442000000b0053b9e5d365bsm6265154pfb.216.2022.09.29.07.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 07:36:49 -0700 (PDT) From: Taiju HIGASHI Date: Thu, 29 Sep 2022 23:36:33 +0900 Message-Id: <20220929143633.28844-2-higashi@taiju.info> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220929143633.28844-1-higashi@taiju.info> References: <20220929143633.28844-1-higashi@taiju.info> 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-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664468325; 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=S13+hkdmE3qTTNNWXiPnC38faFIhIN66eXq0OnVY+dA=; b=Gsg3n1kfN28uEJ+AePT2XyK1V29fPTR+KpfYzWPPYNoTs/9yYEpUoWBTHCGvl+dXkm5uIF lhRi2W3ennf1ktOLgMTRf6Lvmnrvaet/pNZhU4HL6crCBN8ahbq5Motzj1DhomUoBMDAec y2NJzewJeDLQSV59wkYAD+VGvH/F2bm8t3Ou3TXHDPh/toZPSO7NKm2zcY2MMEkjfl5/jG i8dSWklRdWBEzpjYmZXQzEOumrPzLs5Vgwt7boB9oxdfeVD2j2gZUiKdw1Jhugh460xCuk 6g0r6MjQLHC4BeRxDjfbQBVX1U5OOO55D5LUQsB17/IqZwrGsdc3dJVo95qYug== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664468325; a=rsa-sha256; cv=none; b=kJfOMKq+ku/wbWgj/pqFpxscozmc5UZG7KzoM/4dqcJcjeNvRQTbOwB0scXQcJ7RtXXzFy l44xARYNi2b7tuvOw8wjeSWAiMufpxA8SVeqnB8rtUmzlExwF0nV03uLpp21ePp+oUfu+x O4ra1lZuo/XezA/s0WKdKg6tw+DYVPfGO2kcrhCei8aGkMFx2/zqS7F7bN5vQIOYafjMlO oNY3mR/gVi1FO6WeTNQ5GvWeeMs6FTxUgf20ELmJmBzRl67MeWGXtbA9/PALu6wXhQ9mnj hunU82G8d5RnVkwQxPYBkh0jUXViChu+CTAnTuo/iDpfX1auLjvcNYsL3vtWHg== 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=k3b76hA4; 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=k3b76hA4; 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: 71EF82B783 X-Spam-Score: 5.16 X-Migadu-Scanner: scn1.migadu.com X-TUID: B9fQATZDB/0C * gnu/home/services/fontutils.scm: Support user's fontconfig. --- gnu/home/services/fontutils.scm | 86 ++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 6 deletions(-) diff --git a/gnu/home/services/fontutils.scm b/gnu/home/services/fontutils.scm index 6062eaed6a..32127740f6 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,81 @@ (define-module (gnu home services fontutils) ;;; ;;; Code: -(define (add-fontconfig-config-file he-symlink-path) +(define (default-font-sanitizer type) + (lambda (value) + (if (null? value) + value + `(alias + (family ,type) + (prefer + (family ,value)))))) + +(define-record-type* default-font + make-default-font + default-font? + (serif default-font-serif + (default '()) + (sanitize (default-font-sanitizer 'serif))) + (sans-serif defalut-font-sans-serif + (default '()) + (sanitize (default-font-sanitizer 'sans-serif))) + (monospace default-font-monospace + (default '()) + (sanitize (default-font-sanitizer 'monospace)))) + +(define (sxml->xmlstring sxml) + (if (null? sxml) + "" + (call-with-output-string + (lambda (port) + (sxml->xml sxml 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 (list serif sans-serif 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 (add-fontconfig-config-file user-config) `(("fontconfig/fonts.conf" ,(mixed-text-file "fonts.conf" " - - ~/.guix-home/profile/share/fonts -")))) +" + (serialize-configuration user-config home-fontconfig-configuration-fields) + "\n")))) (define (regenerate-font-cache-gexp _) `(("profile/share/fonts" @@ -59,7 +133,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