Allow console-font service to use fonts other than those packaged with kbd

  • Done
  • quality assurance status badge
Details
2 participants
  • John Soo
  • Ludovic Courtès
Owner
unassigned
Submitted by
John Soo
Severity
normal

Debbugs page

John Soo wrote 6 years ago
(address . bug-guix@gnu.org)
2B601D3D-75D4-4F3B-8324-E039395227CE@asu.edu
The console font service only allows fonts installed by default in the kbd package (tamzen, for instance, has a nice bitmap font available). I don’t know what the solution might be. I do know that setfont looks in the default font directory only for fonts and the available fonts are those that come packaged with the kbd package.
John Soo wrote 6 years ago
[PATCH] Attempt to use console-fonts not provided by kbd if they are installed
(address . 36014@debbugs.gnu.org)
CAKf5CqUzP1oopvRZz-ss2Ksxoif7ikmpOtyen8o+B0RZ6g89MQ@mail.gmail.com
Hi maintainers,

I looked hard at a nicer way to provide a flag to start kbd pointing to a
directory or file. There is a flag to point to a file for a font which
could be nice. However setfont also prioritizes the current directory over
the kbd directory. The following patch attempts to chdir to a directory
where more console fonts may be installed.

- John
Attachment: file
From 15aa08d212ecea31adcd86f922c0f68297cd423a Mon Sep 17 00:00:00 2001
From: John Soo <jsoo@panosoft.com>
Date: Wed, 10 Jul 2019 06:51:41 -0700
Subject: [PATCH] gnu: Try using any system installed console fonts.

---
gnu/services/base.scm | 7 +++++++
1 file changed, 7 insertions(+)

Toggle diff (20 lines)
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 537d30add5..60d03df9ed 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -775,6 +775,13 @@ to add @var{device} to the kernel's entropy pool. The service will fail if
(usleep 500)
(loop (- i 1))))
+ ;; Try to use any other installed system fonts.
+ (catch #t
+ (lambda _
+ (chdir
+ "/run/current-system/profile/share/kbd/consolefonts"))
+ (lambda _ #t))
+
;; Assume the VT is already in UTF-8 mode, thanks to
;; the 'virtual-terminal' service.
;;
--
2.22.0
Ludovic Courtès wrote 6 years ago
(name . John Soo)(address . jsoo1@asu.edu)(address . 36014@debbugs.gnu.org)
87pnmgpa8q.fsf@gnu.org
Hi John,

John Soo <jsoo1@asu.edu> skribis:

Toggle quote (6 lines)
> I looked hard at a nicer way to provide a flag to start kbd pointing to a
> directory or file. There is a flag to point to a file for a font which
> could be nice. However setfont also prioritizes the current directory over
> the kbd directory. The following patch attempts to chdir to a directory
> where more console fonts may be installed.

What about doing something like this in your config

(console-font-service "tty1"
(file-append some-font-package
"/share/consolefonts/whatever"))

?

Does it work for you?

This approach has the advantage that the service doesn’t need to be
changed, and it doesn’t need to change the current directory of PID 1
either.

Thanks,
Ludo’.
John Soo wrote 6 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 36014@debbugs.gnu.org)
F59CBB33-E085-4329-B769-7FB1E96FDD3D@asu.edu
Thanks Ludo!

I really appreciate how engaged you are btw. Thanks so much. But yes I agree I’d rather not change the directory either. I will see what I can do and report back.

John

Toggle quote (28 lines)
> On Jul 11, 2019, at 1:49 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>
> Hi John,
>
> John Soo <jsoo1@asu.edu> skribis:
>
>> I looked hard at a nicer way to provide a flag to start kbd pointing to a
>> directory or file. There is a flag to point to a file for a font which
>> could be nice. However setfont also prioritizes the current directory over
>> the kbd directory. The following patch attempts to chdir to a directory
>> where more console fonts may be installed.
>
> What about doing something like this in your config
>
> (console-font-service "tty1"
> (file-append some-font-package
> "/share/consolefonts/whatever"))
>
> ?
>
> Does it work for you?
>
> This approach has the advantage that the service doesn’t need to be
> changed, and it doesn’t need to change the current directory of PID 1
> either.
>
> Thanks,
> Ludo’.
John Soo wrote 6 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 36014@debbugs.gnu.org)
D71D5F21-02A9-41C2-8421-2115C3106E97@asu.edu
Ok so I tried your suggestion and it works! I’m so surprised but I think I’ll update the docs to reflect this possibility instead of the current patch.

