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

From: Taiju HIGASHI <[email-masked]>
Date: Thu, 22 Sep 2022 18:50:38 +0900

Hi Andrew and Ludovic,

Thanks for your input and background on the code style.

I'm not very knowledgeable about G-Expressions, so I don't understand
much of what you replied. (I will study it!).

Ludovic Courtès <[email-masked]> writes:

> Hi Andrew,
>
> Andrew Tropin <[email-masked]> skribis:
>
>> 2. We had a discussion with Ludovic about rde home services vs guix home
>> services styles.  And this one looks like rde style, not guix.
>>
>> rde takes arbitrary s-exps and g-exps with optional structure checks and
>> serializes them to target format.
>>
>> guix uses nested records with rigid nesting structure.
>
> That’s generally true, but it’s not black and white and there’s room for
> discussion.  :-)
>
> In this case, Taiju’s proposal is to let users write snippets like this:
>
>     (define font-family-map
>       '((sans-serif . "Noto Sans CJK JP")
>         (serif . "Noto Serif CJK JP")))
>
>     (home-environment
>      (packages (list font-google-noto))
>      (services
>       (list
>        (simple-service 'my-fontconfig-service
>                        home-fontconfig-service-type
>                        (list
>                         (call-with-output-string
>                           (lambda (port)
>                             (sxml->xml
>                              (map (lambda (pair)
>                                     `(alias
>                                       (family ,(car pair))
>                                       (prefer
>                                        (family ,(cdr pair)))))
>                                   font-family-map)
>                              port))))))))
>
> (With v2 they’d provide SXML instead of XML-in-a-string, so it’s
> slightly less verbose but quite similar.)
>
> In this particular case, I would find it easier to use if one could
> provide a set of <font-alias> records, let’s say along these lines:
>
>   (simple-service 'my-fontconfig-service
>                   home-fontconfig-service-type
>                   (list (font-alias 'sans-serif "Noto Sans CJK JP") …))
>
> That way, users wouldn’t need to know the details of the XML syntax for
> fontconfig.
>
> The downside is that it restricts what can be done: it lets you add font
> aliases, but nothing more.
>
> Do you have other use cases in mind, Taiju?

My motivation for writing this patch is that I wanted to continue to use
the settings in the following file after switching to Guix Home.

https://git.sr.ht/~taiju/taix/tree/31a37c231ebba60e38f7fa9cfe1c7a5d7362d021/item/dotfiles/fontconfig/.config/fontconfig/fonts.conf

Honestly, I don't know why it is so complicated, but I refered it from
the following ArchWiki content.

https://wiki.archlinux.org/title/Font_configuration/Examples#Japanese

Therefore, just being able to set font aliasing is unfortunately not
enough to satisfy my use case.

Thanks,
--
Taiju