[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1916-g5e60fc8

[email protected] (Michael Vrhel) Thu, 21 Nov 2019 00:03:47 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  5e60fc862a73898ce048730d0c23c00b9ddb5578 (commit)
      from  d7118262b44939688c9143c278b8c76c6c620171 (commit)

----------------------------------------------------------------------
commit 5e60fc862a73898ce048730d0c23c00b9ddb5578
Author: Michael Vrhel <[email protected]>
Date:   Wed Nov 20 15:24:28 2019 -0800

    Bug 701660  Trans. Text knockout missing ET
    
    The file has contents that look like this
    
    BT
     stuff
    BT
     stuff
    ET
    
    more stuff
    
    The first BT meets the conditions to push the text group.
    Unfortunately it is missing the ET, so the group is never popped.
    These fixes will make sure that if we are in a text group and
    encounter another BT we popped the current text group.

diff --git a/base/gdevp14.c b/base/gdevp14.c
index de3f9ca..b609e24 100644
--- a/base/gdevp14.c
+++ b/base/gdevp14.c
@@ -4641,7 +4641,11 @@ gx_update_pdf14_compositor(gx_device * pdev, gs_gstate * pgs,
             code = gx_end_transparency_group(pgs, pdev);
             break;
         case PDF14_BEGIN_TRANS_TEXT_GROUP:
-            p14dev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;
+            if (p14dev->text_group == PDF14_TEXTGROUP_BT_PUSHED) {
+                p14dev->text_group = PDF14_TEXTGROUP_MISSING_ET;
+                emprintf(p14dev->memory, "Warning: Text group pushed but no ET found\n");
+            } else
+                p14dev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;
             break;
         case PDF14_END_TRANS_TEXT_GROUP:
             if (p14dev->text_group == PDF14_TEXTGROUP_BT_PUSHED)
@@ -4812,6 +4816,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
        Special note:  If text-knockout is set to false while we are within a
        BT ET pair, we should pop the group.  I need to create a test file for
        this case.  */
+
+       /* Catch case where we already pushed a group and are trying to push another one.
+       In that case, we will pop the current one first, as we don't want to be left
+       with it. Note that if we have a BT and no other BTs or ETs then this issue
+       will not be caught until we do the put_image and notice that the stack is not
+       empty. */
+    if (pdev->text_group == PDF14_TEXTGROUP_MISSING_ET) {
+        code = gs_end_transparency_group(pgs);
+        if (code < 0)
+            return code;
+        pdev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;
+    }
+
     if (gs_currenttextknockout(pgs) && (blend_issue || opacity != 1.0) &&
         gs_currenttextrenderingmode(pgs) != 3 && /* don't bother with invisible text */
         pdev->text_group == PDF14_TEXTGROUP_BT_NOT_PUSHED)
@@ -8554,7 +8571,11 @@ pdf14_clist_create_compositor(gx_device	* dev, gx_device ** pcdev,
                   So, if needed change the masks bounding box at this time */
                 break;
             case PDF14_BEGIN_TRANS_TEXT_GROUP:
-                pdev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;
+                if (pdev->text_group == PDF14_TEXTGROUP_BT_PUSHED) {
+                    emprintf(pdev->memory, "Warning: Text group pushed but no ET found\n");
+                    pdev->text_group = PDF14_TEXTGROUP_MISSING_ET;
+                } else
+                    pdev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;
                 *pcdev = dev;
                 return 0; /* Never put into clist. Only used during writing */
             case PDF14_END_TRANS_TEXT_GROUP:
@@ -9083,6 +9104,18 @@ pdf14_clist_text_begin(gx_device * dev,	gs_gstate	* pgs,
     if (code < 0)
         return code;
 
+   /* Catch case where we already pushed a group and are trying to push another one.
+   In that case, we will pop the current one first, as we don't want to be left
+   with it. Note that if we have a BT and no other BTs or ETs then this issue
+   will not be caught until we do the put_image and notice that the stack is not
+   empty. */
+    if (pdev->text_group == PDF14_TEXTGROUP_MISSING_ET) {
+        code = gs_end_transparency_group(pgs);
+        if (code < 0)
+            return code;
+        pdev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;
+    }
+
     /* We may need to push a non-isolated transparency group if the following
     is true.
     1) We are not currently in one that we pushed for text.  This is
diff --git a/base/gstrans.h b/base/gstrans.h
index 0c9a3cd..1868517 100644
--- a/base/gstrans.h
+++ b/base/gstrans.h
@@ -81,7 +81,8 @@ typedef enum {
 typedef enum {
     PDF14_TEXTGROUP_NO_BT,  /* We are not in a BT/ET.  Avoids Annotation Texts */
     PDF14_TEXTGROUP_BT_NOT_PUSHED, /* We are in a BT/ET but no group pushed */
-    PDF14_TEXTGROUP_BT_PUSHED   /* We are in a BT/ET section and group was pushed */
+    PDF14_TEXTGROUP_BT_PUSHED,   /* We are in a BT/ET section and group was pushed */
+    PDF14_TEXTGROUP_MISSING_ET   /* We pushed a group already and then had another BT occur */
 } pdf14_text_group_state;
 
 typedef struct gs_transparency_source_s {


Summary of changes:
 base/gdevp14.c | 37 +++++++++++++++++++++++++++++++++++--
 base/gstrans.h |  3 ++-
 2 files changed, 37 insertions(+), 3 deletions(-)