[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 25/25: Slow our roll on withdrawal of AT&T font support.
From: |
G. Branden Robinson |
Subject: |
[groff] 25/25: Slow our roll on withdrawal of AT&T font support. |
Date: |
Tue, 29 Oct 2024 02:26:07 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 5011cd1d5a647d977f74ccaad21e5abe004fe30e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Oct 28 18:16:40 2024 -0500
Slow our roll on withdrawal of AT&T font support.
Deprecate rather than withdrawing support for AT&T font names, on "pdf"
and "ps" devices only.
* tmac/ps.tmac: Restore font translations to groff font names.
* src/roff/troff/env.cpp: New global vector
`deprecated_font_identifiers` stores deprecated AT&T font names. Add
external declaration of `is_device_ps_or_pdf`.
(warn_if_font_name_deprecated): New function searches vector for given
symbol `nm` (a font name); if found, throws a warning in category
"font" and deletes the name from the vector.
(environment::set_font): If `is_device_ps_or_pdf`, call
`warn_if_font_name_deprecated()`.
(init_env_requests): Populate new vector.
* src/roff/troff/input.cpp: New global Boolean tracks whether the output
device is named "pdf" or "ps". We need this because "CW" is a valid,
non-deprecated font name on the "dvi" device.
(main): Once the name of the output device is determined, update
`is_device_ps_or_pdf` if necessary.
* NEWS: Revise item.
Thanks to Deri James for the discussion; see
<https://lists.gnu.org/archive/html/groff/2024-10/msg00066.html> and
follow-ups.
---
ChangeLog | 29 +++++++++++++++++++++++++++++
NEWS | 41 +++++++++++++++++++++++++----------------
src/roff/troff/env.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/roff/troff/input.cpp | 4 ++++
tmac/ps.tmac | 22 ++++++++++++++++++++++
5 files changed, 124 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 16ff148ce..15b1496b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2024-10-28 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ Deprecate rather than withdrawing support for AT&T font names,
+ on "pdf" and "ps" devices only.
+
+ * tmac/ps.tmac: Restore font translations to groff font names.
+
+ * src/roff/troff/env.cpp: New global vector
+ `deprecated_font_identifiers` stores deprecated AT&T font names.
+ Add external declaration of `is_device_ps_or_pdf`.
+ (warn_if_font_name_deprecated): New function searches vector for
+ given symbol `nm` (a font name); if found, throws a warning in
+ category "font" and deletes the name from the vector.
+ (environment::set_font): If `is_device_ps_or_pdf`, call
+ `warn_if_font_name_deprecated()`.
+ (init_env_requests): Populate new vector.
+
+ * src/roff/troff/input.cpp: New global Boolean tracks whether
+ the output device is named "pdf" or "ps". We need this because
+ "CW" is a valid, non-deprecated font name on the "dvi" device.
+ (main): Once the name of the output device is determined, update
+ `is_device_ps_or_pdf` if necessary.
+
+ * NEWS: Revise item.
+
+ Thanks to Deri James for the discussion; see
+ <https://lists.gnu.org/archive/html/groff/2024-10/msg00066.html>
+ and follow-ups.
+
2024-10-23 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/env.cpp (environment::print_env): Rearrange
diff --git a/NEWS b/NEWS
index 59a70a7f7..8f16e6239 100644
--- a/NEWS
+++ b/NEWS
@@ -185,22 +185,31 @@ Macro packages
multi-line headings. Thanks to Peter Schaffter.
* The device-specific macro files loaded by "troffrc" automatically on
- startup, such as "ps.tmac" and "html.tmac", no longer perform font
- translations for font names used by varieties of AT&T troff ('C',
- 'Hb', 'HX', and many others). These names are not portable: in AT&T
- troff, the font repertoire, like the special character repertoire,
- was device-dependent. Since groff 1.23.0, GNU troff diagnoses
- attempts to use nonexistent font names. We recommend addressing such
- portability issues wherever suits you: (1) in a document, perhaps by
- using `ie` and `el` requests and the `.g` register to test whether
- the formatter claims support for groff extensions, then `ie` and `el`
- again with the `F` groff conditional expression operator to check for
- font availability, and performing font remappings with the groff
- `ftr` request as desired; (2) doing so in your "troffrc" file; or (3)
- by modifying these macro files similarly. Users of the "dvi" and
- "lbp" output devices should be aware that these devices don't supply
- full families of monospaced fonts (and never have). See grodvi(1)
- and grolbp(1).
+ startup, such as "html.tmac", no longer perform font translations for
+ font names used by varieties of AT&T troff ('C', 'Hb', 'HX', and
+ several others).
+
+ These names are not portable: in AT&T troff, the font repertoire,
+ like the special character repertoire, was device-dependent. Since
+ groff 1.23.0, GNU troff diagnoses attempts to use nonexistent font
+ names. We recommend addressing such portability issues wherever
+ suits you: (1) in a document, perhaps by using `ie` and `el` requests
+ and the `.g` register to test whether the formatter claims support
+ for groff extensions, then `ie` and `el` again with the `F` groff
+ conditional expression operator to check for font availability, and
+ performing font remappings with the groff `ftr` request as desired;
+ (2) doing so in your "troffrc" file; or (3) by modifying these macro
+ files similarly. Users of the "dvi" and "lbp" output devices should
+ be aware that these devices don't supply full families of monospaced
+ fonts (and never have). See grodvi(1) and grolbp(1) for lists of
+ font names supported by each device.
+
+ The legacy names are retained for the "pdf" and "ps" devices for this
+ release; however, use of them prompts one warning in the "font"
+ category from the formatter per deprecated name. We expect to
+ withdraw support for the names completely in the next groff release.
+ See gropdf(1) and grops(1) for lists of font names supported by each
+ device.
* Hyperlink support is now enabled by default on PDF and terminal
devices for an (man) and doc (mdoc) documents. Instructions and
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index c3c341e21..33f51d10e 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -39,6 +39,9 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h> // errno
#include <math.h> // ceil()
+#include <vector>
+#include <algorithm> // find()
+
symbol default_family("T");
enum { ADJUST_LEFT = 0,
@@ -556,12 +559,32 @@ static node *configure_space_underlining(bool b)
return new device_extension_node(m, 1);
}
+// TODO: Kill this off in groff 1.25.
+std::vector<string> deprecated_font_identifiers;
+extern bool is_device_ps_or_pdf; // See input.cpp.
+
+static void warn_if_font_name_deprecated(symbol nm)
+{
+ const char *name = nm.contents();
+ std::vector<string>::iterator it
+ = find(deprecated_font_identifiers.begin(),
+ deprecated_font_identifiers.end(), name);
+ if (it != deprecated_font_identifiers.end()) {
+ warning(WARN_FONT, "font name '%1' is deprecated", name);
+ // Warn only once for each name.
+ deprecated_font_identifiers.erase(it);
+ }
+}
+
bool environment::set_font(symbol nm)
{
if (line_interrupted) {
warning(WARN_FONT, "ignoring font selection on interrupted line");
return true; // "no operation" is successful
}
+ // TODO: Kill off in groff 1.25.
+ if (is_device_ps_or_pdf)
+ warn_if_font_name_deprecated(nm);
if (nm == symbol("P") || nm.is_empty()) {
if (family->make_definite(prev_fontno) < 0)
return false;
@@ -4302,6 +4325,27 @@ void init_env_requests()
register_dictionary.define("skw", new variable_reg(&skw_reg_contents));
register_dictionary.define("ssc", new variable_reg(&ssc_reg_contents));
register_dictionary.define("st", new variable_reg(&st_reg_contents));
+ // TODO: Kill the following off in groff 1.25.
+ deprecated_font_identifiers.push_back("AX");
+ deprecated_font_identifiers.push_back("KR");
+ deprecated_font_identifiers.push_back("KI");
+ deprecated_font_identifiers.push_back("KB");
+ deprecated_font_identifiers.push_back("KX");
+ deprecated_font_identifiers.push_back("CW");
+ deprecated_font_identifiers.push_back("C");
+ deprecated_font_identifiers.push_back("CO");
+ deprecated_font_identifiers.push_back("CX");
+ deprecated_font_identifiers.push_back("H");
+ deprecated_font_identifiers.push_back("HO");
+ deprecated_font_identifiers.push_back("HX");
+ deprecated_font_identifiers.push_back("Hr");
+ deprecated_font_identifiers.push_back("Hi");
+ deprecated_font_identifiers.push_back("Hb");
+ deprecated_font_identifiers.push_back("Hx");
+ deprecated_font_identifiers.push_back("PA");
+ deprecated_font_identifiers.push_back("PX");
+ deprecated_font_identifiers.push_back("NX");
+ deprecated_font_identifiers.push_back("ZI");
}
// Appendix H of _The TeXbook_ is useful background for the following.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ddb5db681..cdfeb2f77 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -112,6 +112,7 @@ bool is_writing_html = false;
static int suppression_level = 0; // depth of nested \O escapes
bool in_nroff_mode = false;
+bool is_device_ps_or_pdf = false;
// Keep track of whether \f, \F, \D'F...', \H, \m, \M, \O[345], \R, \s,
// or \S has been processed in token::next().
@@ -9034,6 +9035,9 @@ int main(int argc, char **argv)
if (want_unsafe_requests)
mac_path = ¯o_path;
set_string(".T", device);
+ // TODO: Kill this off in groff 1.25. See env.cpp.
+ if ((strcmp("pdf", device) == 0) || strcmp("ps", device) == 0)
+ is_device_ps_or_pdf = true;
init_charset_table();
init_hpf_code_table();
if (0 /* nullptr */ == font::load_desc())
diff --git a/tmac/ps.tmac b/tmac/ps.tmac
index 5ddc45aca..f77a827ff 100644
--- a/tmac/ps.tmac
+++ b/tmac/ps.tmac
@@ -3,6 +3,28 @@
.do nr *groff_ps_tmac_C \n[.cp]
.cp 0
.
+.\" These font translations will be withdrawn in groff 1.25.
+.ftr AX ABI
+.ftr KR BMR
+.ftr KI BMI
+.ftr KB BMB
+.ftr KX BMBI
+.ftr CW CR
+.ftr CO CI
+.ftr CX CBI
+.ftr H HR
+.ftr HO HI
+.ftr HX HBI
+.ftr Hr HNR
+.ftr Hi HNI
+.ftr Hb HNB
+.ftr Hx HNBI
+.ftr NX NBI
+.ftr PA PR
+.ftr PX PBI
+.ftr ZI ZCMI
+.ftr C CR
+.
.cflags 8 \[an]
.
.char \[radicalex] \h'-\w'\[sr]'u'\[radicalex]\h'\w'\[sr]'u'
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 25/25: Slow our roll on withdrawal of AT&T font support.,
G. Branden Robinson <=