unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#39602] Generate font catalogues for the X server
@ 2020-02-14 17:17 Ivan Kozlov
  2020-06-12 18:44 ` Ivan Kozlov
  2020-06-22 20:11 ` Marius Bakke
  0 siblings, 2 replies; 3+ messages in thread
From: Ivan Kozlov @ 2020-02-14 17:17 UTC (permalink / raw)
  To: 39602

Actually, I am sending this as a patch.

This should produce a "share/fontpath.d" directory in the profile which is a font catalogue as described in Xserver(1). Then the X server font path can be set to include this catalogue and it will find the installed fonts. This concerns all legacy X11 applications using the core fonts system, and most importantly xterm.

The hook ‘fonts-dir-file’ was originally added for this purpose as the comments can tell; you would include e. g. "share/fonts/X11/misc" from the profile in the font path, which is a union directory with symbolic links to fonts that want to install there and a fonts.dir file describing all of them. This has not been working for ages, since the X.org server stopped following symbolic links to font files for security reasons. It should be removed.

--- a/guix/profiles.scm 2020-01-01 13:03:15.579056969 +0300
+++ b/guix/profiles.scm 2020-02-14 19:52:51.979902836 +0300
@@ -1293,6 +1293,37 @@
                     `((type . profile-hook)
                       (hook . fonts-dir))))
 
+(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))
+              (fonpath-dir (string-append #$output "/share/fontpath.d")))
+         (mkdir-p fontpath-dir)
+         (chdir fontpath-dir)
+         (for-each (lambda (dir pri)
+                     (symlink dir (string-append (basename dir) ":pri=" (number->string pri))))
+                   font-dirs
+                   (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))))
+
 (define (manual-database manifest)
   "Return a derivation that builds the manual page database (\"mandb\") for
 the entries in MANIFEST."
@@ -1430,6 +1461,7 @@
   (list info-dir-file
         manual-database
         fonts-dir-file
+       fontpath-file
         ghc-package-cache-file
         ca-certificate-bundle
         glib-schemas

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

* [bug#39602] Generate font catalogues for the X server
  2020-02-14 17:17 [bug#39602] Generate font catalogues for the X server Ivan Kozlov
@ 2020-06-12 18:44 ` Ivan Kozlov
  2020-06-22 20:11 ` Marius Bakke
  1 sibling, 0 replies; 3+ messages in thread
From: Ivan Kozlov @ 2020-06-12 18:44 UTC (permalink / raw)
  To: 39602

Is nobody interested in this? I don’t see any problems with the patch.

This must have been of concern at least once, judging by fonts-dir-file’s existence. The fontpath mechanism is the only way today to make the core (server-side) fonts work reasonably.

14.02.2020, 20:17, "Ivan Kozlov" <kanichos@yandex.ru>:
> Actually, I am sending this as a patch.
>
> This should produce a "share/fontpath.d" directory in the profile which is a font catalogue as described in Xserver(1). Then the X server font path can be set to include this catalogue and it will find the installed fonts. This concerns all legacy X11 applications using the core fonts system, and most importantly xterm.
>
> The hook ‘fonts-dir-file’ was originally added for this purpose as the comments can tell; you would include e. g. "share/fonts/X11/misc" from the profile in the font path, which is a union directory with symbolic links to fonts that want to install there and a fonts.dir file describing all of them. This has not been working for ages, since the X.org server stopped following symbolic links to font files for security reasons. It should be removed.
>
> --- a/guix/profiles.scm 2020-01-01 13:03:15.579056969 +0300
> +++ b/guix/profiles.scm 2020-02-14 19:52:51.979902836 +0300
> @@ -1293,6 +1293,37 @@
>                      `((type . profile-hook)
>                        (hook . fonts-dir))))
>
> +(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))
> + (fonpath-dir (string-append #$output "/share/fontpath.d")))
> + (mkdir-p fontpath-dir)
> + (chdir fontpath-dir)
> + (for-each (lambda (dir pri)
> + (symlink dir (string-append (basename dir) ":pri=" (number->string pri))))
> + font-dirs
> + (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))))
> +
>  (define (manual-database manifest)
>    "Return a derivation that builds the manual page database (\"mandb\") for
>  the entries in MANIFEST."
> @@ -1430,6 +1461,7 @@
>    (list info-dir-file
>          manual-database
>          fonts-dir-file
> + fontpath-file
>          ghc-package-cache-file
>          ca-certificate-bundle
>          glib-schemas




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

* [bug#39602] Generate font catalogues for the X server
  2020-02-14 17:17 [bug#39602] Generate font catalogues for the X server Ivan Kozlov
  2020-06-12 18:44 ` Ivan Kozlov
@ 2020-06-22 20:11 ` Marius Bakke
  1 sibling, 0 replies; 3+ messages in thread
From: Marius Bakke @ 2020-06-22 20:11 UTC (permalink / raw)
  To: Ivan Kozlov, 39602

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

Ivan Kozlov <kanichos@yandex.ru> writes:

> Actually, I am sending this as a patch.
>
> This should produce a "share/fontpath.d" directory in the profile which is a font catalogue as described in Xserver(1). Then the X server font path can be set to include this catalogue and it will find the installed fonts. This concerns all legacy X11 applications using the core fonts system, and most importantly xterm.
>
> The hook ‘fonts-dir-file’ was originally added for this purpose as the comments can tell; you would include e. g. "share/fonts/X11/misc" from the profile in the font path, which is a union directory with symbolic links to fonts that want to install there and a fonts.dir file describing all of them. This has not been working for ages, since the X.org server stopped following symbolic links to font files for security reasons. It should be removed.

Thanks for this investigation, and the patch!

Overall it LGTM, but I wonder how useful it is, seeing as no one has
reported the issue.  Would it make sense to add hooks in the
configuration system instead for setting font path and a font union?

A patch to remove the legacy broken 'fonts-dir-file' generation from
(guix profiles) would be welcome, by the way.

Thanks,
Marius

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

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14 17:17 [bug#39602] Generate font catalogues for the X server Ivan Kozlov
2020-06-12 18:44 ` Ivan Kozlov
2020-06-22 20:11 ` Marius Bakke

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