unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Making the core fonts work
@ 2020-02-14  6:44 Ivan Kozlov
  2020-02-14  8:58 ` Pierre Neidhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Kozlov @ 2020-02-14  6:44 UTC (permalink / raw)
  To: guix-devel

Hello.

You should know that it is currently non-trivial to make the X.org server use fonts from a profile. You basically have to manually sift through the font files and find their ‘dirname’. The ‘fonts-dir’ union directories that Guix generates and installs into profiles have been useless since forever and in fact only get in the way; this is because the X.org server will not follow symbolic links to font files.

I was reading the Xserver(1) man page and noticed that it supports ‘font catalogue’ directories. They should contain symbolic links to actual font directories that will be added to the font path. This should allow a very nice solution.

Something like this:

(define (fontpath-file manifest)
  (define build
    #~(begin
        (use-modules (srfi srfi-1) (srfi srfi-26) (guix build utils))
        (let* ((top-font-dirs (filter file-exists?
                                      (map (cut string-append <>
                                                "/share/fonts")
                                           '#$(manifest-inputs manifest))))
               (font-dirs (append-map (lambda (dir)
                                        (find-files dir
                                                    (lambda (file stat)
                                                      (and (eq? 'directory (stat:type stat))
                                                           (file-exists? (string-append file "/fonts.dir"))))
                                                    #:directories? #t)) top-font-dirs)))
          (mkdir #$output)
          (chdir #$output)
          (if (null? font-dirs)
              (exit #t)
              (for-each (lambda (dir pri)
                          (symlink dir (string-append (basename dir) ":pri=" pri)))
                        font-dirs
                        (map number->string (iota (length font-dirs) 1)))))))
  (gexp->derivation "fontpath.d" build
                    #:modules '((guix build utils)
                                (srfi srfi-1)
                                (srfi srfi-26))
                    #:local-build? #t
                    #:substitutable? #f
                    #:properties
                    `((type . profile-hook)
                      (hook . fontpath-dir))))

This should be installed somewhere in the profile. Then you set the font path to "catalogue:$HOME/.guix-profile/share/fontpath.d" and everything works like a charm.

I am unqualified to make the actual patch that would add this functionality into Guix.

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

* Re: Making the core fonts work
  2020-02-14  6:44 Making the core fonts work Ivan Kozlov
@ 2020-02-14  8:58 ` Pierre Neidhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre Neidhardt @ 2020-02-14  8:58 UTC (permalink / raw)
  To: Ivan Kozlov, guix-devel

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

Thanks for sharing!

We recently had a discussion about this in bug 38498.
Your insight may prove useful to fix it for good! :)

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

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

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

end of thread, other threads:[~2020-02-14  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14  6:44 Making the core fonts work Ivan Kozlov
2020-02-14  8:58 ` Pierre Neidhardt

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).