gbranden pushed a commit to branch master
in repository groff.

commit 106ceff3926d262ce6fb63c67ac90de3519dc567
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jun 4 09:07:15 2025 -0500

    [troff]: Implement new `pfp` request.
    
    * src/roff/troff/node.cpp (dump_font_mounting_positions_request): Add.
    
      (init_node_requests): Wire up `pfp` request name to
      `dump_font_mounting_positions_request()`.
    
    * doc/groff.texi.in (Selecting Fonts, Debugging):
    * man/groff.7.man (Request short reference, Debugging):
    * man/groff_diff.7.man (New requests, Debugging):
    * NEWS: Document it.
    
    Illustration:
    
    $ echo .pfp | ./build/test-groff -T ps
    1       R
    2       I
    3       B
    4       BI
    5       TR      TR      Times-Roman
    6       CR      CR      Courier
    7       CI      CI      Courier-Oblique
    8       CB      CB      Courier-Bold
    9       CBI     CBI     Courier-BoldOblique
    10      SS      SS      Symbol-Slanted
    11      S       S       Symbol
    12      ZD      ZD      ZapfDingbats
    13      ZDR     ZDR     ZapfDingbats-Reverse
    14      AB      AB      AvantGarde-Demi
    15      ABI     ABI     AvantGarde-DemiOblique
    16      AI      AI      AvantGarde-BookOblique
    17      AR      AR      AvantGarde-Book
    18      BMB     BMB     Bookman-Demi
    19      BMBI    BMBI    Bookman-DemiItalic
    20      BMI     BMI     Bookman-LightItalic
    21      BMR     BMR     Bookman-Light
    22      HB      HB      Helvetica-Bold
    23      HBI     HBI     Helvetica-BoldOblique
    24      HI      HI      Helvetica-Oblique
    25      HR      HR      Helvetica
    26      HNB     HNB     Helvetica-Narrow-Bold
    27      HNBI    HNBI    Helvetica-Narrow-BoldOblique
    28      HNI     HNI     Helvetica-Narrow-Oblique
    29      HNR     HNR     Helvetica-Narrow
    30      NB      NB      NewCenturySchlbk-Bold
    31      NBI     NBI     NewCenturySchlbk-BoldItalic
    32      NI      NI      NewCenturySchlbk-Italic
    33      NR      NR      NewCenturySchlbk-Roman
    34      PB      PB      Palatino-Bold
    35      PBI     PBI     Palatino-BoldItalic
    36      PI      PI      Palatino-Italic
    37      PR      PR      Palatino-Roman
    38      TB      TB      Times-Bold
    39      TBI     TBI     Times-BoldItalic
    40      TI      TI      Times-Italic
    $ printf '.fp 55 PREFERRED_RESERVE_CURRENCY_IN_AGE_OF_TRUMP EURO\n.pfp\n' \
      | ./build/test-groff -T ps 2>&1 | tail -n 2
    40      TI      TI      Times-Italic
    55      PREFERRED_RESERVE_CURRENCY_IN_AGE_OF_TRUMP      EURO    FreeEuro
---
 ChangeLog               | 15 +++++++++++++++
 NEWS                    |  4 ++++
 doc/groff.texi.in       | 37 +++++++++++++++++++++++++++++++++++++
 man/groff.7.man         | 22 ++++++++++++++++++++++
 man/groff_diff.7.man    | 21 +++++++++++++++++++++
 src/roff/troff/node.cpp | 20 ++++++++++++++++++++
 6 files changed, 119 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index dd2ce26c2..0ab5eba81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -165,6 +165,21 @@
        to `fn` to preƫmpt `-Wshadow` compiler warning with planned
        refactoring of `class font`.
 
+2025-06-04  G. Branden Robinson <[email protected]>
+
+       [troff]: Implement new `pfp` request.
+
+       * src/roff/troff/node.cpp
+       (dump_font_mounting_positions_request): Add.
+
+       (init_node_requests): Wire up `pfp` request name to
+       `dump_font_mounting_positions_request()`.
+
+       * doc/groff.texi.in (Selecting Fonts, Debugging):
+       * man/groff.7.man (Request short reference, Debugging):
+       * man/groff_diff.7.man (New requests, Debugging):
+       * NEWS: Document it.
+
 2025-06-04  G. Branden Robinson <[email protected]>
 
        [troff]: Extend `font_info` class.  I need this so I can
diff --git a/NEWS b/NEWS
index 6085961b0..286ecd5be 100644
--- a/NEWS
+++ b/NEWS
@@ -208,6 +208,10 @@ troff
 *  A new request, `pcomposite`, reports to the standard error stream the
    list of configured composite character mappings.
 
+*  A new request, `pfp`, reports to the standard error stream the
+   list of occupied font mounting positions and the corresponding
+   abstract style name or font information.
+
 *  A new request, `pftr`, reports to the standard error stream the
    list of configured font translations.
 
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 2887b9117..cdf06075b 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -11198,6 +11198,16 @@ identifiers.
 @c exercised this freedom in 30+ years, and we should consider
 @c prohibiting it.  --GBR
 
