Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fonts rendered are 25% larger than requested on SVG backend #1528

Closed
kghose opened this issue Nov 23, 2012 · 5 comments
Closed

Fonts rendered are 25% larger than requested on SVG backend #1528

kghose opened this issue Nov 23, 2012 · 5 comments

Comments

@kghose
Copy link

kghose commented Nov 23, 2012

Problem The text painted with the 'text' function and any other lettering on the axes is 25% larger than requested

To reproduce

Here is a small example program that will reproduce the problem:

import matplotlib as mpl
mpl.use('Agg')
mpl.rcParams['svg.fonttype'] = 'none'
mpl.rcParams['font.sans-serif'] = ['Arial']
import pylab

pylab.figure(figsize=(3,1))
for f in xrange(5):
  pylab.text(f,0,f+10,fontsize=f+10)
pylab.setp(pylab.gca(),'xlim',[0,6],'ylim',[-1,1])
pylab.savefig('test.svg')

Opening up test.svg in inkscape will have all fontsizes larger by 25% (x 1.25)

Platform

Matplotlib version 1.2.0

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

@dmcdougall
Copy link
Member

Are you also using tex? The reason I ask is because I just found this line and this line in another PR. This may be a red herring, but I thought I would point it out so someone could look into it at some point.

@kghose
Copy link
Author

kghose commented Dec 3, 2012

Hi dmcdougall: that's an important thought, but no. This is regular text.

@mdboom
Copy link
Member

mdboom commented Dec 4, 2012

This is a tricky problem. There are seemingly differences of opinion about how font size units are handled in SVG. Chrome, Firefox and Inkscape handle them all differently. What we have now works with Chrome and Firefox and is at least the "correct" size in Inkscape, even though it isn't displayed as such. And it's a hack -- the size of the image is specified in points, which causes 1 pixel === 1 point in user space, and then the font size is specified in pixels. Inkscape gets confused because it wants to display the fontsize in points in its UI. This can be fixed to work as expected in Inkscape, (by specifying all units in pixels, but not all in points, interestingly enough) but then the output doesn't display correctly on Chrome or Firefox. This could be made a user option, but I'm wary of adding more obscure user options. SVG standards compliance is not the greatest ;(

@dmcdougall
Copy link
Member

@mdboom Interesting! I hadn't realised standards compliance was so shoddy.

I think it's reasonable to label this as WONTFIX, for the very reason of standards compliance.

@kghose Have you tried creating a pdf or eps file and using a third-party tool to convert to SVG? There may be third-party solutions that allow the user to adjust certain elements of the file, e.g. font size.

@dmcdougall
Copy link
Member

Since this appears to be an issue of different browsers implementing different standards, I've labelled this as 'wontfix' and I'm going to close it. If somebody feels there is a way to fix this then please feel free to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants