bugGNU Octave - Bugs: bug #52655, [GL2PS] fontsize not correct svg...

 
 

bug #52655: [GL2PS] fontsize not correct svg output

Submitter:  Juan Pablo Carbajal <juanpi>
Submitted:  Wed 13 Dec 2017 09:39:10 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Fixed Assigned to:  None
Originator Name:  juanpi Open/Closed:  * Closed
Release:  * 4.2.1 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 28 Feb 2018 10:32:38 PM UTC, comment #17: 

We now force point units in SVG outputs:

http://hg.savannah.gnu.org/hgweb/octave/rev/a802e644937a

Marking this bug fixed.

Pantxo Diribarne <pantxo>
Group Member
Sat 16 Dec 2017 01:02:11 PM UTC, comment #16: 

You'll find the preliminary converter sources, instructions to build it and a patch to use it in Octave in comment 10 and 12 of bug #52193.

The converter currently makes use of QPolygon class to merge polygons that have the same color (and avoid antialiasing artifacts between adjacent triangles). It works most of the time but I found that sometimes some triangles are missing  in the output pdf. So yes if you have an idea of a reliable and efficient polygon merging algorithm you are welcome to give a hand (my attempts up to now are unsatisfactory). In any event lets continue the discussion in bug #52193 report.

Pantxo Diribarne <pantxo>
Group Member
Fri 15 Dec 2017 09:49:22 PM UTC, comment #15: 

Yeah, I suggested this long ago (started doing it in geometry). Where are the files of the current converter? just to get started, maybe I can give a hand.

Juan Pablo Carbajal <juanpi>
Group Member
Fri 15 Dec 2017 03:55:18 PM UTC, comment #14: 

