summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2017-06-14 16:01:59 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2017-06-14 16:01:59 +0000
commit9b4f34f42d59ccbd192d9895f4996d97a7ea50d2 (patch)
treebc505c4389e54ce5fe87d1af89783bbad70604da /src
parentUpdate dialog when object is added, deleted, or changed. (diff)
parent[Bug #1417470] Fix PDF+TeX output for text inside groups with clip/mask (diff)
downloadinkscape-9b4f34f42d59ccbd192d9895f4996d97a7ea50d2.tar.gz
inkscape-9b4f34f42d59ccbd192d9895f4996d97a7ea50d2.zip
Merge branch 'fix-1417470' of gitlab.com:mgmax/inkscape
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/cairo-render-context.cpp35
-rw-r--r--src/extension/internal/cairo-render-context.h1
2 files changed, 33 insertions, 3 deletions
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 21902db7d..c513744a8 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -128,7 +128,8 @@ CairoRenderContext::CairoRenderContext(CairoRenderer *parent) :
_renderer(parent),
_render_mode(RENDER_MODE_NORMAL),
_clip_mode(CLIP_MODE_MASK),
- _omittext_state(EMPTY)
+ _omittext_state(EMPTY),
+ _omittext_missing_pages(0)
{
}
@@ -884,6 +885,13 @@ CairoRenderContext::finish(void)
if (_vector_based_target)
cairo_show_page(_cr);
+ // PDF+TeX Output, see CairoRenderContext::_prepareRenderGraphic()
+ while (_omittext_missing_pages > 0) {
+ _omittext_missing_pages--;
+ g_warning("PDF+TeX output: issuing blank PDF page at end (workaround for previous error)");
+ cairo_show_page(_cr);
+ }
+
cairo_destroy(_cr);
cairo_surface_finish(_surface);
cairo_status_t status = cairo_surface_status(_surface);
@@ -1435,8 +1443,29 @@ CairoRenderContext::_prepareRenderGraphic()
// Only PDFLaTeX supports importing a single page of a graphics file,
// so only PDF backend gets interleaved text/graphics
if (_is_omittext && _target == CAIRO_SURFACE_TYPE_PDF) {
- if (_omittext_state == NEW_PAGE_ON_GRAPHIC)
- cairo_show_page(_cr);
+ if (_omittext_state == NEW_PAGE_ON_GRAPHIC) {
+ if (cairo_get_group_target(_cr) != cairo_get_target(_cr)) {
+ // we are in the middle of a group, i. e., between cairo_push_group() and cairo_pop_group().
+ // cairo_show_page() has no effect here!
+ // To ensure that the the generated TeX source doesn't try to include non-existing pages,
+ // we will later output an extra blank page.
+ // This is a workaround for bug #1417470.
+ g_warning("PDF+TeX output: Found text inside a clipped/masked group. This is not supported, the Z-order will be incorrect. Blank pages will be added to the PDF output to work around bug #1417470.");
+ _omittext_missing_pages++;
+ } else {
+ // no group is active, create new page
+ cairo_show_page(_cr);
+ // Output missing pages (workaround for the 'if' case above).
+ // With this solution, the Z-order is more wrong than necessary.
+ // It would be better to print the blank pages first, and then the actual current page.
+ // However, this isn't easily possible with cairo.
+ while (_omittext_missing_pages > 0) {
+ _omittext_missing_pages--;
+ g_warning("PDF+TeX output: issuing blank PDF page (workaround for previous error)");
+ cairo_show_page(_cr);
+ }
+ }
+ }
_omittext_state = GRAPHIC_ON_TOP;
}
}
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index dfa6084d1..9b976fd6d 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -207,6 +207,7 @@ protected:
CairoClipMode _clip_mode;
CairoOmitTextPageState _omittext_state;
+ int _omittext_missing_pages;
cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver,
Geom::OptRect const &pbox, float alpha);