bugGNU Octave - Bugs: bug #56448, Backslashes in text objects break...

 
 

bug #56448: Backslashes in text objects break postscript export

Submitter:  Georg Wiora <gwiora>
Submitted:  Thu 06 Jun 2019 08:10:13 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  gwiora Open/Closed:  * Closed
Release:  * 5.1.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 07 Jun 2019 03:50:14 PM UTC, comment #9: 

@Georg: To place the plots correctly on the page use the "PaperPosition" property of the figure object.  Documentation is in the manual.  Also, in your original code, I see you using "-r300" which is an option associated with bitmap formats, but PostScript is a vector format and doesn't need that option.  As a quick placement option, you might want to try -bestfit or -fillpage options to print.  Documentation is below.


'-fillpage'
'-bestfit'
     When using a page-based format (PDF, PostScript, printer)
     ignore the "paperposition" property and have the plot occupy
     the entire page.  The option '-fillpage' will stretch the plot
     to occupy the page with 0.25 inch margins all around.  The
     option '-bestfit' will expand the plot to take up as much room
     as possible on the page *without* distorting the original
     aspect ratio of the plot.


Rik <rik5>
Group administrator
Fri 07 Jun 2019 11:23:19 AM UTC, comment #8: 

@Georg: It is very strange that you don't see the warning ... In fact what is even more strange is that in your PS figure you obtain a "a" character instead of a "ä".
Anyway, can you file a new bug report about "-svgconvert" producing misplaced PDF together with a simple example? Please add your screen setup (resolution, number) since this may be relevant.
Also, for me PDF (with or without "-svgconvert" option) works very well with the -append option, as documented. Can you file another bug report about this?

Pantxo Diribarne <pantxo>
Group Member
Fri 07 Jun 2019 07:45:48 AM UTC, comment #7: 

Thank you for your hints and quick fix!

@Rik: I misinterpreted the 'convertsvg' option as another output device and specified it as '-dconvertsvg'. That failed. Using '-convertsvg' gives very nice output but the plot is now misplaced on the page (small problem :-)

@Pantxo: No I did not see this print warning.

Georg Wiora <gwiora>
Thu 06 Jun 2019 09:17:41 PM UTC, comment #6: 

@Pantxo: Great fix!  I applied it to stable so it will be part of the next bug fix release (5.2.0).

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Thu 06 Jun 2019 06:53:17 PM UTC, comment #5: 

The patch:

(file #47047)

Pantxo Diribarne <pantxo>
Group Member
Thu 06 Jun 2019 06:52:32 PM UTC, comment #4: 

I attached a one liner patch that fixes the issue.

@Georg: In your original example, you should be receiving a warning since you are trying to print a non ASCII character.


warning: print: only ASCII characters are supported for EPS and derived formats.


In that case "ä" will still be replaced by a blank space.

Pantxo Diribarne <pantxo>
Group Member
Thu 06 Jun 2019 05:37:43 PM UTC, comment #3: 

The option -svgconvert was part of the 5.1.0 release.  What is the error message when you execute the following?


version
plot (1:10, 'o-')
print -svgconvert tst.pdf




Rik <rik5>
Group administrator
Thu 06 Jun 2019 03:47:02 PM UTC, comment #2: 

Thank you for your hints Rik! Unfortunately is svgconvert not available on windows and I need a multipage format. Otherwise i would use pdf output directly. But ps output seems the only one supporting 'append' option.

Georg Wiora <gwiora>
Thu 06 Jun 2019 03:30:27 PM UTC, comment #1: 

Confirmed.  A very simple example to reproduce is


clf;
ht = text (0.5, 0.5, "This is a backslash (\\).");
print -dpsc2 bslash.ps


This is not specific to Windows; I reproduced it on Linux using the code above.  The "interpreter" property is also a red herring as either "none" or "tex" have the same issue.  I believe this is going to be a problem with the gl2ps library.  We may be forced in Octave to work around it by filtering the output of gl2ps before we pass it to Ghostscript.

As a workaround for now you can go through svg and pdf formats which do work.  On a Linux machine which has the pdf2ps converter this sequence works


print -svgconvert bslash.pdf
system ("pdf2ps bslash.pdf")




(file #47046)

Rik <rik5>
Group administrator
Thu 06 Jun 2019 08:10:13 AM UTC, original submission:  

Create a text with a backslash and display it with 'interpreter' 'none'. Postscript export looks broken then. I was using qt5 graphics on windows for this result.


% Postscript export bug octave 5.1.0

mytext = sprintf("this is _\\pm ä test:\nwith a linebreak\n and a %.3f number",pi)

x=linspace(0,10*pi,1000);
y=sin(x)+x;

fh = figure('name','my plot figure');
plot(x,y);
title(mytext,'interpreter','none');
text(0.4,0.4,mytext,'units','normalized','interpreter','tex','backgroundcolor','w');


mytext2 = {"this is a_\\pm test:","with ä linebreak"}

fh2 = figure('name','my plot figure2');
plot(x,y);
title(mytext2,'interpreter','none');
text(0.4,0.4,mytext2,'units','normalized','interpreter','tex','backgroundcolor','w');

print('-dpsc2', sprintf('-f%d',fh),'-r300','ps_export.ps');

print('-dpsc2', sprintf('-f%d',fh2),'-r300','-append','ps_export.ps');



Georg Wiora <gwiora>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #47047:  escape_backslash.patch added by pantxo (792B - text/x-patch)
file #47046:  tst_bslash.m added by rik5 (103B - text/x-matlab)
file #47043:  ps_export.ps added by gwiora (218KiB - application/postscript - Sample postscript output and test script)
file #47044:  PostscriptexportBug.m added by gwiora (718B - application/octet-stream - Sample postscript output and test script)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by gwiora (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-06 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2019-06-06 pantxo Attached File- Added escape_backslash.patch, #47047
    2019-06-06 pantxo CategoryPlotting Plotting with OpenGL
        StatusConfirmed Patch Submitted
    2019-06-06 rik5 Attached File- Added tst_bslash.m, #47046
        StatusNone Confirmed
        Operating SystemMicrosoft Windows Any
        SummaryBack slashes in text objects break postscript export Backslashes in text objects break postscript export
    2019-06-06 gwiora Attached File- Added ps_export.ps, #47043
        Attached File- Added PostscriptexportBug.m, #47044

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code