On Wednesday, 9 October 2024 16:33:21 BST G. Branden Robinson wrote:
> > If the warning was about the AT&T fontnames being deprecated but no
> > change to the font used (i.e. continue to use CR), even though there
> > would be 1000+ warnings, it would achieve your desire to drop support
> > for the ancient font names but in a way which did not affect rendering
> > of the document in the interim.
> 
> What do you suggest instead?

Hi Branden,


I tnought something like this:-

diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index a087bc601..2dea476ce 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -556,6 +556,8 @@ static node *configure_space_underlining(bool b)
   return new device_extension_node(m, 1);
 }
 
+static char ATnTfonts[]="#AX|ABI#KR|BMR#KI|BMI#KB|BMB#KX|BMBI#C|CR#CW|CR#CO|
CI#CX|CBI#H|HR#HO|HI#HX|HBI#Hr|HNR#Hi|HNI#Hb|HNB#Hx|HNBI#NX|NBI#PA|PR#PX|
PBI#ZI|ZCMI#";
+
 bool environment::set_font(symbol nm)
 {
   if (line_interrupted) {
@@ -571,6 +573,17 @@ bool environment::set_font(symbol nm)
   }
   else {
     prev_fontno = fontno;
+    char cnm[8]="#";
+    strncat(cnm+1,nm.contents(),6);
+    char *found=strstr(ATnTfonts,cnm);
+    char *alias=found+strlen(cnm);
+
+    if (0 != found && *alias++ == '|') {
+      int alen=strcspn(alias,"#");
+      warning(WARN_FONT, "obsolete AT&T font names (such as '%1') have been 
deprecated.", cnm+1);
+      memset(found+1,32,alias-found+alen-1);
+    }
+
     int n = symbol_fontno(nm);
     if (n < 0) {
       n = next_available_font_position();

Of course this is not a serious patch (although it works). I've never dabbled 
in C++, I have not written anything in C for over 30 years, and I don't have a 
very deep understanding of groff internals, but it may give you an idea how 
deprecation of the AT&T font names could be handled, rather than sudden 
removal.

You can test by reinstating the .ftr requests and run a document using the old 
font names. You should see a warning for each different obsolete font used, 
rather than repeated message each time the font is used.

Anyway, you did ask, I'm sure you could do it better.

Cheers 

Deri

Reply via email to