bugGNU Octave - Bugs: bug #48567, superscripts spaced incorrectly in...

 
 

bug #48567: superscripts spaced incorrectly in text objects (OpenGL toolkit)

Submitter:  Rik <rik5>
Submitted:  Tue 19 Jul 2016 11:32:28 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  3 - Low Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 22 Sep 2017 01:52:30 PM UTC, comment #13: 

Thank you both of taking care of the review. I noticed a regression (see black polygon in e.g. demo title 3) which I fixed with this patch:

http://hg.savannah.gnu.org/hgweb/octave/rev/71a449b29cc7


Pantxo Diribarne <pantxo>
Group Member
Fri 22 Sep 2017 12:08:20 AM UTC, comment #12: 

This change caused a BIST test to fail in _osmesa_print_.  The expected value of the generated file is different after the tweaks to exponents.  I fixed that here (http://hg.savannah.gnu.org/hgweb/octave/rev/35d13d84a71a).

Rik <rik5>
Group administrator
Thu 21 Sep 2017 11:20:43 PM UTC, comment #11: 

I was the original reporter and this works very nicely now on my original code.  Thanks to Pantxo for keeping on top of this.  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Thu 21 Sep 2017 10:05:27 PM UTC, comment #10: 

I made some minor edits and pushed the changeset from file #41709 here:

http://hg.savannah.gnu.org/hgweb/octave/rev/1b7e49a72c62

Can we close this report, or is there more to be done?  If there is more, should we continue here or in a separate report?

John W. Eaton <jwe>
Group administrator
Fri 01 Sep 2017 01:29:36 PM UTC, comment #9: 

I attached an updated patch since the previous ones did not apply anymore.

(file #41709)

Pantxo Diribarne <pantxo>
Group Member
Sun 04 Jun 2017 01:02:04 PM UTC, comment #8: 

@Rik: do you think you'll get a chance to test this patch.

Pantxo Diribarne <pantxo>
Group Member
Mon 20 Mar 2017 11:55:39 AM UTC, comment #7: 

Hi,

I attached a preliminary cset that implements manual positioning of text characters in both svg and eps formats. This currently covers all the formats that we use since the pdf terminal in gl2ps is only used without text (latex handles the text).
Could you please test it when you have time?

I didn't go further with svg conversion since I now think Batik is not reliable enough (fonts location configuration  is a mess, "Symbol" font not found by default ...).

(file #40032)

Pantxo Diribarne <pantxo>
Group Member
Tue 11 Oct 2016 08:31:32 PM UTC, comment #6: 

I am much more concerned about text rendering than lines transparency, so I didn't review the converters capabilities in this regard. Anyway we definitely only have few (one?) candidates:

  • Batik handles text attributes very well and has a good PDF printout (EPS receives much less attention and e.g. transparency is not supported), provided FOP is properly configured to find fonts on the system. This would be a good candidate for svg->pdf->qhostscript chain.
  • Qt 4.8 only has builtin support for a subset of svg and can't read gl2ps svg files out of the box, clipping areas are drawn black and have to be removed. Besides this I saw font rendering issues and some polygons outlined when they should not but to be fair, I should test all this with Qt5.
  • Inkscape is full featured and its outputs are superior to others and it would even eliminate the need for ghoscript. Unfortunately it is monolithic, which rules it out in my opinion.
  • librsvg has poor text capabilities, e.g. it doesn't handle individual character coordinates which are used in the patch I provided.


At the end of the day we only have Batik as a serious candidate. It adds a (java)step in the chain but the timing is not as bad as I though:


>> demo light 2
>> tic, print ("/tmp/toto.svg"), toc, tic, svg2other ("/tmp/toto.svg", "", "pdf"), toc

Elapsed time is 6.99975 seconds.
Elapsed time is 1.4601 seconds.

>> delete /tmp/toto.pdf
>> plot (1:10)
>> tic, print ("/tmp/toto.svg"), toc, tic, svg2other ("/tmp/toto.svg", "", "pdf"), toc

Elapsed time is 0.0971031 seconds.
Elapsed time is 0.103145 seconds.


For svg with many patches it is about only +20%, while for simple plots it is about a 100% penalty.

As a first step I'd propose to first implement a few new print devices, e.g. -dbatikpdf(eps,png), compare the png output with the current one using dump_plot_demos and then decide to go further or not. The advantage of this approach is that we would require users to have Batik and Fop properly installed and configured and not have to handle this dependency ourselves for the moment.

Pantxo Diribarne <pantxo>
Group Member
Tue 11 Oct 2016 02:47:17 PM UTC, comment #5: 

I like the idea.  It would be nice to switch the backend to svg so we could also get alpha transparency, in addition to better text formatting.

Rik <rik5>
Group administrator
Tue 11 Oct 2016 01:52:04 PM UTC, comment #4: 

I attached a draft cset that improves the text in svg printout: it dumps a preformated svg text element directly in gl2ps output. It allows us two important imprvements:

  • placing characters exactly where they should be (i.e. consistently with onscreen result)
  • use any font present on the system


I also a toy octave function "svg2other" that uses Java Batik and FOP to convert the svg to pdf/eps or png. In order to use this function you need to install FOP and Batik, and eventually change the path to the .jar binaries in the function.

(file #38701, file #38702)

Pantxo Diribarne <pantxo>
Group Member
Fri 22 Jul 2016 01:08:22 AM UTC, comment #3: 

I've marked the bug as "Postponed".  Maybe we'll get to this, or maybe we'll just wait for improvements in gl2ps to come along.

Rik <rik5>
Group administrator
Thu 21 Jul 2016 01:02:59 PM UTC, comment #2: 

I marked the bug confirmed but I would be tempted to mark it "Won't fix".

Pantxo Diribarne <pantxo>
Group Member
Thu 21 Jul 2016 01:01:16 PM UTC, comment #1: 

Unfortunately, as explained in comment 72 of bug #31468, the approach we use to display multi-line and tex formatted strings is very fragile.  There are many reasons (font match - helvetica is non-free so most renderers use replacement fonts-, kerning, integer divisions in octave and then in the renderer ...) why the length of a string may not match between Octave and another renderer.

Our current approach is enough for short strings and powers of 10 in log plots, but I fear long strings will always be an issue until either gl2ps has improved text capabilities or Octave implements its own printing system using cairo/pango or Qt.

The only workaround I know of, if it can be called a workaround, is to use monospace font "courier"


plot (1:10)
ht = text (2,6, {"This is a very long line with a huge sentence Z^2"}, "fontname", "courier")
print tmp2.pdf
open tmp2.pdf

Pantxo Diribarne <pantxo>
Group Member
Tue 19 Jul 2016 11:32:28 PM UTC, original submission:  

This sample code produces a badly spaced superscript. 


./run-octave -f
demo mesh 3
print tmp.pdf
open tmp.pdf


It appears that it may have something to do with very long lines.  The following is also badly spaced.


plot (1:10)
ht = text (2,6, {"This is a very long line with a huge sentence Z^2"})
print tmp2.pdf
open tmp2.pdf



Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #41709:  character_position2.patch added by pantxo (18KiB - text/x-patch)
file #40032:  character_position.patch added by pantxo (18KiB - text/x-patch)
file #38701:  svg4.patch added by pantxo (10KiB - text/x-diff)
file #38702:  svg2other.m added by pantxo (4KiB - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (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
    2017-09-21 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2017-09-01 pantxo Attached File- Added character_position2.patch, #41709
    2017-03-20 pantxo Attached File- Added character_position.patch, #40032
        StatusPostponed Patch Submitted
    2016-10-11 pantxo Attached File- Added svg4.patch, #38701
        Attached File- Added svg2other.m, #38702
    2016-07-22 rik5 Priority5 - Normal 3 - Low
        StatusConfirmed Postponed
    2016-07-21 pantxo StatusNone Confirmed
    2016-07-19 rik5 Summarysuperscripts spaced incorrectly in title objects superscripts spaced incorrectly in text objects (OpenGL toolkit)

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code