@juanpi: there is an on-going effort to convert svg directly from Octave. The converter, in its current state, already takes care of scaling figure due to this known bug in gl2ps (see bug #52193).

Pantxo Diribarne <pantxo>
Group Member
Fri 15 Dec 2017 03:43:09 PM UTC, comment #13: 

@Pantxo: when I create and svg is meant to go be used for printing (as in paper). If I have to be changing the fonts every time it breaks automation. So pt should be conserved.

I am closing the bug as "upstream bug" ("In progress" due to the lack of that status)

Juan Pablo Carbajal <juanpi>
Group Member
Fri 15 Dec 2017 09:54:33 AM UTC, comment #12: 

I filed a bug report:

https://gitlab.onelab.info/gl2ps/gl2ps/issues/20

Could we now close this report as upstream bug?

Pantxo Diribarne <pantxo>
Group Member
Fri 15 Dec 2017 08:04:57 AM UTC, comment #11: 

@Juanpi: consider the following example:


annotation ("textbox", [.2 .5 .3 .2], "string", "This text should fit in the box")


If text and rectangle size don't match then the figure will be ugly. That's why I want text and primitive size to be exactly as on-screen.

>> Where is the dev version you are referring to?


I was talking about Octave dev version. There has been a bit of work to improve the svg output.

>> have you already aksed why gl2ps doesn't exploit the huge amount of svg writer routines written in inkscape?


I don't see anything complicated in writing an svg file that would justify the use of an external library in gl2ps.

Pantxo Diribarne <pantxo>
Group Member
Thu 14 Dec 2017 11:40:33 PM UTC, comment #10: 

Also, @Pantxo, have you already aksed why gl2ps doesn't exploit the huge amount of svg writer routines written in inkscape? example : https://gitlab.com/inkscape/inkscape/blob/master/src/2geom/svg-path-writer.cpp

Juan Pablo Carbajal <juanpi>
Group Member
Thu 14 Dec 2017 11:22:07 PM UTC, comment #9: 

@Pantxo, I metioned the verison of gl2ps that I am using. When I cclone from github I see only one "master" branch and the code there doesn't have what you mention about the text elements. Where is the dev version you are referring to?

also, if I understadn you correctly, I think our expectations are different. I do not care about relative sizes of text and axes. I want that the svg honors the format I set in my figure, i.e. if text is 12pt, I want and svg with 12pt fonts.

The gl2ps svg output needs a lot of improvements and I guess it can only get better by working on gl2ps.

I agree that we do not want to pass everything in poits, but we definitely want to pass numbers with their units (remember Mars Polar Lander!), so gl2ps needs ot get 12pt and not just 12 as the SVg output I get shows.

Juan Pablo Carbajal <juanpi>
Group Member
Thu 14 Dec 2017 10:49:12 PM UTC, comment #8: 

Both graphics primitives and text coordinates are expressed in the same (pixels) unit. We don't want to change the units for text since we would also have to change that of all other elements and scale their coordinates.

>> I don't know if there is any good solution here.


Fixing gl2ps is the only viable solution in my opinion.

Pantxo Diribarne <pantxo>
Group Member
Thu 14 Dec 2017 09:59:22 PM UTC, comment #7: 

This documentation on units in SVG is instructive (https://www.w3.org/TR/SVG/coords.html#Units).

A point is defined to be 1.25 pixels.  So if Octave is using points, and SVG is using pixels, the transform ratio is 1/1.25 = 0.8.  This is fixed, and is why I am seeing a font size of 9.6 points in Inkscape for what is a 12 point font in Octave (0.8*12 = 9.6).

Rik <rik5>
Group administrator
Thu 14 Dec 2017 09:51:28 PM UTC, comment #6: 

Skipping the stable version, it would be possible to add the unit measure to the fontsize in the development version.  Attached is a patch that unconditionally adds "pt" to the font-size property (fontsz.diff).

But it probably doesn't do what you want.  Octave's print code for svg is also setting the kerning, the space between letters, and letters appear too close together when the fontsize is changed from svg pixels to points.  You can get rid of the kerning by using Text->Remove Manual Kerning in Inkscape.  That makes things look nicer, but now the size of the text, at 12pt, is larger than what appears in the plot window in Octave.

I don't know if there is any good solution here.

(file #42652)

Rik <rik5>
Group administrator
Thu 14 Dec 2017 03:45:43 PM UTC, comment #5: 

In the current dev branch (which you don't seem to be using since Helvetica is not the default font, it should be FreeSans) we directly dump the svg text element to make sure characters are well placed (we specify x as a vector of coordinates), as in our on-screen figure. As a side effect the font-name is honored.

Can you explain what you find is wrong in your attachments?
To me, the figure looks the same as on-screen: text is not misplaced, the relative height of text with regards to the figure axes is respected.

The remaining problem (pixels are not points most of the time!) is described in the link I provided and can't be fixed from Octave: just try to change the size of text in Inkscape (or in the source svg) and you'll see that alignment/width ratios will be wrong.

Pantxo Diribarne <pantxo>
Group Member
Thu 14 Dec 2017 03:13:33 PM UTC, comment #4: 

Sure, here they go: svg, inkscape and qt figure

also notice that GL2PS also ignores the fontname, but I think I can fix this in the current gl2ps dev version (or at least report it). They just force Helvetica or Times...do not ask me why...

(file #42648,

Juan Pablo Carbajal <juanpi>
Group Member
Thu 14 Dec 2017 02:42:29 PM UTC, comment #3: 

Can you attach a screenshot of inkscape rendered figure and the svg figure it self (e.g. "plot (1:10), print foo.svg")?

Pantxo Diribarne <pantxo>
Group Member
Thu 14 Dec 2017 12:44:09 PM UTC, comment #2: 

Hi,

Your "Note" is not correct. Indeed in my computer theimage is not rendered correctly. This is because SVG uses the user defined scale as default. So it might be that your Inkscape is configured to use pt as default, therefore the bug is not triggered.

Octave can do is to pass the size with units, which is the most portable way of handling the situation. Otherwise it will always be up to the receiving end to guess what the units of the font-size is.

Juan Pablo Carbajal <juanpi>
Group Member
Thu 14 Dec 2017 12:21:11 PM UTC, comment #1: 

This has already been reported [1] but the proposed patch didn't receive any review even after a few requests. MaybeI can file a bug report now that gl2ps uses gitlab. 

Note though that the figure, when open e.g. in Inkscape, and its text labels are correct: both axes dimensions and text size match. This means that a figure produced by octave and viewed on the same computer will have the expected size (the number of pixels per inch is the same in inkscape and in octave).

Since there is nothing Octave can do about that I'll close this report as "invalid" (we would need a "upstream bug" item here).

[1] http://www.geuz.org/pipermail/gl2ps/2016/000451.html

Pantxo Diribarne <pantxo>
Group Member
Wed 13 Dec 2017 09:39:10 AM UTC, original submission:  


Please apologize if this is actually an upstream bug.

The fontsize of print -dsvg (using GL2PS dev version from git repositorycommit 84971332162c1990a55df62b78ef04561e267401) is consistently smaller than what was passed to the string objects in octave, due to implicit units handling inconssitence between Octave and GL2PS.

Example

ht = text (0.5, 0.5, "Some text in 12pt", 'fontsize', 12);
print -dsvg "test_fontsize.svg"


Produces and svg with

<text fill="#000000" x="298.08" y="208.44" font-size="12" text-anchor="start" dy="6" font-family="Helvetica">Some text in 12pt</text>


by default GL2PS svg font-size will be interpreted in px unless 12pt is given[1].

I guess octave should put units on the string passed to GL2PS or convert its pt default into px before calling GL2PS

[1]: https://www.w3.org/TR/SVG11/text.html#FontSizeProperty


Juan Pablo Carbajal <juanpi>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #42652:  fontsz.diff added by rik5 (829B - text/x-patch)
file #42648:  test_fontsize.svg added by juanpi (4KiB - image/svg+xml)
file #42649:  Figure 1_034.png added by juanpi (16KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by juanpi (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
    2018-02-28 pantxo StatusIn Progress Fixed
    2017-12-15 juanpi StatusNeed Info In Progress
        Open/ClosedOpen Closed
    2017-12-14 rik5 Attached File- Added fontsz.diff, #42652
    2017-12-14 juanpi Attached File- Added test_fontsize.svg, #42648
        Attached File- Added Figure 1_034.png, #42649
        Attached File- Added test_fontsize.svg - Inkscape_035.png, #42650
    2017-12-14 juanpi StatusInvalid / Not an Octave Bug Need Info
        Open/ClosedClosed Open
    2017-12-14 pantxo StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code