Subject: [bug#57963] [PATCH v5 2/2] home: services: Support user's fontconfig configuration.

From: Taiju HIGASHI <[email-masked]>
Date: Wed, 02 Nov 2022 10:43:21 +0900

Hi,

Liliana Marie Prikler <[email-masked]> writes:

> Am Donnerstag, dem 27.10.2022 um 14:31 +0900 schrieb Taiju HIGASHI:
>> Liliana Marie Prikler <[email-masked]> writes:
>>
>> > Am Donnerstag, dem 27.10.2022 um 13:00 +0900 schrieb Taiju HIGASHI:
>> > > Sorry for the long time it has taken to resolve the issue.
>> > > What do you think about it?
>> > Putting the discussion with Declan aside, the last thing mentioned
>> > was
>> > not trying to mix SXML and XML-in-strings.  Ludo offered the
>> > solutions:
>> > 1. Taking a <fontconfig-configuration> or a file-like object
>> > 2. (Optionally) using a gexp-compiler for the former
>> >
>> > Cheers
>>
>> Sorry for the lack of clarity.
>> I had sent you a past email confirming that the direction of the
>> implementation was correct and was waiting for your response.
>>
>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57963#239
> Ahh, I missed that.  If you pull in the XML declarations and the
> <fontconfig></fontconfig> stuff to the serialization, you should
> basically have most of what you'd need for a G-Exp compiler, but even
> if not it'd simplify this to
>
> (match
>   ((? home-font-config-configuration? config)
>    (serialize-... config ...))
>   ((? file-like? config) config))
>
> Not sure if a match for type-checking would be needed since it's
> already taken care of elsewhere, so writing it just in case.
>
> Cheers

Sorry for my response delay.
Is my recognition correct?  I have plan to rewrite it as below.

--8<---------------cut here---------------start------------->8---
(define (serialize-fontconfig-configuration config)
  (define start-of-fontconfig "<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>")

  (define end-of-fontconfig "</fontconfig>\n")

  (mixed-text-file
   "fonts.conf"
   start-of-fontconfig
   (serialize-configuration config home-fontconfig-configuration-fields)
   end-of-fontconfig))

(define (add-fontconfig-config-file user-config)
  `(("fontconfig/fonts.conf"
     ,(match user-config
          ((? home-fontconfig-configuration? user-config)
           (serialize-fontconfig-configuration user-config))
        ((? file-like? user-config) user-config)))))
--8<---------------cut here---------------end--------------->8---

Thanks,
-- 
Taiju