gbranden pushed a commit to branch master
in repository groff.

commit 9835b2b5980162f8dd9dd85d4e241491e1d3daee
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue May 13 12:08:15 2025 -0500

    [troff]: Reduce unnecessary output in troff mode.
    
    * src/roff/troff/node.cpp (troff_output_file::fill_color)
      (troff_output_file::stroke_color): Emit motion commands prior to
      changing fill or stroke color only in nroff mode.  Annotate why.
---
 ChangeLog               |  6 ++++++
 src/roff/troff/node.cpp | 13 ++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fc0227db2..99bfd70bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-05-13  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/node.cpp (troff_output_file::fill_color)
+       (troff_output_file::stroke_color): Emit motion commands prior to
+       changing fill or stroke color only in nroff mode.  Annotate why.
+
 2025-05-13  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/node.cpp (make_glyph_node): Assign Boolean, not
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 81f1062e2..576826bec 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -1300,7 +1300,11 @@ void troff_output_file::fill_color(color *col)
   if (!want_color_output)
     return;
   flush_tbuf();
-  do_motion();
+  // In nroff-mode devices (grotty), the fill color is a property of the
+  // character cell; our drawing position has to be on the page, lest
+  // grotty grouse "output above first line discarded".
+  if (in_nroff_mode)
+    do_motion();
   put("DF");
   unsigned int components[4];
   color_scheme scheme;
@@ -1353,8 +1357,11 @@ void troff_output_file::stroke_color(color *col)
   if (!want_color_output)
     return;
   flush_tbuf();
-  // grotty doesn't like a color command if the vertical position is zero.
-  do_motion();
+  // In nroff-mode devices (grotty), the stroke color is a property of
+  // the character cell; our drawing position has to be on the page,
+  // lest grotty grouse "output above first line discarded".
+  if (in_nroff_mode)
+    do_motion();
   put("m");
   unsigned int components[4];
   color_scheme scheme;

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

Reply via email to