+You can obtain a report of occupied font mounting positions
+(whether configured by the
+@samp{DESC}
+file or the
+@code{fp}
+request)
+on the standard error stream with the
+@code{pfp} request.
+@xref{Debugging}.
+
 @cindex font position register (@code{.f})
 The position of the currently selected font (or abstract style) is
 available in the read-only register @samp{.f}.  It is associated with
@@ -18070,6 +18080,7 @@ Examine the state of the formatter with requests that 
write lists of
 defined names---macros, strings, and diversions---colors,
 composite character mappings,
 environments,
+occupied font mounting positions,
 font translations,
 automatic hyphenation codes
 and exceptions,
@@ -18243,6 +18254,32 @@ Report the state of the current environment followed 
by that of all
 other environments to the standard error stream.
 @endDefreq
 
+@Defreq {pfp, }
+@cindex dumping occupied font mounting positions (@code{pfp})
+@cindex occupied font mounting positions, dumping (@code{pfp})
+@cindex font mounting positions, occupied, dumping (@code{pfp})
+@cindex mounting positions, occupied by fonts, dumping (@code{pfp})
+@cindex positions, font mounting, occupied, dumping (@code{pfp})
+Report,
+to the standard error stream,
+the list of occupied font mounting positions.
+Recall the
+@code{fp}
+request description in
+@ref{Selecting Fonts}.
+Occupied mounting positions are listed,
+one per line,
+in increasing order,
+followed by the typeface name;
+if the name corresponds to an abstract style,
+the entry ends there.
+Otherwise,
+the name of the font description file
+and the font's ``internal name'' datum,
+the meaning of which varies by output device,
+follow.
+@endDefreq
+
 @Defreq {pftr, }
 @cindex dumping font translations (@code{pftr})
 @cindex font translations, dumping (@code{pftr})
diff --git a/man/groff.7.man b/man/groff.7.man
index 506921728..d8159ecee 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -4262,6 +4262,26 @@ Report the state of the current environment followed by 
that of all
 other environments to the standard error stream.
 .
 .TPx
+.REQ .pfp
+Report,
+to the standard error stream,
+the list of occupied font mounting positions.
+.\" Recall the @code{fp} request description in @ref{Selecting Fonts}.
+.
+Occupied mounting positions are listed,
+one per line,
+in increasing order,
+followed by the typeface name;
+if the name corresponds to an abstract style,
+the entry ends there.
+.
+Otherwise,
+the name of the font description file
+and the font's \[lq]internal name\[rq] datum,
+the meaning of which varies by output device,
+follow.
+.
+.TPx
 .REQ .pftr
 Report,
 to the standard error stream,
@@ -9048,6 +9068,8 @@ composite character mappings
 .RB ( pcomposite );
 environments
 .RB ( pev );
+occupied font mounting positions
+.RB ( pfp );
 font translations
 .RB ( pftr );
 automatic hyphenation codes
diff --git a/man/groff_diff.7.man b/man/groff_diff.7.man
index d7e019f66..522c2a487 100644
--- a/man/groff_diff.7.man
+++ b/man/groff_diff.7.man
@@ -3478,6 +3478,27 @@ other environments to the standard error stream.
 .
 .
 .TP
+.B .pfp
+Report,
+to the standard error stream,
+the list of occupied font mounting positions.
+.\" Recall the @code{fp} request description in @ref{Selecting Fonts}.
+.
+Occupied mounting positions are listed,
+one per line,
+in increasing order,
+followed by the typeface name;
+if the name corresponds to an abstract style,
+the entry ends there.
+.
+Otherwise,
+the name of the font description file
+and the font's \[lq]internal name\[rq] datum,
+the meaning of which varies by output device,
+follow.
+.
+.
+.TP
 .B .pftr
 Report,
 to the standard error stream,
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 8cb37303e..f20440146 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6547,6 +6547,25 @@ static bool mount_font_no_translate(int n, symbol name, 
symbol filename,
   return true;
 }
 
+void dump_font_mounting_positions_request()
+{
+  for (int i = 0; i < font_table_size; i++) {
+    font_info *fi = font_table[i];
+    if (0 /* nullptr */ == fi) // No font mounted here.
+      continue;
+    errprint("%1\t%2", i, fi->get_name().contents());
+    font *f = font_table[i]->get_font();
+    if (f != 0 /* nullptr */) { // It's not an abstract style.
+      errprint("\t%1", f->get_filename());
+      if (f->get_internal_name() != 0 /* nullptr */)
+       errprint("\t%1", f->get_internal_name());
+    }
+    errprint("\n");
+    fflush(stderr);
+  }
+  skip_line();
+}
+
 bool mount_font(int n, symbol name, symbol external_name)
 {
   assert(n >= 0);
@@ -7380,6 +7399,7 @@ void init_node_requests()
   init_request("ftr", translate_font);
   init_request("kern", set_kerning_mode);
   init_request("lg", set_ligature_mode);
+  init_request("pfp", dump_font_mounting_positions_request);
   init_request("pftr", dump_font_translations);
   init_request("rfschar", remove_font_specific_character);
   init_request("shc", soft_hyphen_character_request);

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to