gbranden pushed a commit to branch master
in repository groff.
commit b9acbdd11abf92f5c9b895db0d4cc24a5432d888
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jun 4 05:48:25 2025 -0500
[libdriver,grohtml,grops]: Revise diagnostic msgs.
* src/devices/grohtml/post-html.cpp
(html_printer::set_style)
(html_printer::set_numbered_char)
(html_printer::set_char_and_width):
* src/devices/grops/ps.cpp (ps_printer::set_style):
* src/libs/libdriver/printer.cpp (printer::set_char_and_width): Clarify
diagnostics; state what operation failed and characterize source of
invalid data as "font _description_ file", not simply a "font".
---
ChangeLog | 14 ++++++++++++++
src/devices/grohtml/post-html.cpp | 25 ++++++++++++++++++-------
src/devices/grops/ps.cpp | 6 +++---
src/libs/libdriver/printer.cpp | 8 ++++----
4 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 781030ca4..ccd4b24cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2025-06-04 G. Branden Robinson <[email protected]>
+
+ [libdriver,grohtml,grops]: Revise diagnostic messages.
+
+ * src/devices/grohtml/post-html.cpp
+ (html_printer::set_style)
+ (html_printer::set_numbered_char)
+ (html_printer::set_char_and_width):
+ * src/devices/grops/ps.cpp (ps_printer::set_style):
+ * src/libs/libdriver/printer.cpp (printer::set_char_and_width):
+ Clarify diagnostics; state what operation failed and
+ characterize source of invalid data as "font _description_
+ file", not simply a "font".
+
2025-06-04 G. Branden Robinson <[email protected]>
* src/devices/grohtml/post-html.cpp
diff --git a/src/devices/grohtml/post-html.cpp
b/src/devices/grohtml/post-html.cpp
index 06286d969..56d787562 100644
--- a/src/devices/grohtml/post-html.cpp
+++ b/src/devices/grohtml/post-html.cpp
@@ -2227,7 +2227,10 @@ void html_printer::set_style(const style &sty)
{
const char *fontname = sty.f->get_filename();
if (0 /* nullptr */ == fontname)
- fatal("no internalname specified for font");
+ // XXX: Is this the only circumstance that can cause a null font
+ // description file name? ps.cpp uses sty.f->get_internal_name()...
+ fatal("cannot set style; font description lacks an 'internalname'"
+ " directive");
#if 0
change_font(fontname, (font::res / (72 * font::sizescale))
@@ -2242,6 +2245,8 @@ void html_printer::set_style(const style &sty)
int html_printer::is_bold (font *f)
{
assert(f != 0 /* nullptr */);
+ // XXX: This property should be inferred from font description data,
+ // not the file name.
const char *fontname = f->get_filename();
return (strcmp(fontname, "B") == 0) || (strcmp(fontname, "BI") == 0);
}
@@ -2253,6 +2258,8 @@ int html_printer::is_bold (font *f)
font *html_printer::make_bold (font *f)
{
assert(f != 0 /* nullptr */);
+ // XXX: This logic locks us into a font description file naming
+ // scheme.
const char *fontname = f->get_filename();
if (strcmp(fontname, "B") == 0)
@@ -4036,9 +4043,10 @@ int html_printer::is_line_start (int nf)
int html_printer::is_font_courier (font *f)
{
+ // XXX: This logic locks us into a font description file naming
+ // scheme.
if (f != 0 /* nullptr */) {
const char *fontname = f->get_filename();
-
return((fontname != 0 /* nullptr */) && (fontname[0] == 'C'));
}
return FALSE;
@@ -4931,7 +4939,8 @@ void html_printer::set_numbered_char(int num, const
environment *env,
return;
}
if (!f->contains(g)) {
- error("font '%1' has no glyph at index %2", f->get_filename(), num);
+ error("font description file '%1' has no glyph at index %2",
+ f->get_filename(), num);
return;
}
int w;
@@ -4945,6 +4954,8 @@ void html_printer::set_numbered_char(int num, const
environment *env,
set_char(g, f, env, w, 0 /* nullptr */);
}
+// XXX: Except for `w = round_width(w);`, this seems to be identical
+// to the overridden `printer::set_char_and_width()`.
glyph *html_printer::set_char_and_width(const char *nm,
const environment *env,
int *widthp, font **f)
@@ -4965,11 +4976,11 @@ glyph *html_printer::set_char_and_width(const char *nm,
}
if (!(*f)->contains(g)) {
if ((nm[0] != '\0') && ('\0' == nm[1]))
- error("font '%1' does not contain ordinary character '%2'",
- (*f)->get_filename(), nm[0]);
+ error("font description file '%1' lacks glyph for ordinary"
+ " character '%2'", (*f)->get_filename(), nm[0]);
else
- error("font '%1' does not contain special character '%2'",
- (*f)->get_filename(), nm);
+ error("font description file '%1' lacks glyph for special"
+ " character '%2'", (*f)->get_filename(), nm);
return UNDEFINED_GLYPH;
}
int w = (*f)->get_width(g, env->size);
diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp
index 3c4e221cb..c4100608e 100644
--- a/src/devices/grops/ps.cpp
+++ b/src/devices/grops/ps.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
Written by James Clark ([email protected])
This file is part of groff.
@@ -946,8 +946,8 @@ void ps_printer::set_style(const style &sty)
out.put_literal_symbol(buf);
const char *psname = sty.f->get_internal_name();
if (0 /* nullptr */ == psname)
- fatal("no 'internalname' specified for font '%1'",
- sty.f->get_filename());
+ fatal("cannot set style; font description file '%1' lacks an"
+ " 'internalname' directive", sty.f->get_filename());
char *encoding = ((ps_font *)sty.f)->encoding;
if (sty.sub == 0) {
if (encoding != 0 /* nullptr */) {
diff --git a/src/libs/libdriver/printer.cpp b/src/libs/libdriver/printer.cpp
index dde12d093..48803328a 100644
--- a/src/libs/libdriver/printer.cpp
+++ b/src/libs/libdriver/printer.cpp
@@ -222,11 +222,11 @@ glyph *printer::set_char_and_width(const char *nm,
}
if (!(*f)->contains(g)) {
if ((nm[0] != '\0') && ('\0' == nm[1]))
- error("font '%1' does not contain ordinary character '%2'",
- (*f)->get_filename(), nm[0]);
+ error("font description file '%1' lacks glyph for ordinary"
+ " character '%2'", (*f)->get_filename(), nm[0]);
else
- error("font '%1' does not contain special character '%2'",
- (*f)->get_filename(), nm);
+ error("font description file '%1' lacks glyph for special"
+ " character '%2'", (*f)->get_filename(), nm);
return UNDEFINED_GLYPH;
}
int w = (*f)->get_width(g, env->size);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit