Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/man/man8/setfont.8.gen
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ map even if the specified map is empty. This may be useful in unusual cases.
\fB\-R\fR, \fB\-\-reset\fR
Reset the screen font, size, and Unicode mapping to the bootup defaults.
.TP
\fB\-v\fR, \fB\-\-quiet\fR
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The short option should be -q, not -v.

If kernel cannot load font, do not log error. This prevents ugly errors
with systemd try-and-fail detection of a fully initialized console.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this mention of systemd from the option description? The documentation should describe what the option does, not where the option can be used.

This option decreases the amount of information.

But actually, this utility does not do what is written here. See below.

.TP
\fB\-v\fR, \fB\-\-verbose\fR
Be verbose.
.TP
Expand Down
6 changes: 6 additions & 0 deletions src/include/kbd/kfont.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ enum kfont_option {
kfont_double_size,
};

int kfont_get_quietness(struct kfont_context *ctx)
KBD_ATTR_NONNULL(1);

void kfont_set_quietness(struct kfont_context *ctx)
KBD_ATTR_NONNULL(1);

int kfont_get_verbosity(struct kfont_context *ctx)
KBD_ATTR_NONNULL(1);

Expand Down
13 changes: 13 additions & 0 deletions src/libkfont/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ kfont_inc_verbosity(struct kfont_context *ctx)
ctx->verbose++;
}

int
kfont_get_quietness(struct kfont_context *ctx)
{
return ctx->quiet;
}

void
kfont_set_quietness(struct kfont_context *ctx)
{
ctx->quiet = 1;
}

void
kfont_set_logger(struct kfont_context *ctx, kfont_logger_t fn)
{
Expand Down Expand Up @@ -155,6 +167,7 @@ kfont_init(const char *prefix, struct kfont_context **ctx)

p->progname = prefix;
p->verbose = 0;
p->quiet = 0;
p->options = 0;
p->log_fn = log_stderr;
p->mapdirpath = mapdirpath;
Expand Down
3 changes: 2 additions & 1 deletion src/libkfont/kdfontop.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ put_font_kdfontop(struct kfont_context *ctx, int consolefd, unsigned char *buf,
return 0;

if (errno == ENOSYS) {
KFONT_ERR(ctx, _("Unable to load such font with such kernel version"));
if (!kfont_get_quietness(ctx))
KFONT_ERR(ctx, _("Unable to load such font with such kernel version"));
return -1;
}

Expand Down
1 change: 1 addition & 0 deletions src/libkfont/kfontP.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

struct kfont_context {
const char *progname;
int quiet;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need a new flag and function to display it. All you need to do is kfont_set_logger(ctx, NULL) to stop displaying all errors.

int verbose;
kfont_logger_t log_fn;

Expand Down
2 changes: 2 additions & 0 deletions src/libkfont/libkfont.map
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ KFONT_1.0 {
kfont_write_psffont;
kfont_read_unicodetable;
kfont_write_unicodetable;
kfont_get_quietness;
kfont_set_quietness;
kfont_get_verbosity;
kfont_inc_verbosity;
kfont_set_logger;
Expand Down
5 changes: 5 additions & 0 deletions src/setfont.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ int main(int argc, char *argv[])
{ "-d, --double", _("double size of font horizontally and vertically.") },
{ "-f, --force", _("force load unicode map.") },
{ "-R, --reset", _("reset the screen font, size, and unicode map to the bootup defaults.") },
{ "-q, --quiet", _("if kernel cannot load font, do not log error.") },
{ "-v, --verbose", _("be more verbose.") },
{ "-V, --version", _("print version number.") },
{ "-h, --help", _("print this usage message.") },
Expand All @@ -199,6 +200,7 @@ int main(int argc, char *argv[])
{ "=v", "verbose", kbd_no_argument, 'v' },
{ "=V", "version", kbd_no_argument, 'V' },
{ "=h", "help", kbd_no_argument, 'H' },
{ "=q", "quiet", kbd_no_argument, 'q' },
{ "+h", "font-height", kbd_required_argument, 'h' },
{ "=om", "output-consolemap", kbd_required_argument, 'M' },
{ "=ou", "output-unicodemap", kbd_required_argument, 'U' },
Expand Down Expand Up @@ -283,6 +285,9 @@ int main(int argc, char *argv[])
case 'V':
print_version_and_exit();
break;
case 'q':
kfont_set_quietness(kfont);
break;
case 'H':
usage(EXIT_SUCCESS, opthelp);
break;
Expand Down