summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 403939b)
raw | patch | inline | side by side (parent: 403939b)
author | theadib <theadib@users.sourceforge.net> | |
Wed, 26 Dec 2007 02:31:57 +0000 (02:31 +0000) | ||
committer | theadib <theadib@users.sourceforge.net> | |
Wed, 26 Dec 2007 02:31:57 +0000 (02:31 +0000) |
index 4e7f54c8610930d2d0eb1b5e1e24039e9970fe3e..b09b4a2fb8b7deabfafd7a4dddeba1fe691eb3a5 100644 (file)
@@ -109,9 +109,17 @@ CairoPdfOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const g
if (ext == NULL)
return;
+ bool old_textToPath = ext->get_param_bool("textToPath");
+ bool new_textToPath = mod->get_param_bool("textToPath");
+ ext->set_param_bool("textToPath", new_textToPath);
+
+ bool old_blurToBitmap = ext->get_param_bool("blurToBitmap");
+ bool new_blurToBitmap = mod->get_param_bool("blurToBitmap");
+ ext->set_param_bool("blurToBitmap", new_blurToBitmap);
+
gchar * final_name;
final_name = g_strdup_printf("> %s", uri);
- ret = pdf_print_document_to_file(doc, final_name);
+ ret = pdf_print_document_to_file(doc, final_name, 0, new_textToPath, new_blurToBitmap);
g_free(final_name);
if (!ret)
"<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version") "\" type=\"enum\" >\n"
"<item value='PDF14'>" N_("PDF 1.4") "</item>\n"
"</param>\n"
+ "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">true</param>\n"
"<param name=\"blurToBitmap\" gui-text=\"" N_("Convert blur effects to bitmaps") "\" type=\"boolean\">false</param>\n"
"<output>\n"
"<extension>.pdf</extension>\n"
"<mimetype>application/pdf</mimetype>\n"
- "<filetypename>Cairo PDF (*.pdf)</filetypename>\n"
+ "<filetypename>PDF via Cairo (*.pdf)</filetypename>\n"
"<filetypetooltip>PDF File</filetypetooltip>\n"
"</output>\n"
"</inkscape-extension>", new CairoPdfOutput());
index 06e0f92c6144e0c23c289f050c4b2d4579f94841..5681fda5e8da23e56869b409a77d997ebdf4c057 100644 (file)
}
static bool
-ps_print_document_to_file(SPDocument *doc, gchar const *filename)
+ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool filtertobitmap)
{
CairoRenderer *renderer;
CairoRenderContext *ctx;
/* Create renderer and context */
renderer = new CairoRenderer();
ctx = renderer->createContext();
+ ctx->setPSLevel(level);
+ ctx->setTextToPath(texttopath);
+ ctx->setFilterToBitmap(filtertobitmap);
+
bool ret = ctx->setPsTarget(filename);
if(ret) {
/* Render document */
@@ -106,18 +110,24 @@ CairoPsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gc
if (ext == NULL)
return;
+ const gchar *old_level = ext->get_param_enum("PSlevel");
+ const gchar *new_level = mod->get_param_enum("PSlevel");
+ int level = 1;
+
bool old_textToPath = ext->get_param_bool("textToPath");
- bool new_val = mod->get_param_bool("textToPath");
- ext->set_param_bool("textToPath", new_val);
+ bool new_textToPath = mod->get_param_bool("textToPath");
+ ext->set_param_bool("textToPath", new_textToPath);
bool old_blurToBitmap = ext->get_param_bool("blurToBitmap");
- new_val = mod->get_param_bool("blurToBitmap");
- ext->set_param_bool("blurToBitmap", new_val);
+ bool new_blurToBitmap = mod->get_param_bool("blurToBitmap");
+ ext->set_param_bool("blurToBitmap", new_blurToBitmap);
+ if(g_ascii_strcasecmp("PS2", new_level) == 0)
+ level = 0;
gchar * final_name;
final_name = g_strdup_printf("> %s", uri);
- ret = ps_print_document_to_file(doc, final_name);
+ ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap);
g_free(final_name);
ext->set_param_bool("blurToBitmap", old_blurToBitmap);
"<name>Cairo PS Output</name>\n"
"<id>org.inkscape.print.ps.cairo</id>\n"
"<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level") "\" type=\"enum\" >\n"
+ "<item value='PS3'>" N_("PostScript 3") "</item>\n"
#if (CAIRO_VERSION >= 010502)
"<item value='PS2'>" N_("PostScript level 2") "</item>\n"
#endif
- "<item value='PS3'>" N_("PostScript 3") "</item>\n"
"</param>\n"
"<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">true</param>\n"
"<param name=\"blurToBitmap\" gui-text=\"" N_("Convert blur effects to bitmaps") "\" type=\"boolean\">false</param>\n"
"<output>\n"
"<extension>.ps</extension>\n"
"<mimetype>application/ps</mimetype>\n"
- "<filetypename>Cairo PS (*.ps)</filetypename>\n"
- "<filetypetooltip>PS File</filetypetooltip>\n"
+ "<filetypename>PostScript via Cairo (*.ps)</filetypename>\n"
+ "<filetypetooltip>PostScript File</filetypetooltip>\n"
"</output>\n"
"</inkscape-extension>", new CairoPsOutput());
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 8511973e408879bd48837090c50e07d5316b0d87..228f596dd375ca89bad540c6396ef1f7f93e289d 100644 (file)
@@ -104,6 +104,10 @@ static cairo_status_t _write_callback(void *closure, const unsigned char *data,
CairoRenderContext::CairoRenderContext(CairoRenderer *parent) :
_dpi(72),
+ _pdf_level(0),
+ _ps_level(1),
+ _is_texttopath(FALSE),
+ _is_filtertobitmap(FALSE),
_stream(NULL),
_is_valid(FALSE),
_vector_based_target(FALSE),
// only opacity & overflow is stored for now
_state->opacity = SP_SCALE24_TO_FLOAT(style->opacity.value);
_state->has_overflow = (style->overflow.set && style->overflow.value != SP_CSS_OVERFLOW_VISIBLE);
+ _state->has_filtereffect = (style->filter.set != 0) ? TRUE : FALSE;
if (style->fill.isPaintserver() || style->stroke.isPaintserver())
_state->merge_opacity = FALSE;
return true;
}
+void CairoRenderContext::setPSLevel(unsigned int level)
+{
+ _ps_level = level;
+}
+
+void CairoRenderContext::setPDFLevel(unsigned int level)
+{
+ _pdf_level = level;
+}
+
+void CairoRenderContext::setTextToPath(bool texttopath)
+{
+ _is_texttopath = texttopath;
+}
+
+void CairoRenderContext::setFilterToBitmap(bool filtertobitmap)
+{
+ _is_filtertobitmap = filtertobitmap;
+}
+
cairo_surface_t*
CairoRenderContext::getSurface(void)
{
CairoRenderState *state = (CairoRenderState*)g_malloc(sizeof(CairoRenderState));
g_assert( state != NULL );
+ state->has_filtereffect = FALSE;
state->merge_opacity = TRUE;
state->opacity = 1.0;
state->need_layer = FALSE;
#ifdef CAIRO_HAS_PS_SURFACE
case CAIRO_SURFACE_TYPE_PS:
surface = cairo_ps_surface_create_for_stream(Inkscape::Extension::Internal::_write_callback, _stream, width, height);
+#if (CAIRO_VERSION >= 010502)
+ cairo_ps_surface_restrict_to_level (surface, (cairo_ps_level_t)_ps_level);
+#endif
break;
#endif
default:
@@ -1344,7 +1373,7 @@ CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoG
i++;
}
- if (is_stroke)
+ if (is_stroke || _is_texttopath)
cairo_glyph_path(cr, glyphs, num_glyphs - num_invalid_glyphs);
else
cairo_show_glyphs(cr, glyphs, num_glyphs - num_invalid_glyphs);
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index e3cbbad8aa211d1ee007987f85e70ede50c3f5a2..58b0a10e2812b814c92ab75204f68686e1004291 100644 (file)
* Miklos Erdelyi <erdelyim@gmail.com>
*
* Copyright (C) 2006 Miklos Erdelyi
- *
+ *
* Licensed under GNU GPL
*/
unsigned int has_overflow : 1;
unsigned int parent_has_userspace : 1; // whether the parent's ctm should be applied
float opacity;
+ bool has_filtereffect;
SPClipPath *clip_path;
SPMask* mask;
RENDER_MODE_NORMAL,
RENDER_MODE_CLIP
};
-
+
typedef enum CairoClipMode {
CLIP_MODE_PATH,
CLIP_MODE_MASK
};
-
+
bool setImageTarget(cairo_format_t format);
bool setPdfTarget(gchar const *utf8_fn);
bool setPsTarget(gchar const *utf8_fn);
/** Set the cairo_surface_t from an external source */
bool setSurfaceTarget(cairo_surface_t *surface, bool is_vector);
+ void setPSLevel(unsigned int level);
+ void setPDFLevel(unsigned int level);
+ void setTextToPath(bool texttopath);
+ void setFilterToBitmap(bool filtertobitmap);
+
/** Creates the cairo_surface_t for the context with the
given width, height and with the currently set target
surface type. */
CairoRenderMode getRenderMode(void) const;
void setClipMode(CairoClipMode mode);
CairoClipMode getClipMode(void) const;
-
+
void addBpath(NArtBpath const *bp);
void setBpath(NArtBpath const *bp);
-
+
void pushLayer(void);
void popLayer(void);
protected:
CairoRenderContext(CairoRenderer *renderer);
virtual ~CairoRenderContext(void);
-
+
float _width;
float _height;
unsigned short _dpi;
-
+ unsigned int _pdf_level;
+ unsigned int _ps_level;
+ bool _is_texttopath;
+ bool _is_filtertobitmap;
+
FILE *_stream;
-
+
unsigned int _is_valid : 1;
unsigned int _vector_based_target : 1;
cairo_surface_type_t _target;
cairo_format_t _target_format;
PangoLayout *_layout;
-
+
unsigned int _clip_rule : 8;
unsigned int _clip_winding_failed : 1;
-
+
GSList *_state_stack;
CairoRenderState *_state; // the current state
-
+
CairoRenderer *_renderer;
CairoRenderMode _render_mode;
cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver,
NRRect const *pbox, float alpha);
cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox);
-
+
unsigned int _showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoGlyphInfo> const &glyphtext, bool is_stroke);
bool _finishSurfaceSetup(cairo_surface_t *surface);
void _setFillStyle(SPStyle const *style, NRRect const *pbox);
void _setStrokeStyle(SPStyle const *style, NRRect const *pbox);
-
+
void _initCairoMatrix(cairo_matrix_t *matrix, NRMatrix const *transform);
void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0);
void _concatTransform(cairo_t *cr, NRMatrix const *transform);
index 418e82b894d260fedf7ee507b65a13b81a289be9..dbb89818317fe443a895841a1f96c6715f0bdcd1 100644 (file)
* Miklos Erdelyi <erdelyim@gmail.com>
*
* Copyright (C) 2006 Miklos Erdelyi
- *
+ *
* Licensed under GNU GPL
*/
void
CairoRenderer::destroyContext(CairoRenderContext *ctx)
{
- delete ctx;
+ delete ctx;
}
/*
SPGroup *group = SP_GROUP(item);
CairoRenderer *renderer = ctx->getRenderer();
TRACE(("group op: %f\n", SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value)));
-
+
GSList *l = g_slist_reverse(group->childList(false));
while (l) {
SPObject *o = SP_OBJECT (l->data);
if (SP_IS_ITEM(o)) {
renderer->renderItem (ctx, SP_ITEM (o));
- }
+ }
l = g_slist_remove (l, o);
}
}
calculatePreserveAspectRatio (image->aspect_align, image->aspect_clip, (double)w, (double)h,
&x, &y, &width, &height);
}
-
+
if (image->aspect_clip == SP_ASPECT_SLICE && !ctx->getCurrentState()->has_overflow) {
ctx->addClippingRect(image->x.computed, image->y.computed, image->width.computed, image->height.computed);
}
- nr_matrix_set_translate (&tp, x, y);
+ nr_matrix_set_translate (&tp, x, y);
nr_matrix_set_scale (&s, width / (double)w, height / (double)h);
nr_matrix_multiply (&t, &s, &tp);
SPSymbol *symbol = SP_SYMBOL(item);
if (!SP_OBJECT_IS_CLONED (symbol))
return;
-
+
/* Cloned <symbol> is actually renderable */
ctx->pushState();
ctx->transform(&symbol->c2p);
-
+
// apply viewbox if set
if (0 /*symbol->viewBox_set*/) {
NRMatrix vb2user;
y = 0.0;
width = 1.0;
height = 1.0;
-
+
view_width = symbol->viewBox.x1 - symbol->viewBox.x0;
view_height = symbol->viewBox.y1 - symbol->viewBox.y0;
-
+
calculatePreserveAspectRatio(symbol->aspect_align, symbol->aspect_clip, view_width, view_height,
&x, &y,&width, &height);
ctx->transform(&vb2user);
}
-
+
sp_group_render(item, ctx);
ctx->popState();
}
static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx)
{
+ /*
+ if(ctx->_state->has_filtereffect)
+ printf("\nhas filtereffects");
+ */
+
if (SP_IS_ROOT(item)) {
TRACE(("root\n"));
return sp_root_render(item, ctx);
{
SPStyle const *style = SP_OBJECT_STYLE(item);
ctx->setStateForStyle(style);
-
+
CairoRenderState *state = ctx->getCurrentState();
state->clip_path = item->clip_ref->getObject();
state->mask = item->mask_ref->getObject();
{
ctx->pushState();
setStateForItem(ctx, item);
-
+
CairoRenderState *state = ctx->getCurrentState();
state->need_layer = ( state->mask || state->clip_path || state->opacity != 1.0 );
}
}
TRACE(("%f x %f\n", ctx->_width, ctx->_height));
-
+
return ctx->setupSurface(d.x1-d.x0, d.y1-d.y0);
}
CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
{
g_assert( ctx != NULL && ctx->_is_valid );
-
+
if (cp == NULL)
return;
-
+
CairoRenderContext::CairoRenderMode saved_mode = ctx->getRenderMode();
ctx->setRenderMode(CairoRenderContext::RENDER_MODE_CLIP);
CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask)
{
g_assert( ctx != NULL && ctx->_is_valid );
-
+
if (mask == NULL)
return;
@@ -539,7 +544,7 @@ calculatePreserveAspectRatio(unsigned int aspect_align, unsigned int aspect_clip
{
if (aspect_align == SP_ASPECT_NONE)
return;
-
+
double scalex, scaley, scale;
double new_width, new_height;
scalex = *width / vp_width;
index dc60af4dd68bf2097dacb6955450bb931e4dcbb0..d59e246b092e1e9c468c4235ba54dddbaa908c1e 100644 (file)
"<output>\n"
"<extension>.ps</extension>\n"
"<mimetype>image/x-postscript</mimetype>\n"
- "<filetypename>" N_("Postscript (*.ps)") "</filetypename>\n"
- "<filetypetooltip>" N_("Postscript File") "</filetypetooltip>\n"
+ "<filetypename>" N_("PostScript (*.ps)") "</filetypename>\n"
+ "<filetypetooltip>" N_("PostScript File") "</filetypetooltip>\n"
"</output>\n"
"</inkscape-extension>", new PsOutput());