Subject: Re: [PATCH v3] home: fontutils: Support user's fontconfig.

From: Taiju HIGASHI <[email-masked]>
Date: Tue, 27 Sep 2022 19:10:34 +0900

Hi,

I just sent you the v3 patch.

I have changed only the interface of `preferred-defalut-font` slightly
from what I suggested the other day.

We configure the service as follows.

--8<---------------cut here---------------start------------->8---
  (simple-service
    'my-fontconfig-service
    home-fontconfig-service-type
    (home-fontconfig-configuration
     (font-directories
      (list "~/fonts"))
     (preferred-default-font
      (default-font
        (serif "Noto Serif CJK JP")
        (sans-serif "Noto Sans CJK JP")
        (monospace "PlemolJP Console")))
     (extra-config
      `((match (@ (target font))
          (edit (@ (mode assign)
                   (name antialias))
                (bool true)))))))
--8<---------------cut here---------------end--------------->8---

I didn't understand it properly, but `home-fontconfig-service-type` is
pre-registered as `essential-services` and needs to be extended using
`simple-service`.

> +(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))))

This is the part I am most concerned about, not sure if replacing the
preferred-default-font setting with the last setting is the proper way
to go about it.

I wanted to write a test as well, but since it was to be handled by
gexp, I could not figure out how to write a test that would validate the
gexp result using only exported methods. (I would like to write tests
for serialized functions that are private functions.)

Cheers,
-- 
Taiju