unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Fonts do not work with multiple profiles (fontconfig) and a proposed workaround
@ 2020-09-29 14:30 Todor Kondić
  2020-09-30  7:59 ` Pierre Neidhardt
  0 siblings, 1 reply; 4+ messages in thread
From: Todor Kondić @ 2020-09-29 14:30 UTC (permalink / raw)
  To: help-guix\@gnu.org

Here's my experience with guix-as-a-package-manager, fontconfig and multiple profiles.


If fonts are installed in a profile different than the default one, applications do not pick them up out of the box. I.e. icecat shows characters as squares and you cannot select a cool non standard font in your GTK Emacs.

After digging into this matter, I concluded that the culprit is the main config file situated in some-nondefault-guix-profile/etc/fonts/fonts.conf

Here's a snippet:
-------------------------
<!-- Font directory list -->

	<dir>/gnu/store/7y3lvk3xf4im8n44337mc6y0ccysvfia-font-dejavu-2.37/share/fonts</dir>
	<dir>~/.guix-profile/share/fonts</dir> <dir>/run/current-system/profile/share/fonts</dir>
	<dir prefix="xdg">fonts</dir>
	<!-- the following element will be removed in the future -->
	<dir>~/.fonts</dir>
---------------------------

Clearly, some-nondefault-guix-profile/share/fonts is not among the list of dirs that are searched for font definitions. I'd call this a bug, but maybe it's by design. Still, shouldn't guix package definitions respect the -p flag to package command?


Anyway, the workaround is the following. See this snippet of the same config file,
----------------------------
<!--
  Load local system customization file
-->
	<include ignore_missing="yes">conf.d</include>

<!-- Font cache directory list -->
-----------------------------

This means it includes the conf files in ...profile/etc/conf.d. The README file reveals that 5?-*.conf files are used for additional customisation. This makes 50-user.conf particularly interesting. And, here it is ...

-----------------------------
<include ignore_missing="yes" prefix="xdg">fontconfig/conf.d</include>
	<include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include>
	<!-- the following elements will be removed in the future -->
	<include ignore_missing="yes" deprecated="yes">~/.fonts.conf.d</include>
	<include ignore_missing="yes" deprecated="yes">~/.fonts.conf</include>
-----------------------------

Apparently , ~/.config/fontconfig/fonts.conf (xdg prefix being ~/.config) is the place to add some more config

After creating ~/.config/fontconfig/fonts.conf with the following content

-----------------------------
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
	<its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
		<its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/>
	</its:rules>

	<description>Default configuration file</description>


<!-- Font directory list -->
        <dir>~/.guix-pillars/pillar/share/fonts</dir>

</fontconfig>

------------------------------

and running fc-cache -rvf the fontconfig-aware programs were able to select fonts from the non-default guix profile.


Hope this helps (me again in six monts from now)!

T






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fonts do not work with multiple profiles (fontconfig) and a proposed workaround
  2020-09-29 14:30 Fonts do not work with multiple profiles (fontconfig) and a proposed workaround Todor Kondić
@ 2020-09-30  7:59 ` Pierre Neidhardt
  2020-09-30  8:21   ` Todor Kondić
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Neidhardt @ 2020-09-30  7:59 UTC (permalink / raw)
  To: Todor Kondić, help-guix\@gnu.org

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

Hi Todor,

Indeed, this workaround does the trick.
Here is my ~/.config/fontconfig/fonts.conf:

--8<---------------cut here---------------start------------->8---
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
<dir>~/.guix-extra-profiles/emacs/emacs/share/fonts</dir>
</fontconfig>
--8<---------------cut here---------------end--------------->8---

Packages' content is static, it is not modifier upon install, which is
why the default  etc/fonts/fonts.conf is pointing to constant locations.

The solution to this bug, I believe, would be to add a post-install
hook that generates the fonts.conf file with the right entries.

Cheers!

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fonts do not work with multiple profiles (fontconfig) and a proposed workaround
  2020-09-30  7:59 ` Pierre Neidhardt
@ 2020-09-30  8:21   ` Todor Kondić
  2020-12-17 20:41     ` Maxim Cournoyer
  0 siblings, 1 reply; 4+ messages in thread
From: Todor Kondić @ 2020-09-30  8:21 UTC (permalink / raw)
  To: help-guix\\@gnu.org

> Hi Todor,
>
> Indeed, this workaround does the trick.
> Here is my ~/.config/fontconfig/fonts.conf:
>
> --8<---------------cut here---------------start------------->8---
> <?xml version="1.0"?>
> <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
> <!-- /etc/fonts/fonts.conf file to configure system font access -->
> <fontconfig>
> <dir>~/.guix-extra-profiles/emacs/emacs/share/fonts</dir>
> </fontconfig>
> --8<---------------cut here---------------end--------------->8---
>
> Packages' content is static, it is not modifier upon install, which is
> why the default etc/fonts/fonts.conf is pointing to constant locations.
>
> The solution to this bug, I believe, would be to add a post-install
> hook that generates the fonts.conf file with the right entries.
>
> Cheers!
>
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Pierre Neidhardt
> https://ambrevar.xyz/

Hi Pierre,

Yes, of course you are right. Packages are installed once and then reused in different profiles (AFAIK). I just did not give much thought to it at the moment. Supporting multiple profiles in a package can be a real pain, right? I mean, there is no magic bullet. In the case of fontconfig, we have the ability to modify the fonts.conf in order to add more font paths. As for other programs, there is usually a way, but it is not universal.

Of course, the hammer solution would be to shove a package going into a different profile into a different store entry (under assumption that at the build-time the package takes -p option as the default). Perhaps something like that could be offered as an option to users? Maybe this is even possible now? I have not done any research on it.

On the other hand, I have not seen any real "official" endorsement of multi-profile setups by Guix as a project :) .

Cheers,

T



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fonts do not work with multiple profiles (fontconfig) and a proposed workaround
  2020-09-30  8:21   ` Todor Kondić
@ 2020-12-17 20:41     ` Maxim Cournoyer
  0 siblings, 0 replies; 4+ messages in thread
From: Maxim Cournoyer @ 2020-12-17 20:41 UTC (permalink / raw)
  To: Todor Kondić; +Cc: help-guix\@gnu.org

Hi,

Todor Kondić <tk.code@protonmail.com> writes:

>> Hi Todor,
>>
>> Indeed, this workaround does the trick.
>> Here is my ~/.config/fontconfig/fonts.conf:
>>
>> --8<---------------cut here---------------start------------->8---
>> <?xml version="1.0"?>
>> <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
>> <!-- /etc/fonts/fonts.conf file to configure system font access -->
>> <fontconfig>
>> <dir>~/.guix-extra-profiles/emacs/emacs/share/fonts</dir>
>> </fontconfig>
>> --8<---------------cut here---------------end--------------->8---
>>
>> Packages' content is static, it is not modifier upon install, which is
>> why the default etc/fonts/fonts.conf is pointing to constant locations.
>>
>> The solution to this bug, I believe, would be to add a post-install
>> hook that generates the fonts.conf file with the right entries.
>>
>> Cheers!

I think a proper fix would be contributing a patch to fontconfig so that
it honors XDG_DATA_DIRS to lookup its fonts.

Any takers?

Maxim


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-17 20:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 14:30 Fonts do not work with multiple profiles (fontconfig) and a proposed workaround Todor Kondić
2020-09-30  7:59 ` Pierre Neidhardt
2020-09-30  8:21   ` Todor Kondić
2020-12-17 20:41     ` Maxim Cournoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).