Mercurial > octave
changeset 24809:a802e644937a
Workaround gl2ps using pixel units for SVG output (bug #53197).
* gl2ps-print.cc (gl2ps_renderer::draw): replace "px" by "pt" in SVG viewport
setup.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Wed, 28 Feb 2018 22:11:38 +0100 |
parents | abfd4fc1b977 |
children | 8a92f442c4a2 |
files | libinterp/corefcn/gl2ps-print.cc |
diffstat | 1 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-print.cc Fri Feb 23 03:12:20 2018 -0600 +++ b/libinterp/corefcn/gl2ps-print.cc Wed Feb 28 22:11:38 2018 +0100 @@ -449,7 +449,8 @@ // In EPS terminal read the header line by line and insert a // new procedure const char* fcn = "/SRX { gsave FCT moveto rotate xshow grestore } BD\n"; - bool header_found = ! (term.find ("eps") != std::string::npos); + bool header_found = ! (term.find ("eps") != std::string::npos + || term.find ("svg") != std::string::npos); while (! feof (tmpf) && nread) { @@ -471,6 +472,25 @@ error ("gl2ps_renderer::draw: internal pipe error"); } } + else if (! header_found + && term.find ("svg") != std::string::npos) + { + // FIXME: gl2ps uses pixel units for SVG format. + // Modify resulting svg to use points instead. + // Remove this "else if" block, and + // make header_found true for SVG if gl2ps is fixed. + std::string srchstr (str); + size_t pos = srchstr.find ("px"); + if (pos != std::string::npos) + { + header_found = true; + srchstr[pos+1] = 't'; // "px" -> "pt" + // Assume the second occurrence is at the same line + pos = srchstr.find ("px", pos); + srchstr[pos+1] = 't'; // "px" -> "pt" + std::strcpy (str, srchstr.c_str ()); + } + } nwrite = std::fwrite (str, 1, nread, fp); if (nwrite != nread)