- John

Toggle quote (28 lines)
> On Jul 11, 2019, at 1:49 PM, Ludovic Courtès <ludo@gnu.org> wrote:
>
> Hi John,
>
> John Soo <jsoo1@asu.edu> skribis:
>
>> I looked hard at a nicer way to provide a flag to start kbd pointing to a
>> directory or file. There is a flag to point to a file for a font which
>> could be nice. However setfont also prioritizes the current directory over
>> the kbd directory. The following patch attempts to chdir to a directory
>> where more console fonts may be installed.
>
> What about doing something like this in your config
>
> (console-font-service "tty1"
> (file-append some-font-package
> "/share/consolefonts/whatever"))
>
> ?
>
> Does it work for you?
>
> This approach has the advantage that the service doesn’t need to be
> changed, and it doesn’t need to change the current directory of PID 1
> either.
>
> Thanks,
> Ludo’.
Ludovic Courtès wrote 6 years ago
(name . John Soo)(address . jsoo1@asu.edu)(address . 36014@debbugs.gnu.org)
875zo7f0m3.fsf@gnu.org
Hi John,

John Soo <jsoo1@asu.edu> skribis:

Toggle quote (2 lines)
> Ok so I tried your suggestion and it works! I’m so surprised but I think I’ll update the docs to reflect this possibility instead of the current patch.

That’s a good idea, thank you!

Ludo’.
John Soo wrote 6 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 36014@debbugs.gnu.org)
CAKf5CqV3mH_1+HS2wRmkcWbb6JHehxgd0rrFc+eFW-cpEN=Yqw@mail.gmail.com
Hi Ludo,

I am not familiar with the info and html documentation build process. Will
this patch suffice?

Thank you,

John
Attachment: file
From 681d6e2f81b4cf46501c2312edcef4c98284675b Mon Sep 17 00:00:00 2001
From: John Soo <jsoo1@asu.edu>
Date: Fri, 16 Aug 2019 10:45:43 -0700
Subject: [PATCH] gnu: Update console-font-service docstring.

* gnu/services/base (console-font-service-type):
Add documentation about valid arguments.
---
gnu/services/base.scm | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

Toggle diff (31 lines)
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 537d30add5..363cb20c06 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -8,6 +8,7 @@
;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2019 John Soo <jsoo1@asu.edu>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -801,10 +802,14 @@ to add @var{device} to the kernel's entropy pool. The service will fail if
(description
"Install the given fonts on the specified ttys (fonts are per
virtual console on GNU/Linux). The value of this service is a list of
-tty/font pairs like:
+tty/font pairs. The font can be the name of a font provided by the kbd package
+or any valid argument to setfont. For example:
@example
-'((\"tty1\" . \"LatGrkCyr-8x16\"))
+'((\"tty1\" . \"LatGrkCyr-8x16\")
+ (\"tty2\" . (file-append
+ font-tamzen
+ \"/share/kbd/consolefonts/TamzenForPowerline10x20.psf\")))
@end example\n")))
(define* (console-font-service tty #:optional (font "LatGrkCyr-8x16"))
--
2.22.0
Ludovic Courtès wrote 6 years ago
(name . John Soo)(address . jsoo1@asu.edu)(address . 36014-done@debbugs.gnu.org)
874l29p4vz.fsf@gnu.org
Hello,

John Soo <jsoo1@asu.edu> skribis:

Toggle quote (3 lines)
> I am not familiar with the info and html documentation build process. Will
> this patch suffice?

Sure; I pushed a slightly modified variant as commit
74a98b5cddd0430dd7229d4045f4885191c624b7.

Thanks,
Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 36014@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 36014
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help