Subject: [bug#57963] [PATCH 1/1] home: fontutils: Support user's fontconfig.

From: Liliana Marie Prikler <[email-masked]>
Date: Wed, 21 Sep 2022 10:54:34 +0200

Am Mittwoch, dem 21.09.2022 um 09:29 +0900 schrieb Taiju HIGASHI:
> * gnu/home/services/fontutils.scm (add-fontconfig-config-file):
> Support user's fontconfig.
> ---
>  gnu/home/services/fontutils.scm | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/gnu/home/services/fontutils.scm
> b/gnu/home/services/fontutils.scm
> index 6062eaed6a..3ea8b1db74 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 <[email-masked]>
>  ;;; Copyright © 2021 Xinglu Chen <[email-masked]>
> +;;; Copyright © 2022 Taiju HIGASHI <[email-masked]>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -21,6 +22,7 @@ (define-module (gnu home services fontutils)
>    #:use-module (gnu home services)
>    #:use-module (gnu packages fontutils)
>    #:use-module (guix gexp)
> +  #:use-module (srfi srfi-1)
>  
>    #:export (home-fontconfig-service-type))
>  
> @@ -33,15 +35,18 @@ (define-module (gnu home services fontutils)
>  ;;;
>  ;;; Code:
>  
> -(define (add-fontconfig-config-file he-symlink-path)
> +(define (add-fontconfig-config-file font-config)
>    `(("fontconfig/fonts.conf"
>       ,(mixed-text-file
>         "fonts.conf"
>         "<?xml version='1.0'?>
>  <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
>  <fontconfig>
> -  <dir>~/.guix-home/profile/share/fonts</dir>
> -</fontconfig>"))))
> +  <dir>~/.guix-home/profile/share/fonts</dir>\n"
> +       (if (null? font-config)
> +           ""
> +           (string-join font-config "\n" 'suffix))
> +       "</fontconfig>\n"))))
I think it'd be wiser to pretty-print SXML here.
The structure could look something like
`(fontconfig 
   (dir "~/.guix-home/profile/share/fonts")
   ,@(extra-user-config ...))

Also, for the particular use case of handling multiple profiles
gracefully (rather than the current status quo) I think fontconfig-
service-type should be able to construct (dir "#$profile/share/fonts")
style entries on its own.  However, given that multiple profiles aren't
supported yet, this is future work.

Cheers