Thanks to Damian, Ralph, and Doug for the feedback.

At 2023-04-08T15:54:55+1000, Damian McGuckin wrote:
> On Fri, 7 Apr 2023, G. Branden Robinson wrote:
> 
> > Crazy?  Sensible?  A long time coming?
> 
> Answers areL No. Yes. At long last.
> 
> The fix does not look quite right but maybe my brain is not switched
> on.

It seems to work okay.  I'm attaching a sample document with PostScript.

At 2023-04-08T11:46:14+0100, Ralph Corderoy wrote:
>     gbfont f
>         Set the bold font to f.
> 
>     gfont f
>     gifont f
>         Set the italic font to f.  gifont is a GNU extension.
> 
>     grfont f
>         Set the roman font to f.
> 
> I think ‘is a GNU extension’ is typical language for GNU documentation.

Yes.  Our eqn(1) is organized a bit funny because it doesn't attempt to
be a comprehensive reference, but rather a primer on GNU extensions.
This always makes it hard for me to settle on who my audience is.

> > -  { "gfont", GIFONT },
> > +  { "gifont", GIFONT },
> > +  { "gfont", GIFONT }, // for backward compatibility
> ...
> > -    lex_error("invalid argument to gfont primitive");
> > +    lex_error("invalid argument to gifont primitive");
> 
> The user should see a message which uses the keyword they entered.
> It's annoying to search for ‘gifont’ and not find it, as will be
> typical.

Yes.  I had a twinge of conscience about it when I did this; I have high
expectations of diagnostic messages.  The days when one could excuse
oneself by saying "we don't have enough room in core to store
diagnostics that help anyone but the program author" are long gone.

> One way to do this would be to have GFONT and GIFONT and only treat
> them the same later on.

Yes; they now both wrap `set_gifont()`, which takes care of it.

At 2023-04-08T09:53:37-0400, Douglas McIlroy wrote:
> The proposal is clean and well defended.
> 
> Perfecting tweaks for the proposed man page:
> 
> 1. Delete the parenthesized remark about boldface. At best it is TMI,
> at worst, condescending.

Done.  This arose from my casting about confusedly for an audience as
noted above.

> 2. To parallel the phrase "to be set in italic", delete "type" from
> "to be set in roman type".

Done.  (And strictly, we should be saying "oblique" and "upright", but
that ship has probably sailed for eqn(1).)

> 3. Delete the last sentence from the main paragraph. This complicated
> statement (check that adverbial participial phrase with a quintuple
> noun, "groff font selection escape sequences") offers little return on
> a reader's effort to understand it..One can figure the lesson out for
> oneself when needed.

*laugh*  Granted.  Fixed.  I am put in mind of a story about a basement
wall sign somewhere that read:

  SUMP PUMP BACKUP ALARM SILENCER SWITCH

Some Chomskian grammarians had fun with that one.

> 4. Shorten the sentence about compatibility to
> 
>         gfont f
>             Synonym for gifont f

I don't want to have a tagged paragraph for this primitive at all.  The
term is locatable in the page with a / search in the pager.  I don't
think any eqn veterans who used gfont will ever forget its existence,
but they will still be able to find (and use) it.  I want the tagged
paragraphs to present the contemporary dialect of the language.

