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

From: Taiju HIGASHI <[email-masked]>
Date: Thu, 20 Oct 2022 12:44:33 +0900

Declan Tsien <[email-masked]> writes:

> Taiju HIGASHI <[email-masked]> writes:
>
>>
>> By the way, should we be able to specify the binding attribute as well?
>>
>
> I checked the fontconfig doc.
> https://www.freedesktop.org/software/fontconfig/fontconfig-user.html
> Here is the relevant portation:
>
>> There is one special case to this rule; family names are split into
>> two bindings; strong and weak. Strong family names are given greater
>> precedence in the match than lang elements while weak family names are
>> given lower precedence than lang elements. This permits the document
>> language to drive font selection when any document specified font is
>> unavailable.
>
> I guess it's ok to ignore or set a default =strong= when serializing?
>

If you put the setting below,

--8<---------------cut here---------------start------------->8---
(home-fontconfig-configuration
  (default-font-serif-family "Noto Serif CJK JP")
  (default-font-sans-serif-family "Noto Sans Serif CJK JP")
  (default-font-monospace-family "PlemolJP Console"))
--8<---------------cut here---------------end--------------->8---

The current implementation serializes below.

--8<---------------cut here---------------start------------->8---
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <dir>~/.guix-home/profile/share/fonts</dir>
  <alias>
    <family>serif</family>
    <prefer>
      <family>Noto Serif CJK JP</family>
    </prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Noto Sans Serif CJK JP</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>PlemolJP Console</family>
    </prefer>
  </alias>
</fontconfig>
--8<---------------cut here---------------end--------------->8---

Since the binding attribute is omitted, it would be interpreted as the
default weak.
ref: https://github.com/behdad/fontconfig/blob/5b41ded2b0ddb98a07ac86264b94403cb7a0fd82/fonts.dtd#L127-L128

I would like the default-font-* fields to cover only typical settings.
Instead, we provide extra-config field to be used for settings that are
not typical.

You can also configure the settings you want by specifying them in
extra-config.

--8<---------------cut here---------------start------------->8---
(home-fontconfig-configuration
 (extra-config
  '((alias (@ (binding "strong"))
	   (family "sans-serif")
	   (prefer
	    (family "WenQuanYi Micro Hei")
	    (family "Noto Sans")))
    (alias (@ (binding "strong"))
	   (family "monospace")
	   (prefer
	    (family "Sarasa Mono CL")
	    (family "Inconsolata")
	    (family "Noto Mono"))))))
--8<---------------cut here---------------end--------------->8---

I don't see clearly what the typical configuration of alias should be,
but I believe the current specification is sufficient for our needs.

Do you still think it is preferable to change the default-font-* field
interface, even knowing that you can configure it in the extra-config
field?  Please give me your frank opinion :)

Thanks,
-- 
Taiju