jfree / jfreesvg

A fast, lightweight Java library for creating Scalable Vector Graphics (SVG) output.
http://www.jfree.org/jfreesvg
GNU General Public License v3.0
319 stars 58 forks source link

svg font size units #3

Open miminno opened 8 years ago

miminno commented 8 years ago

Shouldn't the font size for text elements be in points rather than pixels? getSVGFontStyle() prints 'px' for the 'font-size' attribute.

sladkoff commented 7 years ago

I don't think that it should.

It states here that the value of font-size can actually be any of the following: <absolute-size> | <relative-size> | <length> | <percentage> | inherit

If anything, the font-size unit could be made configurable, I guess.

EDIT: Actually, ignore that. The library is using css styles for the font-size, not the svg attribute. The same applies though, IMO.

EDIT 2: Ha, no, actually, you're right, I didn't know that the size in java.awt.Font is in points.

miminno commented 7 years ago

Yes, exactly, java.awt.Font is in points and the svg font size should be the same. I should've mentioned that in the original post.

miminno commented 7 years ago

Bump. Any thoughts on this? Thanks.

jfree commented 7 years ago

I think you are correct. I'll do some investigation and change it.

jfree commented 7 years ago

In fact, 'px' is working better that 'pt' at the moment because the other dimensions in the SVG are defaulting to 'px' (so everything is consistent, even it not matching the Java2D standard unit size). I'll continue analysing this alongside the viewBox request that is also outstanding.

miminno commented 7 years ago

For me this causes big issues when exporting the same JFreeChart chart to PDF and SVG. Fonts are different and as a result the whole chart looks different. I'm attaching the sample for comparison here. I realize that switching from px to pt is not that easy due to all internal calculations that take place, but I hope that perhaps there is some reasonable solution to this.

svgvspdf