groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 02/06: [pic]: Save and restore stroke and fill colors.


From: G. Branden Robinson
Subject: [groff] 02/06: [pic]: Save and restore stroke and fill colors.
Date: Mon, 25 Sep 2023 10:20:08 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 51253cd140d73a0052c436d48a90805c36eabd78
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Sep 25 05:34:46 2023 -0500

    [pic]: Save and restore stroke and fill colors.
    
    ...when entering and leaving, respectively, preprocessed regions.
    
    * src/preproc/pic/troff.cpp: Define C/C++ preprocessor macros to house
      names of *roff strings storing this information.
    
      (troff_output::start_picture): Save stroke and fill colors.
    
      (troff_output::finish_picture): Restore stroke and fill colors.
    
    Fixes <https://savannah.gnu.org/bugs/?64624>.  Thanks to Dave Kemper for
    the report and testing this code change.
---
 ChangeLog                 | 13 +++++++++++++
 src/preproc/pic/troff.cpp |  9 +++++++++
 2 files changed, 22 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 51d40792f..dd0e92007 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-09-25  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [pic]: Save and restore stroke and fill colors when entering and
+       leaving, respectively, preprocessed regions.
+
+       * src/preproc/pic/troff.cpp: Define C/C++ preprocessor macros to
+       house names of *roff strings storing this information.
+       (troff_output::start_picture): Save stroke and fill colors.
+       (troff_output::finish_picture): Restore stroke and fill colors.
+
+       Fixes <https://savannah.gnu.org/bugs/?64624>.  Thanks to Dave
+       Kemper for the report and testing this code change.
+
 2023-09-22  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * doc/doc.am (doc/meintro_fr.ps): Depend on tbl, resolving race
diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp
index c66e43e2f..eb1f9e48b 100644
--- a/src/preproc/pic/troff.cpp
+++ b/src/preproc/pic/troff.cpp
@@ -271,6 +271,9 @@ inline position troff_output::transform(const position &pos)
 // If this register is defined, geqn won't produce '\x's.
 #define EQN_NO_EXTRA_SPACE_REG "0x"
 
+#define SAVED_STROKE_COLOR_STR "gpic*saved-stroke-color"
+#define SAVED_FILL_COLOR_STR "gpic*saved-fill-color"
+
 void troff_output::start_picture(double sc,
                                 const position &ll, const position &ur)
 {
@@ -291,6 +294,10 @@ void troff_output::start_picture(double sc,
   // This guarantees that if the picture is used in a diversion it will
   // have the right width.
   printf("\\h'%.3fi'\n.sp -1\n", width);
+  (void) puts(".ds " SAVED_STROKE_COLOR_STR " default");
+  (void) puts(".ds " SAVED_FILL_COLOR_STR " default");
+  (void) puts(".if !'\\n[.m]'' .ds " SAVED_STROKE_COLOR_STR " \\n[.m]");
+  (void) puts(".if !'\\n[.M]'' .ds " SAVED_FILL_COLOR_STR " \\n[.M]");
 }
 
 void troff_output::finish_picture()
@@ -303,6 +310,8 @@ void troff_output::finish_picture()
   printf(".if \\n(" FILL_REG " .fi\n");
   printf(".br\n");
   printf(".nr " EQN_NO_EXTRA_SPACE_REG " 0\n");
+  (void) puts(".gcolor \\*[" SAVED_STROKE_COLOR_STR "]");
+  (void) puts(".fcolor \\*[" SAVED_FILL_COLOR_STR "]");
   // this is a little gross
   set_location(current_filename, current_lineno);
   if (want_flyback)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]