guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making the core fonts work


From: Ivan Kozlov
Subject: Making the core fonts work
Date: Fri, 14 Feb 2020 09:44:16 +0300

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]