--- inkscape-0.48.2/src/extension/internal/latex-text-renderer.h 2011-07-08 12:25:09.000000000 -0600 +++ inkscape-0.48.2-new/src/extension/internal/latex-text-renderer.h 2011-12-01 17:01:04.000000000 -0700 @@ -29,11 +29,12 @@ namespace Internal { bool latex_render_document_text_to_file(SPDocument *doc, gchar const *filename, const gchar * const exportId, bool exportDrawing, bool exportCanvas, - bool pdflatex); - + bool pdflatex, bool fontsizesupport, bool combinedepsandpdf); + + class LaTeXTextRenderer { public: - LaTeXTextRenderer(bool pdflatex); + LaTeXTextRenderer(bool pdflatex, bool fontsizesupport, bool combinedepsandpdf); virtual ~LaTeXTextRenderer(); bool setTargetFile(gchar const *filename); @@ -50,6 +51,8 @@ protected: gchar * _filename; bool _pdflatex; /** true if ouputting for pdfLaTeX*/ + bool _fontsizesupport; /** true if want font sizes to be output */ + bool _combinedepsandpdf; /** true if outputting combined eps and pdf */ void push_transform(Geom::Matrix const &transform); Geom::Matrix const & transform(); --- inkscape-0.48.2/src/extension/internal/latex-text-renderer.cpp 2011-07-08 12:25:09.000000000 -0600 +++ inkscape-0.48.2-new/src/extension/internal/latex-text-renderer.cpp 2011-12-01 17:07:00.000000000 -0700 @@ -56,7 +56,7 @@ namespace Internal { bool latex_render_document_text_to_file( SPDocument *doc, gchar const *filename, const gchar * const exportId, bool exportDrawing, bool exportCanvas, - bool pdflatex) + bool pdflatex, bool fontsizesupport, bool combinedepsandpdf) { sp_document_ensure_up_to_date(doc); @@ -78,7 +78,7 @@ latex_render_document_text_to_file( SPDo return false; /* Create renderer */ - LaTeXTextRenderer *renderer = new LaTeXTextRenderer(pdflatex); + LaTeXTextRenderer *renderer = new LaTeXTextRenderer(pdflatex,fontsizesupport,combinedepsandpdf); bool ret = renderer->setTargetFile(filename); if (ret) { @@ -94,10 +94,12 @@ latex_render_document_text_to_file( SPDo return ret; } -LaTeXTextRenderer::LaTeXTextRenderer(bool pdflatex) +LaTeXTextRenderer::LaTeXTextRenderer(bool pdflatex, bool fontsizesupport, bool combinedepsandpdf) : _stream(NULL), _filename(NULL), - _pdflatex(pdflatex) + _pdflatex(pdflatex), + _fontsizesupport(fontsizesupport), + _combinedepsandpdf(combinedepsandpdf) { push_transform(Geom::identity()); } @@ -207,7 +209,13 @@ static char const preamble[] = " \\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"; +" \\providecommand\\rotatebox[2]{#2}%\n" +" \\ifx\\SetFigFontNFSS\\undefined%\n" +" \\gdef\\SetFigFontNFSS#1#2#3#4#5{%\n" +" \\reset@font\\fontsize{#1}{#2pt}%\n" +" \\fontfamily{#3}\\fontseries{#4}\\fontshape{#5}%\n" +" \\selectfont}%\n" +" \\fi\n"; static char const postamble[] = " \\end{picture}%\n" @@ -316,6 +324,10 @@ LaTeXTextRenderer::sp_text_render(SPItem double degrees = -180/M_PI * Geom::atan2(wotransl.xAxis()); bool has_rotation = !Geom::are_near(degrees,0.); + // determine size (and interlinear space) + float fontsize = style->font_size.computed; + float interlinearspace = fontsize*1.2; // 20% greater than fontsize is good rule of thumb + // write to LaTeX Inkscape::SVGOStringStream os; os.setf(std::ios::fixed); // don't use scientific notation @@ -331,7 +343,12 @@ LaTeXTextRenderer::sp_text_render(SPItem os << "\\rotatebox{" << degrees << "}{"; } os << "\\makebox(0,0)" << alignment << "{"; - os << "\\smash{" << str << "}"; // smash the text, to be able to put the makebox coordinates at the baseline + if (_fontsizesupport) { + os << "\\smash{{\\SetFigFontNFSS{" << fontsize << "}{" << interlinearspace << "}{\\rmdefault}{\\mddefault}{\\updefault}" + << str << "}}"; // smash the text, to be able to put the makebox coordinates at the baseline + } else { + os << "\\smash{" << str << "}"; // smash the text, to be able to put the makebox coordinates at the baseline + } if (has_rotation) { os << "}"; // rotatebox end } @@ -539,10 +556,16 @@ LaTeXTextRenderer::setupDocument(SPDocum os << " \\global\\let\\svgscale\\undefined%\n"; os << " \\makeatother%\n"; + // if combined EPS and PDF then strip filename extension + gchar * whereisperiod = g_strrstr(_filename,"."); + if (_combinedepsandpdf && (whereisperiod != NULL)) (*whereisperiod) = '\0'; // replace period "." with NULL termination + os << " \\begin{picture}(" << _width << "," << _height << ")%\n"; // strip pathname, as it is probably desired. Having a specific path in the TeX file is not convenient. os << " \\put(0,0){\\includegraphics[width=\\unitlength]{" << _filename << "}}%\n"; + if (whereisperiod != NULL) (*whereisperiod) = '.'; // restore period in filename + fprintf(_stream, "%s", os.str().c_str()); return true; --- inkscape-0.48.2/src/extension/internal/cairo-renderer-pdf-out.h 2011-07-08 12:25:09.000000000 -0600 +++ inkscape-0.48.2-new/src/extension/internal/cairo-renderer-pdf-out.h 2011-11-18 10:16:20.000000000 -0700 @@ -22,6 +22,13 @@ namespace Inkscape { namespace Extension { namespace Internal { + +bool +pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, + bool texttopath, bool omittext, bool filtertobitmap, int resolution, + const gchar * const exportId, bool exportDrawing, bool exportCanvas); + + class CairoRendererPdfOutput : Inkscape::Extension::Implementation::Implementation { public: --- inkscape-0.48.2/src/extension/internal/cairo-renderer-pdf-out.cpp 2011-07-08 12:25:09.000000000 -0600 +++ inkscape-0.48.2-new/src/extension/internal/cairo-renderer-pdf-out.cpp 2011-12-01 17:25:23.000000000 -0700 @@ -19,6 +19,7 @@ #ifdef HAVE_CAIRO_PDF #include "cairo-renderer-pdf-out.h" +#include "cairo-ps-out.h" // for combined EPS capability #include "cairo-render-context.h" #include "cairo-renderer.h" #include "latex-text-renderer.h" @@ -50,7 +51,7 @@ CairoRendererPdfOutput::check (Inkscape: return TRUE; } -static bool +bool pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas) @@ -158,6 +159,22 @@ CairoRendererPdfOutput::save(Inkscape::E g_warning("Parameter might not exist"); } + bool new_comboEPSPDFLaTeX = FALSE; + try { + new_comboEPSPDFLaTeX = mod->get_param_bool("comboEPSPDFLaTeX"); + } + catch(...) { + g_warning("Parameter might not exist"); + } + + bool new_textToLaTeXFontSize = FALSE; + try { + new_textToLaTeXFontSize = mod->get_param_bool("textToLaTeXFontSize"); + } + catch(...) { + g_warning("Parameter might not exist"); + } + bool new_blurToBitmap = FALSE; try { new_blurToBitmap = mod->get_param_bool("blurToBitmap"); @@ -198,6 +215,10 @@ CairoRendererPdfOutput::save(Inkscape::E g_warning("Parameter might not exist"); } + + // if doing combined EPS+PDF+LaTex then turn on regular PDF+LaTex, too + if (new_comboEPSPDFLaTeX) new_textToLaTeX = true; + // Create PDF file { gchar * final_name; @@ -213,7 +234,22 @@ CairoRendererPdfOutput::save(Inkscape::E // Create LaTeX file (if requested) if (new_textToLaTeX) { - ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true); + ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true, new_textToLaTeXFontSize, new_comboEPSPDFLaTeX); + + if (!ret) + throw Inkscape::Extension::Output::save_failed(); + } + + // Create EPS file (if requested) + if (new_comboEPSPDFLaTeX) { + gchar * final_name; + gchar * whereisperiod = g_strrstr(filename,"."); + if (whereisperiod != NULL) (*whereisperiod) = '\0'; // replace period "." with NULL termination + final_name = g_strdup_printf("> %s.eps", filename); + ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_textToLaTeX, + new_blurToBitmap, new_bitmapResolution, new_exportId, new_exportDrawing, new_exportCanvas, true); + if (whereisperiod != NULL) (*whereisperiod) = '.'; // change original filename back + g_free(final_name); if (!ret) throw Inkscape::Extension::Output::save_failed(); @@ -244,6 +280,8 @@ CairoRendererPdfOutput::init (void) "\n" "false\n" "false\n" + "false\n" + "false\n" "true\n" "90\n" "false\n" --- inkscape-0.48.2/src/extension/internal/cairo-ps-out.h 2011-07-08 12:25:09.000000000 -0600 +++ inkscape-0.48.2-new/src/extension/internal/cairo-ps-out.h 2011-11-18 10:24:49.000000000 -0700 @@ -23,6 +23,13 @@ namespace Inkscape { namespace Extension { namespace Internal { + +bool +ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, + bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool eps); + + + class CairoPsOutput : Inkscape::Extension::Implementation::Implementation { public: --- inkscape-0.48.2/src/extension/internal/cairo-ps-out.cpp 2011-07-08 12:25:09.000000000 -0600 +++ inkscape-0.48.2-new/src/extension/internal/cairo-ps-out.cpp 2011-12-01 17:24:53.000000000 -0700 @@ -19,6 +19,7 @@ #ifdef HAVE_CAIRO_PDF #include "cairo-ps-out.h" +#include "cairo-renderer-pdf-out.h" // for combined PDF capability #include "cairo-render-context.h" #include "cairo-renderer.h" #include "latex-text-renderer.h" @@ -61,7 +62,7 @@ bool CairoEpsOutput::check (Inkscape::Ex } } -static bool +bool ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool eps = false) { @@ -157,6 +158,22 @@ CairoPsOutput::save(Inkscape::Extension: g_warning("Parameter might not exist"); } + bool new_comboEPSPDFLaTeX = FALSE; + try { + new_comboEPSPDFLaTeX = mod->get_param_bool("comboEPSPDFLaTeX"); + } + catch(...) { + g_warning("Parameter might not exist"); + } + + bool new_textToLaTeXFontSize = FALSE; + try { + new_textToLaTeXFontSize = mod->get_param_bool("textToLaTeXFontSize"); + } + catch(...) { + g_warning("Parameter might not exist"); + } + bool new_blurToBitmap = FALSE; try { new_blurToBitmap = mod->get_param_bool("blurToBitmap"); @@ -182,6 +199,10 @@ CairoPsOutput::save(Inkscape::Extension: new_exportId = mod->get_param_string("exportId"); } catch(...) {} + + // if doing combined PS+PDF+LaTeX then turn on PS+LaTeX option, too + if (new_comboEPSPDFLaTeX) new_textToLaTeX = true; + // Create PS { gchar * final_name; @@ -195,7 +216,21 @@ CairoPsOutput::save(Inkscape::Extension: // Create LaTeX file (if requested) if (new_textToLaTeX) { - ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false); + ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false, new_textToLaTeXFontSize, new_comboEPSPDFLaTeX); + + if (!ret) + throw Inkscape::Extension::Output::save_failed(); + } + // Create PDF file (if requested) + if (new_comboEPSPDFLaTeX) { + gchar * final_name; + gchar * whereisperiod = g_strrstr(filename,"."); + if (whereisperiod != NULL) (*whereisperiod) = '\0'; // replace period "." with NULL termination + final_name = g_strdup_printf("> %s.pdf", filename); + ret = pdf_render_document_to_file(doc, final_name, level, new_textToPath, new_textToLaTeX, + new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaPage); + if (whereisperiod != NULL) (*whereisperiod) = '.'; // change original filename back + g_free(final_name); if (!ret) throw Inkscape::Extension::Output::save_failed(); @@ -240,6 +275,22 @@ CairoEpsOutput::save(Inkscape::Extension g_warning("Parameter might not exist"); } + bool new_comboEPSPDFLaTeX = FALSE; + try { + new_comboEPSPDFLaTeX = mod->get_param_bool("comboEPSPDFLaTeX"); + } + catch(...) { + g_warning("Parameter might not exist"); + } + + bool new_textToLaTeXFontSize = FALSE; + try { + new_textToLaTeXFontSize = mod->get_param_bool("textToLaTeXFontSize"); + } + catch(...) { + g_warning("Parameter might not exist"); + } + bool new_blurToBitmap = FALSE; try { new_blurToBitmap = mod->get_param_bool("blurToBitmap"); @@ -265,6 +316,10 @@ CairoEpsOutput::save(Inkscape::Extension new_exportId = mod->get_param_string("exportId"); } catch(...) {} + + // if doing combined EPS+PDF+LaTeX then turn on EPS+LaTeX option, too + if (new_comboEPSPDFLaTeX) new_textToLaTeX = true; + // Create EPS { gchar * final_name; @@ -278,7 +333,21 @@ CairoEpsOutput::save(Inkscape::Extension // Create LaTeX file (if requested) if (new_textToLaTeX) { - ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false); + ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false, new_textToLaTeXFontSize, new_comboEPSPDFLaTeX); + + if (!ret) + throw Inkscape::Extension::Output::save_failed(); + } + // Create PDF file (if requested) + if (new_comboEPSPDFLaTeX) { + gchar * final_name; + gchar * whereisperiod = g_strrstr(filename,"."); + if (whereisperiod != NULL) (*whereisperiod) = '\0'; // replace period "." with NULL termination + final_name = g_strdup_printf("> %s.pdf", filename); + ret = pdf_render_document_to_file(doc, final_name, level, new_textToPath, new_textToLaTeX, + new_blurToBitmap, new_bitmapResolution, new_exportId, new_areaDrawing, new_areaPage); + if (whereisperiod != NULL) (*whereisperiod) = '.'; // change original filename back + g_free(final_name); if (!ret) throw Inkscape::Extension::Output::save_failed(); @@ -322,6 +391,8 @@ CairoPsOutput::init (void) "\n" "false\n" "false\n" + "false\n" + "false\n" "true\n" "90\n" "true\n" @@ -360,6 +431,8 @@ CairoEpsOutput::init (void) "\n" "false\n" "false\n" + "false\n" + "false\n" "true\n" "90\n" "true\n"