diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2017-12-05 20:51:01 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2017-12-05 20:51:01 +0000 |
| commit | 82b42536b29ccb2f93f4bd156c7fa20367920348 (patch) | |
| tree | 2d5cecbd09c2cfb1f849ad399395185e15c8d823 /src | |
| parent | PDF+LaTeX export: Fix multiline text (diff) | |
| download | inkscape-82b42536b29ccb2f93f4bd156c7fa20367920348.tar.gz inkscape-82b42536b29ccb2f93f4bd156c7fa20367920348.zip | |
PDF+LaTeX export: do not apply style to newlines
As the parser seems to wrap newlines into their own tspan which has
the same style as the preceding tspan the latex-text renderer
produced output like "\texbf{\\}" which broke compilation in LaTeX
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/latex-text-renderer.cpp | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index e5b87b389..7a1cacbf2 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -346,31 +346,6 @@ void LaTeXTextRenderer::sp_text_render(SPText *textobj) for (Inkscape::Text::Layout::iterator li = layout.begin(), le = layout.end(); li != le; li.nextStartOfSpan()) { - SPStyle const &spanstyle = *(sp_te_style_at_position (textobj, li)); - bool is_bold = false, is_italic = false, is_oblique = false; - - if (spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_500 || - spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_600 || - spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_700 || - spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_800 || - spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_900 || - spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLD || - spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLDER) - { - is_bold = true; - os << "\\textbf{"; - } - if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_ITALIC) - { - is_italic = true; - os << "\\textit{"; - } - if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_OBLIQUE) - { - is_oblique = true; - os << "\\textsl{"; // this is an accurate choice if the LaTeX chosen font matches the font in Inkscape. Gives bad results when it is not so... - } - Inkscape::Text::Layout::iterator ln = li; ln.nextStartOfSpan(); Glib::ustring uspanstr = sp_te_get_string_multiline (textobj, li, ln); @@ -379,6 +354,34 @@ void LaTeXTextRenderer::sp_text_render(SPText *textobj) continue; } + bool is_bold = false, is_italic = false, is_oblique = false; + + // newline character only -> don't attempt to add style (will break compilation in LaTeX) + if (g_strcmp0(spanstr, "\n")) { + SPStyle const &spanstyle = *(sp_te_style_at_position (textobj, li)); + if (spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_500 || + spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_600 || + spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_700 || + spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_800 || + spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_900 || + spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLD || + spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLDER) + { + is_bold = true; + os << "\\textbf{"; + } + if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_ITALIC) + { + is_italic = true; + os << "\\textit{"; + } + if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_OBLIQUE) + { + is_oblique = true; + os << "\\textsl{"; // this is an accurate choice if the LaTeX chosen font matches the font in Inkscape. Gives bad results when it is not so... + } + } + // replace carriage return with double slash gchar ** splitstr = g_strsplit(spanstr, "\n", 2); os << splitstr[0]; |
