[poppler] 2 commits - poppler/CairoFontEngine.cc poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 4 11:37:24 UTC 2022


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

New commits:
commit 7f2b2964297e4d381b43ad5710540fedfe216a2c
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Mar 19 17:59:39 2022 +1030

    Fix clang warning

diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index 1da0bfdc..efde742a 100644
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -588,8 +588,9 @@ static cairo_status_t _render_type3_glyph(cairo_scaled_font_t *scaled_font, unsi
     }
 
     status = CAIRO_STATUS_SUCCESS;
-    if (color && !output_dev->hasColor())
+    if (color && !output_dev->hasColor()) {
         status = CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED;
+    }
 
     delete gfx;
     delete output_dev;
commit 61f6d6d1492b9a8bfa19dfe4bfa4a7294a9a29bd
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Mar 19 15:06:58 2022 +1030

    Cairo color type 3 fonts
    
    Fixes #729
    Fixes #944

diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index 759c61b0..1da0bfdc 100644
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -519,7 +519,7 @@ static cairo_status_t _init_type3_glyph(cairo_scaled_font_t *scaled_font, cairo_
     return CAIRO_STATUS_SUCCESS;
 }
 
-static cairo_status_t _render_type3_glyph(cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics)
+static cairo_status_t _render_type3_glyph(cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics, bool color)
 {
     Dict *charProcs;
     Object charProc;
@@ -530,6 +530,7 @@ static cairo_status_t _render_type3_glyph(cairo_scaled_font_t *scaled_font, unsi
     PDFRectangle box;
     type3_font_info_t *info;
     Gfx *gfx;
+    cairo_status_t status;
 
     info = (type3_font_info_t *)cairo_font_face_get_user_data(cairo_scaled_font_get_font_face(scaled_font), &type3_font_key);
 
@@ -586,10 +587,26 @@ static cairo_status_t _render_type3_glyph(cairo_scaled_font_t *scaled_font, unsi
         metrics->height = bbox[3] - bbox[1];
     }
 
+    status = CAIRO_STATUS_SUCCESS;
+    if (color && !output_dev->hasColor())
+        status = CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED;
+
     delete gfx;
     delete output_dev;
 
-    return CAIRO_STATUS_SUCCESS;
+    return status;
+}
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 17, 6)
+static cairo_status_t _render_type3_color_glyph(cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics)
+{
+    return _render_type3_glyph(scaled_font, glyph, cr, metrics, true);
+}
+#endif
+
+static cairo_status_t _render_type3_noncolor_glyph(cairo_scaled_font_t *scaled_font, unsigned long glyph, cairo_t *cr, cairo_text_extents_t *metrics)
+{
+    return _render_type3_glyph(scaled_font, glyph, cr, metrics, false);
 }
 
 CairoType3Font *CairoType3Font::create(const std::shared_ptr<const GfxFont> &gfxFont, PDFDoc *doc, CairoFontEngine *fontEngine, bool printing, XRef *xref)
@@ -605,7 +622,10 @@ CairoType3Font *CairoType3Font::create(const std::shared_ptr<const GfxFont> &gfx
     ref = *gfxFont->getID();
     font_face = cairo_user_font_face_create();
     cairo_user_font_face_set_init_func(font_face, _init_type3_glyph);
-    cairo_user_font_face_set_render_glyph_func(font_face, _render_type3_glyph);
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 17, 6)
+    cairo_user_font_face_set_render_color_glyph_func(font_face, _render_type3_color_glyph);
+#endif
+    cairo_user_font_face_set_render_glyph_func(font_face, _render_type3_noncolor_glyph);
     type3_font_info_t *info = new type3_font_info_t(gfxFont, doc, fontEngine, printing, xref);
 
     cairo_font_face_set_user_data(font_face, &type3_font_key, (void *)info, _free_type3_font_info);
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index f6a005f6..d51ae4e6 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -156,6 +156,7 @@ CairoOutputDev::CairoOutputDev()
     inUncoloredPattern = false;
     inType3Char = false;
     t3_glyph_has_bbox = false;
+    has_color = false;
     text_matrix_valid = true;
 
     groupColorSpaceStack = nullptr;
@@ -545,6 +546,7 @@ void CairoOutputDev::updateFillColor(GfxState *state)
 
         LOG(printf("fill color: %d %d %d\n", fill_color.r, fill_color.g, fill_color.b));
     }
+    has_color = true;
 }
 
 void CairoOutputDev::updateStrokeColor(GfxState *state)
@@ -562,6 +564,7 @@ void CairoOutputDev::updateStrokeColor(GfxState *state)
 
         LOG(printf("stroke color: %d %d %d\n", stroke_color.r, stroke_color.g, stroke_color.b));
     }
+    has_color = true;
 }
 
 void CairoOutputDev::updateFillOpacity(GfxState *state)
@@ -613,6 +616,7 @@ void CairoOutputDev::updateFillColorStop(GfxState *state, double offset)
     auto opacity = (state->getStrokePattern()) ? state->getStrokeOpacity() : state->getFillOpacity();
 
     cairo_pattern_add_color_stop_rgba(fill_pattern, offset, colToDbl(fill_color.r), colToDbl(fill_color.g), colToDbl(fill_color.b), opacity);
+    has_color = true;
     LOG(printf("fill color stop: %f (%d, %d, %d, %d)\n", offset, fill_color.r, fill_color.g, fill_color.b, dblToCol(opacity)));
 }
 
@@ -2845,6 +2849,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
 
     cairo_pattern_destroy(maskPattern);
     cairo_pattern_destroy(pattern);
+    has_color = true;
 
 cleanup:
     imgStr->close();
@@ -3499,6 +3504,7 @@ void CairoImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, i
         setCairo(nullptr);
         cairo_surface_destroy(surface);
         cairo_destroy(cr);
+        has_color = true;
     }
 }
 
@@ -3556,5 +3562,6 @@ void CairoImageOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *
         setCairo(nullptr);
         cairo_surface_destroy(surface);
         cairo_destroy(cr);
+        has_color = true;
     }
 }
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 9a3bb7dc..75f28748 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -249,6 +249,7 @@ public:
     }
     bool hasType3GlyphBBox() { return t3_glyph_has_bbox; }
     double *getType3GlyphBBox() { return t3_glyph_bbox; }
+    bool hasColor() { return has_color; }
 
 protected:
     void doPath(cairo_t *cairo, GfxState *state, const GfxPath *path);
@@ -316,6 +317,7 @@ protected:
     bool inType3Char; // inside a Type 3 CharProc
     double t3_glyph_wx, t3_glyph_wy;
     bool t3_glyph_has_bbox;
+    bool has_color;
     double t3_glyph_bbox[4];
     bool prescaleImages;
 


More information about the poppler mailing list