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;