gbranden pushed a commit to branch master
in repository groff.

commit 817cddeefa3f560174a5c1ed69960541a2b70a6e
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Mar 5 08:35:03 2026 -0600

    [troff]: Add `is_valid_font()` function.
    
    Add internal mechanism for distinguishing validity of font mounting
    positions as _values_ from their usability to format output.  A font
    mounting position is an integer with a limited range.  The font
    information associated with that (otherwise valid) position can
    nevertheless not be usable for formatting output.  While the formatter
    attempts to prevent input documents from contorting themselves into this
    situation, it also affords a means of egress from valid state.  See the
    `sty` (counter-)example in groff's Texinfo manual <https://www.gnu.org/\
    software/groff/manual/groff.html.node/Font-Families.html>.
    
    Add new function taking an integer mounting position and returning a
    Boolean.
    
    * src/roff/troff/node.h: Declare it.
    * src/roff/troff/node.cpp (is_valid_font): Define it.
---
 ChangeLog               | 20 ++++++++++++++++++++
 src/roff/troff/node.cpp |  6 ++++++
 src/roff/troff/node.h   |  1 +
 3 files changed, 27 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index a187abdf4..59fc3fb2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2026-03-05  G. Branden Robinson <[email protected]>
+
+       [troff]: Add internal mechanism for distinguishing validity of
+       font mounting positions as _values_ from their usability to
+       format output.  A font mounting position is an integer with a
+       limited range.  The font information associated with that
+       {otherwise valid} position can nevertheless not be usable for
+       formatting output.  While the formatter attempts to prevent
+       input documents from contorting themselves into this situation,
+       it also affords a means of egress from valid state.  See the
+       `sty` (counter-)example in groff's Texinfo manual <https://\
+       www.gnu.org/software/groff/manual/groff.html.node/
+       Font-Families.html>.
+
+       Add new function taking an integer mounting position and
+       returning a Boolean.
+
+       * src/roff/troff/node.h: Declare it.
+       * src/roff/troff/node.cpp (is_valid_font): Define it.
+
 2026-03-05  G. Branden Robinson <[email protected]>
 
        [troff]: Refactor resolution of currently selected font (which
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 053d727ff..9901a21d3 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6970,6 +6970,12 @@ bool is_valid_font_mounting_position(int n)
          && (font_table[n] != 0 /* nullptr */));
 }
 
+bool is_valid_font(int n)
+{
+  return (is_valid_font_mounting_position(n)
+         && !(font_table[n]->is_style()));
+}
+
 // Read the next token and look it up as a font name or position number.
 // Return lookup success.  Store, in the supplied struct argument, the
 // requested name or position, and the position actually resolved.
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 051b62e78..da9886bd9 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -708,6 +708,7 @@ extern bool is_font_name(symbol, symbol);
 extern bool is_abstract_style(symbol);
 extern bool mount_style(int, symbol);
 extern bool is_valid_font_mounting_position(int);
+extern bool is_valid_font(int);
 extern int symbol_fontno(symbol);
 extern int next_available_font_position();
 extern void init_size_list(int *);

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

Reply via email to