diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp
index 17966701a7..74e87dc0b7 100644
--- a/src/common/dcsvg.cpp
+++ b/src/common/dcsvg.cpp
@@ -541,18 +541,6 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
CalcBoundingBox((wxCoord)(x + h * sin(rad)), (wxCoord)(y + h * cos(rad)));
CalcBoundingBox((wxCoord)(x + h * sin(rad) + w * cos(rad)), (wxCoord)(y + h * cos(rad) - w * sin(rad)));
- if (m_backgroundMode == wxBRUSHSTYLE_SOLID)
- {
- // draw background first
- // just like DoDrawRectangle except we pass the text color to it and set the border to a 1 pixel wide text background
- s += wxString::Format(wxS(" "), NumStr(-angle), x, y);
- s += wxS("\n");
- write(s);
- }
-
// Create text style string
wxString fontstyle;
switch (m_font.GetStyle())
@@ -605,24 +593,46 @@ void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoor
const wxArrayString lines = wxSplit(sText, '\n', '\0');
for (size_t lineNum = 0; lineNum < lines.size(); lineNum++)
{
+ const int xRect = x + wxRound(lineNum * dx);
+ const int yRect = y + wxRound(lineNum * dy);
+
// convert x,y to SVG text x,y (the coordinates of the text baseline)
wxCoord ww, hh, desc;
wxString const& line = lines[lineNum];
DoGetTextExtent(line, &ww, &hh, &desc);
- const int xx = x + wxRound(lineNum * dx) + (hh - desc) * sin(rad);
- const int yy = y + wxRound(lineNum * dy) + (hh - desc) * cos(rad);
+ const int xText = xRect + (hh - desc) * sin(rad);
+ const int yText = yRect + (hh - desc) * cos(rad);
- const int tx = xx - (int)ceil(xx * scale);
- const int ty = yy - (int)ceil(yy * scale);
+ const int tx = xText - (int)ceil(xText * scale);
+ const int ty = yText - (int)ceil(yText * scale);
const int len = (int)floor(ww / scale);
+ if (m_backgroundMode == wxBRUSHSTYLE_SOLID)
+ {
+ // draw text background
+ const wxString rectStyle = wxString::Format(
+ wxS("style=\"%s %s stroke-width:1;\""),
+ wxBrushString(m_textBackgroundColour),
+ wxPenString(m_textBackgroundColour));
+
+ const wxString rectTransform = wxString::Format(
+ wxS("transform=\"rotate(%s %d %d)\""),
+ NumStr(-angle), xRect, yRect);
+
+ s = wxString::Format(
+ wxS(" \n"),
+ xRect, yRect, ww, hh, rectStyle, rectTransform);
+
+ write(s);
+ }
+
const wxString transform = wxString::Format(
wxS("transform=\"rotate(%s %d %d) translate(%d %d) scale(%s)\""),
- NumStr(-angle), xx, yy, tx, ty, NumStr(scale));
+ NumStr(-angle), xText, yText, tx, ty, NumStr(scale));
s = wxString::Format(
wxS(" %s\n"),
- xx, yy, len, style, transform,
+ xText, yText, len, style, transform,
#if wxUSE_MARKUP
wxMarkupParser::Quote(line)
#else