summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2cbc52f)
raw | patch | inline | side by side (parent: 2cbc52f)
author | Johan Engelen <goejendaagh@zonnet.nl> | |
Fri, 26 Feb 2010 23:29:26 +0000 (00:29 +0100) | ||
committer | Johan Engelen <goejendaagh@zonnet.nl> | |
Fri, 26 Feb 2010 23:29:26 +0000 (00:29 +0100) |
index 6f22dbdc71d00b0569ff508b9e2faa4168593296..61760e9d9b85d07b5c655321f21bdbc74188692f 100644 (file)
@@ -199,7 +199,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
//strip filename of ".ps", do not add ".tex" here.
gsize n = g_str_has_suffix(filename, ".ps") ? strlen(filename)-3 : strlen(filename);
tex_filename = g_strndup(filename, n);
- ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage);
+ ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage, false);
g_free(tex_filename);
if (!ret)
@@ -287,7 +287,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
//strip filename of ".eps", do not add ".tex" here.
gsize n = g_str_has_suffix(filename, ".eps") ? strlen(filename)-4 : strlen(filename);
tex_filename = g_strndup(filename, n);
- ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage);
+ ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_areaDrawing, new_areaPage, false);
g_free(tex_filename);
if (!ret)
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 1dcfbdf1d746d94e0ff5772505e380f7d5786f70..808590e04061725810bc1e6651337b4a7ede15b1 100644 (file)
//strip filename of ".pdf", do not add ".tex" here.
gsize n = g_str_has_suffix(filename, ".pdf") ? strlen(filename)-4 : strlen(filename);
tex_filename = g_strndup(filename, n);
- ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_exportDrawing, new_exportCanvas);
+ ret = latex_render_document_text_to_file(doc, tex_filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
g_free(tex_filename);
if (!ret)
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index 07f3d5a6d7541ce08780446d96360f8f27bd2926..c058c4ff2cc60cd1522db15664835679da5df37a 100644 (file)
*/
bool
latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas)
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas,
+ bool pdflatex)
{
sp_document_ensure_up_to_date(doc);
return false;
/* Create renderer */
- LaTeXTextRenderer *renderer = new LaTeXTextRenderer();
+ LaTeXTextRenderer *renderer = new LaTeXTextRenderer(pdflatex);
bool ret = renderer->setTargetFile(filename);
if (ret) {
return ret;
}
-LaTeXTextRenderer::LaTeXTextRenderer(void)
+LaTeXTextRenderer::LaTeXTextRenderer(bool pdflatex)
: _stream(NULL),
- _filename(NULL)
+ _filename(NULL),
+ _pdflatex(pdflatex)
{
push_transform(Geom::identity());
}
"\\begingroup\n"
" \\makeatletter\n"
" \\providecommand\\color[2][]{%\n"
-" \\GenericError{(Inkscape) \\space\\space\\@spaces}{%\n"
-" Color is used for the text in Inkscape, but the color package color is not loaded.\n"
-" }{Either use black text in Inkscape or load the package\n"
-" color.sty in LaTeX.}%\n"
+" \\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package \'color.sty\' is not loaded}\n"
" \\renewcommand\\color[2][]{}%\n"
" }\n"
+" \\providecommand\\transparent[1]{%\n"
+" \\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package \'transparent.sty\' is not loaded}\n"
+" \\renewcommand\\transparent[1]{}%\n"
+" }\n"
" \\providecommand\\rotatebox[2]{#2}\n";
static char const postamble[] =
Geom::Point anchor = textobj->attributes.firstXY() * transform();
Geom::Point pos(anchor);
- // determine color (for now, use rgb color model as it is most native to Inkscape)
+ // determine color and transparency (for now, use rgb color model as it is most native to Inkscape)
bool has_color = false; // if the item has no color set, don't force black color
+ bool has_transparency = false;
// TODO: how to handle ICC colors?
// give priority to fill color
guint32 rgba = 0;
+ float opacity = SP_SCALE24_TO_FLOAT(style->opacity.value);
if (style->fill.set && style->fill.isColor()) {
has_color = true;
rgba = style->fill.value.color.toRGBA32(1.);
+ opacity *= SP_SCALE24_TO_FLOAT(style->fill_opacity.value);
} else if (style->stroke.set && style->stroke.isColor()) {
has_color = true;
rgba = style->stroke.value.color.toRGBA32(1.);
+ opacity *= SP_SCALE24_TO_FLOAT(style->stroke_opacity.value);
+ }
+ if (opacity < 1.0) {
+ has_transparency = true;
}
-
// get rotation
Geom::Matrix i2doc = sp_item_i2doc_affine(item);
if (has_color) {
os << "\\color[rgb]{" << SP_RGBA32_R_F(rgba) << "," << SP_RGBA32_G_F(rgba) << "," << SP_RGBA32_B_F(rgba) << "}";
}
+ if (_pdflatex && has_transparency) {
+ os << "\\transparent{" << opacity << "}";
+ }
if (has_rotation) {
os << "\\rotatebox{" << degrees << "}{";
}
diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h
index 69f5393147f2f68cbb615d2b8f8123853ba60f11..b5d4bfac154f1244b3a2f005f072f19572704320 100644 (file)
namespace Extension {
namespace Internal {
-bool latex_render_document_text_to_file(SPDocument *doc, gchar const *filename, const gchar * const exportId, bool exportDrawing, bool exportCanvas);
+bool latex_render_document_text_to_file(SPDocument *doc, gchar const *filename,
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas,
+ bool pdflatex);
class LaTeXTextRenderer {
public:
- LaTeXTextRenderer();
+ LaTeXTextRenderer(bool pdflatex);
virtual ~LaTeXTextRenderer();
bool setTargetFile(gchar const *filename);
FILE * _stream;
gchar * _filename;
+ bool _pdflatex; /** true if ouputting for pdfLaTeX*/
+
void push_transform(Geom::Matrix const &transform);
Geom::Matrix const & transform();
void pop_transform();