bugGNU Octave - Bugs: bug #43827, print svg with incorrect font...

 
 

bug #43827: print svg with incorrect font baseline

Submitter:  Muhali <muhali>
Submitted:  Mon 15 Dec 2014 06:53:14 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 02 Jan 2015 04:27:39 PM UTC, comment #7: 

I was using inkscape, and there you have a zero baseline-shift as default when entering new text. That translates to the bottom verticalalignment of your example, so I guess that got me confused.

Muhali <muhali>
Fri 02 Jan 2015 01:37:38 PM UTC, comment #6: 

consider the following Octave code:


## verticalalignment middle is default
text (0.2, 0.5, "Z middle");
text (0.5, 0.5, "Z bottom", "verticalalignment", "bottom")
text (0.8, 0.5, "Z top", "verticalalignment", "top")

line([0 1], [0.5 0.5])
axis off
print out.svg


which produces following SVG (snipped header and footer)


<text fill="#000000" x="164.16" y="226.58" font-size="10" text-anchor="start" baseline-shift="-5" font-family="Helvetica">Z middle</text>
<text fill="#000000" x="298.08" y="226.58" font-size="10" text-anchor="start" baseline-shift="0" font-family="Helvetica">Z bottom</text>
<text fill="#000000" x="432" y="226.58" font-size="10" text-anchor="start" baseline-shift="-10" font-family="Helvetica">Z top</text>
<polyline fill="none" stroke="#000000" stroke-width="0.5" points="74.88,226.58 521.28,226.58"/>


As you can see the y position of the line and the text are always the same and "baseline-shift = font-size/2" is used to vertically center the text, 0 for bottom and font-size for top.

I also attach the exported PNG from inkscape. I still can't see an error in Octave, gl2ps and Inkscape


Andreas Weber <andy1978>
Group Member
Fri 02 Jan 2015 10:55:06 AM UTC, comment #5: 

but the line


<text fill="#000000" x="298.08" y="207.958" font-size="12" text-anchor="start" baseline-shift="-6" font-family="Helvetica">ZZZ</text>


from foo.svg shows that the text itself ('ZZZ') gets shifted, not only the labels. Why is normal text shifted?

Muhali <muhali>
Fri 02 Jan 2015 02:26:18 AM UTC, comment #4: 

So it seems that gl2ps is producing valid svg and that there is notihng Octave should do per se.

Workarounds exist such as using a fully svg-compliant viewer like Inkscape or translating to svg through a different format like postscript or pdf.

Closing report.

Rik <rik5>
Group administrator
Thu 01 Jan 2015 09:45:49 PM UTC, comment #3: 

The SVG attribute in question is "baseline-shift" http://www.w3.org/TR/SVG11/text.html#BaselineShiftProperty

The svg generated by gl2ps looks fine for me. It uses font-size="10" and baseline-shift="-10" to draw the xlabels which should show text below the box.

I've found a bugreport because baseline-shift isn't implemented in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=308338

I created a testimage

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
  <text x="10" y="40" style="font-size:26px">
    (a+b)<tspan style="baseline-shift:super;font-size:18px">2</tspan>
  </text>
  <text x="10" y="80" style="font-size:26px">
   c<tspan style="baseline-shift:sub;font-size:18px">11</tspan>
  </text>
  <text x="10" y="120" style="font-size:26px">
    K<tspan style="baseline-shift:-20;font-size:18px">i=0</tspan>
  </text>
</svg>


Only Inkscape renders correct here, LibreOffice, Gimp and Iceweasel fail

Andreas Weber <andy1978>
Group Member
Mon 29 Dec 2014 05:46:07 PM UTC, comment #2: 

This will be hard to fix since we rely on gl2ps to construct the svg from the OpenGL window.  Really it needs to be fixed upstream, if it needs to be fixed.

I get quite acceptable results with Inkscape, bad results with Libreoffice or Firefox, and intermediate results with KDE's svg renderer.  This is the same experience reported by Pantxo so I'm not sure who is following the svg standard and who is not.  It may be that gl2ps is creating correct svg code.

As a workaround, I find working in Inkscape with svg to be quite easy.  There is also the choice of exporting to a format like postscript or pdf and then importing that into svg through Inkscape or another program.  I had good results doing that including being able to recognize text as text, rather than just graphic images.

Rik <rik5>
Group administrator
Mon 15 Dec 2014 11:58:29 PM UTC, comment #1: 

Hi,

Confirmed on linux mint 17.1. Note that only tick labels are shifted, not the text object (wich isn't necessary to reproduce the bug).

LibreOffice, Firefox, gThumb and Gimp all render shifted tick labels (not necessarily consistent between each other) while in Inkscape the shift is not obvious (if any).

Pantxo Diribarne <pantxo>
Group Member
Mon 15 Dec 2014 06:53:14 PM UTC, original submission:  

Doing


text(0.5, 0.5, "ZZZ")
print foo.svg


results in the attached foo.svg. You will notice that all characters have gotten a baseline-shift, which is very inconvenient for subsequent editing.

Muhali <muhali>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #32748:  out.png added by andy1978 (3KiB - image/png - exported png from inkscape)
file #32677:  foo.svg added by muhali (6KiB - image/svg+xml)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by muhali (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-01-02 andy1978 Attached File- Added out.png, #32748
    2015-01-02 rik5 StatusConfirmed Wont Fix
        Open/ClosedOpen Closed
    2014-12-15 pantxo StatusNone Confirmed
    2014-12-15 muhali Attached File- Added foo.svg, #32677

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code