[gs-commits] ghostpdl branch, pdfi, updated. jbig2dec-0.14-2324-gb91eda9

[email protected] (Ken Sharp) Thu, 3 Oct 2019 13:40:14 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, pdfi has been updated
       via  b91eda99180bcd0c745ab8d4f6b15eec57cef0f3 (commit)
      from  7d0725f2275af8dbbe40e0d73992632fb7f308ba (commit)

----------------------------------------------------------------------
commit b91eda99180bcd0c745ab8d4f6b15eec57cef0f3
Author: Ken Sharp <[email protected]>
Date:   Thu Oct 3 14:39:15 2019 +0100

    Interim commit
    
    Working on clipping text rendering modes, reformatting the code in
    preparation for executing the 'draw' twice, which will be required for
    clipping modes.
    
    Noticed that the pdfwrite case (ctx->preserve_tr_mode) was swapping to
    the fill colour before drawing the text (surprisingly this is required)
    but wasn't swapping back again afterwards. This was causing some tex
    to be stored in the wrong colour in the PDF file.
    
    This shows a number of progressions, but often not clearly as the font
    is not yet imlemented.

diff --git a/pdf/pdf_text.c b/pdf/pdf_text.c
index 6ac89a1..fb2c4be 100644
--- a/pdf/pdf_text.c
+++ b/pdf/pdf_text.c
@@ -352,7 +352,29 @@ static int pdfi_show(pdf_context *ctx, pdf_string *s)
         Trmode = gs_currenttextrenderingmode(ctx->pgs);
         if (current_font->pdfi_font_type == e_pdf_font_type3 && Trmode != 0 && Trmode != 3)
             Trmode = 0;
+    } else {
+        /* CID fonts, multi-byte encodings. Not implemented yet. */
+        return 0;
+    }
 
+    if (ctx->preserve_tr_mode) {
+        if (Trmode == 3)
+            text.operation = TEXT_DO_NONE | TEXT_RENDER_MODE_3;
+        else
+            text.operation |= TEXT_DO_DRAW;
+        /* Text is filled, so select the fill colour.
+         */
+        gs_swapcolors(ctx->pgs);
+
+        code = gs_text_begin(ctx->pgs, &text, ctx->memory, &penum);
+        if (code >= 0) {
+            ctx->current_text_enum = penum;
+            code = gs_text_process(penum);
+            gs_text_release(penum, "pdfi_Tj");
+            ctx->current_text_enum = NULL;
+        }
+        gs_swapcolors(ctx->pgs);
+    } else {
         if (Trmode != 0 && Trmode != 3 && !ctx->preserve_tr_mode) {
             text.operation |= TEXT_DO_FALSE_CHARPATH;
             pdfi_gsave(ctx);
@@ -375,11 +397,7 @@ static int pdfi_show(pdf_context *ctx, pdf_string *s)
             gs_text_release(penum, "pdfi_Tj");
             ctx->current_text_enum = NULL;
         }
-    } else {
-        /* CID fonts, multi-byte encodings. Not implemented yet. */
-    }
 
-    if (!ctx->preserve_tr_mode) {
         switch(Trmode) {
             case 0:
                 /* Text has been drawn, put the colours back again */


Summary of changes:
 pdf/pdf_text.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)