summarylogtreecommitdiffstats
path: root/0003-Apply-subpixel-rendering-in-Cairo-Backend.patch
diff options
context:
space:
mode:
authorPaul Gideon Dann2020-07-15 16:04:23 +0100
committerPaul Gideon Dann2020-07-15 16:05:51 +0100
commita67dc9ea6e5f7c916f876dc1082c4359e16ed2e0 (patch)
tree9d137e7f7fbdfaeb702b72f841f882ee5eac8a87 /0003-Apply-subpixel-rendering-in-Cairo-Backend.patch
parent4a4e77849cd1fd9fe961bfbae422d3526b57af22 (diff)
downloadaur-a67dc9ea6e5f7c916f876dc1082c4359e16ed2e0.tar.gz
Update for Poppler 0.90.1
Diffstat (limited to '0003-Apply-subpixel-rendering-in-Cairo-Backend.patch')
-rw-r--r--0003-Apply-subpixel-rendering-in-Cairo-Backend.patch299
1 files changed, 0 insertions, 299 deletions
diff --git a/0003-Apply-subpixel-rendering-in-Cairo-Backend.patch b/0003-Apply-subpixel-rendering-in-Cairo-Backend.patch
deleted file mode 100644
index 5973df5f42a9..000000000000
--- a/0003-Apply-subpixel-rendering-in-Cairo-Backend.patch
+++ /dev/null
@@ -1,299 +0,0 @@
-From f7b6ba8787b2bf6c0a9c9f3b7465c88e0c9ece08 Mon Sep 17 00:00:00 2001
-From: Paul Gideon Dann <pdgiddie@gmail.com>
-Date: Tue, 9 Aug 2016 15:02:53 +0100
-Subject: [PATCH 3/4] Apply subpixel rendering in Cairo Backend
-
-Source:
-https://github.com/zhou13/poppler-subpixel/blob/master/poppler/poppler-subpixel.patch
----
- glib/demo/render.c | 25 ++++++++++++++++++++---
- glib/poppler-page.cc | 10 ++++++++++
- glib/poppler-page.h | 1 +
- poppler/CairoFontEngine.cc | 6 +++---
- poppler/CairoOutputDev.cc | 24 ++++++++++++++++++++++
- poppler/Gfx.cc | 41 ++++++++++++++++++++++++++++++++++++++
- poppler/Gfx.h | 3 +++
- poppler/Page.cc | 13 ++++++++++++
- poppler/Page.h | 3 +++
- 9 files changed, 120 insertions(+), 6 deletions(-)
-
-diff --git a/glib/demo/render.c b/glib/demo/render.c
-index 78d24bb5..d482ceb5 100644
---- a/glib/demo/render.c
-+++ b/glib/demo/render.c
-@@ -82,12 +82,14 @@ pgd_render_start (GtkButton *button,
- PgdRenderDemo *demo)
- {
- PopplerPage *page;
-+ gboolean subpixel_rendering;
- gdouble page_width, page_height;
- gdouble width, height;
- gint x, y;
- gchar *str;
- GTimer *timer;
- cairo_t *cr;
-+ cairo_font_options_t *fo;
-
- page = poppler_document_get_page (demo->doc, demo->page);
- if (!page)
-@@ -116,6 +118,21 @@ pgd_render_start (GtkButton *button,
- width, height);
- cr = cairo_create (demo->surface);
-
-+ fo = cairo_font_options_create ();
-+ cairo_get_font_options (cr, fo);
-+
-+ subpixel_rendering = poppler_page_support_subpixel_rendering (page);
-+ printf("subpixel_rendering %d\n", subpixel_rendering);
-+ if (subpixel_rendering) {
-+ cairo_set_source_rgb (cr, 1., 1., 1.);
-+ cairo_paint (cr);
-+ cairo_font_options_set_antialias (fo, CAIRO_ANTIALIAS_SUBPIXEL);
-+ cairo_font_options_set_subpixel_order (fo, CAIRO_SUBPIXEL_ORDER_RGB);
-+ }
-+
-+ cairo_set_font_options (cr, fo);
-+ cairo_font_options_destroy (fo);
-+
- cairo_save (cr);
- switch (demo->rotate) {
- case 90:
-@@ -143,9 +160,11 @@ pgd_render_start (GtkButton *button,
- poppler_page_render (page, cr);
- cairo_restore (cr);
-
-- cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
-- cairo_set_source_rgb (cr, 1., 1., 1.);
-- cairo_paint (cr);
-+ if (!subpixel_rendering) {
-+ cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
-+ cairo_set_source_rgb (cr, 1., 1., 1.);
-+ cairo_paint (cr);
-+ }
-
- g_timer_stop (timer);
-
-diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
-index f237bb69..73afea17 100644
---- a/glib/poppler-page.cc
-+++ b/glib/poppler-page.cc
-@@ -2693,3 +2693,13 @@ poppler_page_get_text_attributes_for_area (PopplerPage *page,
-
- return g_list_reverse(attributes);
- }
-+
-+gboolean
-+poppler_page_support_subpixel_rendering (PopplerPage *page)
-+{
-+ CairoOutputDev *output_dev;
-+ g_return_val_if_fail (POPPLER_IS_PAGE (page), FALSE);
-+
-+ output_dev = page->document->output_dev;
-+ return page->page->supportSubpixelRendering(output_dev);
-+}
-diff --git a/glib/poppler-page.h b/glib/poppler-page.h
-index 0ffc50c6..6fc75d92 100644
---- a/glib/poppler-page.h
-+++ b/glib/poppler-page.h
-@@ -150,6 +150,7 @@ void poppler_page_free_text_attributes (GList *li
- POPPLER_PUBLIC
- GList * poppler_page_get_text_attributes_for_area (PopplerPage *page,
- PopplerRectangle *area);
-+gboolean poppler_page_support_subpixel_rendering (PopplerPage *page);
-
- /* A rectangle on a page, with coordinates in PDF points. */
- #define POPPLER_TYPE_RECTANGLE (poppler_rectangle_get_type ())
-diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
-index 1f637cf5..3de0a45e 100644
---- a/poppler/CairoFontEngine.cc
-+++ b/poppler/CairoFontEngine.cc
-@@ -124,7 +124,7 @@ CairoFont::getSubstitutionCorrection(GfxFont *gfxFont)
- cairo_matrix_t m;
- cairo_matrix_init_identity(&m);
- cairo_font_options_t *options = cairo_font_options_create();
-- cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
-+ cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_SLIGHT);
- cairo_font_options_set_hint_metrics(options, CAIRO_HINT_METRICS_OFF);
- cairo_scaled_font_t *scaled_font = cairo_scaled_font_create(cairo_font_face, &m, &m, options);
-
-@@ -182,7 +182,7 @@ _ft_new_face_uncached (FT_Library lib,
- }
-
- font_face = cairo_ft_font_face_create_for_ft_face (face,
-- FT_LOAD_NO_HINTING |
-+ FT_LOAD_TARGET_LIGHT |
- FT_LOAD_NO_BITMAP);
- if (cairo_font_face_set_user_data (font_face,
- &_ft_cairo_key,
-@@ -351,7 +351,7 @@ _ft_new_face (FT_Library lib,
- _ft_open_faces = l;
-
- l->font_face = cairo_ft_font_face_create_for_ft_face (tmpl.face,
-- FT_LOAD_NO_HINTING |
-+ FT_LOAD_TARGET_LIGHT |
- FT_LOAD_NO_BITMAP);
- if (cairo_font_face_set_user_data (l->font_face,
- &_ft_cairo_key,
-diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
-index 83f1c78d..7f1442f1 100644
---- a/poppler/CairoOutputDev.cc
-+++ b/poppler/CairoOutputDev.cc
-@@ -205,6 +205,13 @@ void CairoOutputDev::setCairo(cairo_t *c)
- }
- if (c != nullptr) {
- cairo = cairo_reference (c);
-+ {
-+ cairo_font_options_t *options = cairo_font_options_create ();
-+ cairo_get_font_options (cairo, options);
-+ cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_SUBPIXEL);
-+ cairo_set_font_options (cairo, options);
-+ cairo_font_options_destroy (options);
-+ }
- /* save the initial matrix so that we can use it for type3 fonts. */
- //XXX: is this sufficient? could we miss changes to the matrix somehow?
- cairo_get_matrix(cairo, &orig_matrix);
-@@ -1455,6 +1462,7 @@ void CairoOutputDev::drawChar(GfxState *state, double x, double y,
- void CairoOutputDev::endString(GfxState *state)
- {
- int render;
-+ GfxFontType fontType;
-
- if (!currentFont)
- return;
-@@ -1472,6 +1480,18 @@ void CairoOutputDev::endString(GfxState *state)
- goto finish;
- }
-
-+ fontType = state->getFont()->getType();
-+ // Do not enable subpixel rendering for type3 font
-+ // For some reason it does not work
-+ if (fontType == fontType3) {
-+ cairo_save(cairo);
-+ cairo_font_options_t *fo;
-+ fo = cairo_font_options_create ();
-+ cairo_get_font_options (cairo, fo);
-+ cairo_font_options_set_antialias (fo, CAIRO_ANTIALIAS_DEFAULT);
-+ cairo_set_font_options (cairo, fo);
-+ }
-+
- if (!(render & 1)) {
- LOG (printf ("fill string\n"));
- cairo_set_source (cairo, fill_pattern);
-@@ -1522,6 +1542,10 @@ void CairoOutputDev::endString(GfxState *state)
- }
-
- finish:
-+ // pair with the previous cairo_save to disable subpixel rendering for type3 fonts
-+ if (fontType == fontType3) {
-+ cairo_restore(cairo);
-+ }
- gfree (glyphs);
- glyphs = nullptr;
- if (use_show_text_glyphs) {
-diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
-index 37a8996a..7f75efb1 100644
---- a/poppler/Gfx.cc
-+++ b/poppler/Gfx.cc
-@@ -4597,6 +4597,47 @@ void Gfx::doImage(Object *ref, Stream *str, bool inlineImg) {
- error(errSyntaxError, getPos(), "Bad image parameters");
- }
-
-+bool Gfx::checkNormalBlendModeOnly(Object *str) {
-+ printf("check blender mode start\n");
-+ Object args[maxArgs];
-+ int numArgs;
-+ bool onlyNormalBlendMode;
-+ Parser myParser(xref, str, false);
-+
-+ numArgs = 0;
-+ onlyNormalBlendMode = true;
-+
-+ Object obj = myParser.getObj();
-+ while (!obj.isEOF()) {
-+ if (obj.isCmd()) {
-+ const char* cmd = obj.getCmd();
-+
-+ if (strcmp(cmd, "gs") == 0) {
-+ GfxBlendMode mode;
-+ Object obj1 = res->lookupGState(args[0].getName());
-+ if (!obj1.isNull()) {
-+ Object obj2 = obj1.dictLookup("BM");
-+ if (!obj2.isNull()) {
-+ if (state->parseBlendMode(&obj2, &mode)) {
-+ printf("check blend mode: %d\n", mode);
-+ onlyNormalBlendMode &= (mode == gfxBlendNormal);
-+ }
-+ }
-+ }
-+ }
-+
-+ numArgs = 0;
-+ } else if (numArgs < maxArgs) {
-+ args[numArgs++] = obj.copy();
-+ }
-+
-+ obj = myParser.getObj();
-+ }
-+
-+ return onlyNormalBlendMode;
-+}
-+
-+
- bool Gfx::checkTransparencyGroup(Dict *resDict) {
- // check the effect of compositing objects as a group:
- // look for ExtGState entries with ca != 1 or CA != 1 or BM != normal
-diff --git a/poppler/Gfx.h b/poppler/Gfx.h
-index e8ff605f..f615d789 100644
---- a/poppler/Gfx.h
-+++ b/poppler/Gfx.h
-@@ -193,6 +193,9 @@ public:
- // Get the current graphics state object.
- GfxState *getState() { return state; }
-
-+ // Check whether a stream only contains normal blend mode (to enable subpixel rendering)
-+ bool checkNormalBlendModeOnly(Object *str);
-+
- bool checkTransparencyGroup(Dict *resDict);
-
- void drawForm(Object *str, Dict *resDict, const double *matrix, const double *bbox,
-diff --git a/poppler/Page.cc b/poppler/Page.cc
-index a875f7bd..c296555a 100644
---- a/poppler/Page.cc
-+++ b/poppler/Page.cc
-@@ -342,6 +342,19 @@ Dict *Page::getResourceDictCopy(XRef *xrefA) {
- return dict ? dict->copy(xrefA) : nullptr;
- }
-
-+bool Page::supportSubpixelRendering(OutputDev *out) {
-+ bool supported = false;
-+ PDFRectangle box;
-+
-+ Object obj = contents.fetch(xref);
-+ if (!obj.isNull()) {
-+ Gfx gfx(doc, out, attrs->getResourceDict(), &box, nullptr);
-+ supported = gfx.checkNormalBlendModeOnly(&obj);
-+ }
-+
-+ return supported;
-+}
-+
- void Page::replaceXRef(XRef *xrefA) {
- Dict *pageDict = pageObj.getDict()->copy(xrefA);
- xref = xrefA;
-diff --git a/poppler/Page.h b/poppler/Page.h
-index 2b19a089..57ead29c 100644
---- a/poppler/Page.h
-+++ b/poppler/Page.h
-@@ -187,6 +187,9 @@ public:
- Object *getResourceDictObject();
- Dict *getResourceDictCopy(XRef *xrefA);
-
-+ // Whether the content in this page supports subpixel rendering (lcdfilter)
-+ bool supportSubpixelRendering(OutputDev *out);
-+
- // Get annotations array.
- Object getAnnotsObject(XRef *xrefA = nullptr) { return annotsObj.fetch(xrefA ? xrefA : xref); }
- // Add a new annotation to the page
---
-2.27.0
-