Here are the revised sections of the man page.  The introductory
paragraph to "New primitives" is new; heretofore it said nothing about
whether the subsequent list was comprehensive (it wasn't).

  New primitives
    The GNU extension primitives "type" and chartype are discussed in
    subsection "Automatic spacing" above; "set" in subsection
    "Customization" below; and gbfont, gifont, and grfont in subsection
    "Fonts" below.

...

  Fonts
    eqn uses up to three typefaces to set an equation: an italic face
    for letters, a roman face for everything else, and a bold face.  The
    defaults for these correspond to the groff font styles I, R, and B,
    respectively, using the font family that is current when the
    equation is set.  The primitives gifont, grfont, and gbfont assign a
    groff typeface to each of eqn's faces.  Control which characters are
    treated as letters (and therefore set in italics) with the chartype
    primitive described above.  A character assigned the type letter is
    set in italics; a digit is set in roman.

    gbfont f
        Set the bold font to f.

    gifont f
        Set the italic font to f.  For AT&T eqn compatibility, gfont is
        recognized as a synonym for gifont.

    grfont f
        Set the roman font to f.

Further feedback is welcome.

Regards,
Branden
diff --git a/NEWS b/NEWS
index 3cf0b8ed8..9f5e66265 100644
--- a/NEWS
+++ b/NEWS
@@ -128,6 +128,12 @@ o The command-line option -D is no longer supported.  It has been
   undocumented, and issued a warning of its obsolescence upon use, for
   30 years, since groff 1.06 (September 1992).
 
+o The "gifont" primitive replaces "gfont" as the means of configuring
+  the global italic face within an equation.  "gfont" remains recognized
+  as a synonym for backward compatibility.  The new name is intended to
+  ease acquisition of the eqn language in light of GNU eqn's
+  thirty-year-old extensions "gbfont" and "grfont".
+
 pic
 ---
 
diff --git a/src/preproc/eqn/eqn.1.man b/src/preproc/eqn/eqn.1.man
index d99766a61..264518487 100644
--- a/src/preproc/eqn/eqn.1.man
+++ b/src/preproc/eqn/eqn.1.man
@@ -10,7 +10,7 @@ or MathML
 .\" Legal Terms
 .\" ====================================================================
 .\"
-.\" Copyright (C) 1989-2022 Free Software Foundation, Inc.
+.\" Copyright (C) 1989-2023 Free Software Foundation, Inc.
 .\"
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
@@ -372,14 +372,19 @@ and
 .SS "New primitives"
 .\" ====================================================================
 .
-The new primitives
-.B type
+The GNU extension primitives
+.RB \[lq] type \[rq]
 and
 .B \%chartype
-are discussed in subsection \[lq]Automatic spacing\[rq] above,
+are discussed in subsection \[lq]Automatic spacing\[rq] above;
+.RB \[lq] set \[rq]
+in subsection \[lq]Customization\[rq] below;
 and
-.B set
-in subsection \[lq]Customization\[rq] below.
+.BR gbfont ,
+.BR gifont ,
+and
+.B grfont
+in subsection \[lq]Fonts\[rq] below.
 .
 .
 .TP
@@ -1404,76 +1409,69 @@ which sets three dots on the baseline.
 .\" ====================================================================
 .
 .I @g@eqn
-normally uses at least two fonts to set an equation:
-an italic font for letters,
-and a roman font for everything else.
-.
-The AT&T
-.I eqn \" AT&T
-.B gfont
-primitive changes the font that is used as the italic font.
-.
-By default this
-.RB is\~ I .
-.
-The font that is used as the roman font can be changed using the new
-.B grfont
-command.
-.
-.
-.TP
-.BI grfont\~ f
-Set the roman font
-.RI to\~ f .
-.
-.
-.P
-The
-.B italic
-primitive uses the current italic font set by
-.BR gfont ;
-the
-.B \%roman
-primitive uses the current roman font set by
-.BR grfont .
+uses up to three typefaces to set an equation:
+an italic face for letters,
+a roman face for everything else,
+and a bold face.
 .
-GNU
-.I eqn \" GNU
-offers a
-.B gbfont
-primitive,
-which changes the font used by the
-.B bold
-primitive.
-.
-If you use only the
-.BR roman ,
-.B italic
+The defaults for these correspond to the
+.I groff
+font styles
+.BR I ,
+.BR R ,
 and
-.B bold
-primitives to change fonts within an equation,
-then
-.BR gfont ,
-.B grfont
+.BR B ,
+respectively,
+using the font family that is current when the equation is set.
+.
+The primitives
+.BR gifont ,
+.BR grfont ,
 and
 .B gbfont
-suffice to configure all the typefaces used by your equations.
-.
+assign a
+.I groff
+typeface to each of
+.IR @g@eqn 's
+faces.
 .
-.LP
-You can control which characters are treated as letters
+Control which characters are treated as letters
 (and therefore set in italics)
-by using the
+with the
 .B chartype
 primitive described above.
 .
-A type of
+A character assigned the type
 .B letter
-causes a character to be set in italic type.
-.
-A type of
+is set in italics;
+a
 .B digit
-causes a character to be set in roman type.
+is set in roman.
+.
+.
+.TP
+.BI gbfont\~ f
+Set the bold font
+.RI to\~ f .
+.
+.
+.TP
+.BI gifont\~ f
+Set the italic font
+.RI to\~ f .
+.
+For
+AT&T
+.I eqn \" AT&T
+compatibility,
+.B gfont
+is recognized as a synonym for
+.BR gifont .
+.
+.TP
+.BI grfont\~ f
+Set the roman font
+.RI to\~ f .
 .
 .
 .\" ====================================================================
@@ -1522,7 +1520,7 @@ statements in the source file override this option.
 .TP
 .BI \-f\~ F
 is equivalent to
-.RB \[lq] gfont
+.RB \[lq] gifont
 .IR F \[rq].
 .
 .
@@ -1716,7 +1714,7 @@ command
 .
 .RS
 .EX
-gfont PI
+gifont PI
 .EE
 .RE
 .
@@ -1727,7 +1725,7 @@ you must use
 .
 .RS
 .EX
-gfont "PI"
+gifont "PI"
 .EE
 .RE
 .
diff --git a/src/preproc/eqn/eqn.ypp b/src/preproc/eqn/eqn.ypp
index d6f8c8b58..4e806d8d7 100644
--- a/src/preproc/eqn/eqn.ypp
+++ b/src/preproc/eqn/eqn.ypp
@@ -86,7 +86,7 @@ void yyerror(const char *);
 
 /* these are handled in the lexer */
 %token SPACE
-%token GIFONT
+%token GFONT
 %token GSIZE
 %token DEFINE
 %token NDEFINE
@@ -100,6 +100,7 @@ void yyerror(const char *);
 %token SET
 %token GRFONT
 %token GBFONT
+%token GIFONT
 
 /* The original eqn manual says that 'left' is right associative. It's lying.
 Consider 'left ( ~ left ( ~ right ) right )'. */
diff --git a/src/preproc/eqn/lex.cpp b/src/preproc/eqn/lex.cpp
index 8eaaca593..d2d53f310 100644
--- a/src/preproc/eqn/lex.cpp
+++ b/src/preproc/eqn/lex.cpp
@@ -94,7 +94,8 @@ static struct {
   { "mark", MARK },
   { "lineup", LINEUP },
   { "space", SPACE },
-  { "gfont", GIFONT },
+  { "gifont", GIFONT },
+  { "gfont", GFONT }, // for backward compatibility
   { "gsize", GSIZE },
   { "define", DEFINE },
   { "sdefine", SDEFINE },
@@ -1004,7 +1005,7 @@ void do_gsize()
     lex_error("invalid size '%1'", token_buffer.contents());
 }
 
-void do_gifont()
+void do_gfont()
 {
   int t = get_token(2);
   if (t != TEXT && t != QUOTED_TEXT) {
@@ -1015,6 +1016,17 @@ void do_gifont()
   set_gifont(token_buffer.contents());
 }
 
+void do_gifont()
+{
+  int t = get_token(2);
+  if (t != TEXT && t != QUOTED_TEXT) {
+    lex_error("invalid argument to gifont primitive");
+    return;
+  }
+  token_buffer += '\0';
+  set_gifont(token_buffer.contents());
+}
+
 void do_grfont()
 {
   int t = get_token(2);
@@ -1172,6 +1184,9 @@ int yylex()
     case GSIZE:
       do_gsize();
       break;
+    case GFONT:
+      do_gfont();
+      break;
     case GIFONT:
       do_gifont();
       break;

Attachment: demo-gifont.ms
Description: Troff MS-macros document

Attachment: demo-gifont.ps
Description: PostScript document

Attachment: signature.asc
Description: PGP signature

Reply via email to