[poppler] poppler/CairoFontEngine.cc poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 24 07:40:39 UTC 2023


 poppler/CairoFontEngine.cc |    2 +-
 poppler/CairoOutputDev.cc  |    6 +++---
 poppler/CairoOutputDev.h   |   12 +++++++++---
 3 files changed, 13 insertions(+), 7 deletions(-)

New commits:
commit 53115a05b7b4480ef06165199c8f1cb3982ab13d
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Tue Jan 3 10:13:52 2023 +1030

    Fix cairo rendering of color type 3 fonts
    
    The bug fix in 448f03cf needs to be disabled for color fonts.

diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index 841e9efd..538795c3 100644
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -482,7 +482,7 @@ static cairo_status_t _render_type3_glyph(cairo_scaled_font_t *scaled_font, unsi
     auto gfx = std::make_unique<Gfx>(info->doc, output_dev, resDict, &box, nullptr);
     output_dev->startDoc(info->doc, info->fontEngine);
     output_dev->startType3Render(gfx->getState(), gfx->getXRef());
-    output_dev->setInType3Char(true);
+    output_dev->setType3RenderType(color ? CairoOutputDev::Type3RenderColor : CairoOutputDev::Type3RenderMask);
     charProc = charProcs->getVal(glyph);
     if (!charProc.isStream()) {
         return CAIRO_STATUS_USER_FONT_ERROR;
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 91c05bc5..0fb7add2 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -155,7 +155,7 @@ CairoOutputDev::CairoOutputDev()
     printing = true;
     use_show_text_glyphs = false;
     inUncoloredPattern = false;
-    inType3Char = false;
+    t3_render_state = Type3RenderNone;
     t3_glyph_has_bbox = false;
     t3_glyph_has_color = false;
     text_matrix_valid = true;
@@ -888,7 +888,7 @@ void CairoOutputDev::doPath(cairo_t *c, GfxState *state, const GfxPath *path)
 
 void CairoOutputDev::stroke(GfxState *state)
 {
-    if (inType3Char) {
+    if (t3_render_state == Type3RenderMask) {
         GfxGray gray;
         state->getFillGray(&gray);
         if (colToDbl(gray) > 0.5) {
@@ -919,7 +919,7 @@ void CairoOutputDev::stroke(GfxState *state)
 
 void CairoOutputDev::fill(GfxState *state)
 {
-    if (inType3Char) {
+    if (t3_render_state == Type3RenderMask) {
         GfxGray gray;
         state->getFillGray(&gray);
         if (colToDbl(gray) > 0.5) {
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 5ce877d2..ee748540 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -263,9 +263,15 @@ public:
     }
     void copyAntialias(cairo_t *cr, cairo_t *source_cr);
 
-    void setInType3Char(bool inType3CharA)
+    enum Type3RenderType
     {
-        inType3Char = inType3CharA;
+        Type3RenderNone,
+        Type3RenderMask,
+        Type3RenderColor
+    };
+    void setType3RenderType(Type3RenderType state)
+    {
+        t3_render_state = state;
     }
     void getType3GlyphWidth(double *wx, double *wy)
     {
@@ -348,7 +354,7 @@ protected:
     int utf8Max;
     cairo_path_t *textClipPath;
     bool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2)
-    bool inType3Char; // inside a Type 3 CharProc
+    Type3RenderType t3_render_state;
     double t3_glyph_wx, t3_glyph_wy;
     bool t3_glyph_has_bbox;
     bool t3_glyph_has_color;


More information about the poppler mailing list