GiovineItalia / Gadfly.jl

Crafty statistical graphics for Julia.
http://gadflyjl.org/stable/
Other
1.9k stars 250 forks source link

Bad font rendering wtih Scale.y_log10 when drawing to backend #565

Open jdtuck opened 9 years ago

jdtuck commented 9 years ago

When executing the following plot the SVG renders with easy to read exponents on the labels

plot(dataset("MASS", "mammals"), x="Body", y="Brain", label=1,
            Scale.x_log10, Scale.y_log10, Geom.point, Geom.label)

2015-03-21-101046_1366x768_scrot

however, once it is rendered to the a backend using

draw(PNG("plot.png", 6inch, 4inch, dpi=600), p)

the exponents are hard to read. Thoughts on what I am doing wrong or how to fix it? Thanks

masvis_average

dcjones commented 9 years ago

That's pretty strange. I've not been able to reproduce this. Can you tell me what version cairo and pango are installed on your system?

jdtuck commented 9 years ago

The versions for cairo is 1.14.2 and pango 1.36.8

jdtuck commented 9 years ago

I have looked more into this and it seems to be coming from cairo, if I export the SVG directly and few in firefox, looks good, but any conversion to PNG, PDF, etc. and the superscripts are rendered wrong. Even if you open the SVG in inkscape things are wrong. Thoughts?

dcjones commented 9 years ago

I'm not sure what's going on. Maybe try changing the font for those labels by adding something like: Theme(minor_label_font="courier") to plot. I wonder if it's just something peculiar with the font cairo is choosing.

jdtuck commented 9 years ago

Actually just tried something, it works fine when the DPI setting is removed, might be getting somewhere. It looks as thought there might be bug when the DPI is set manually and increased. I am not familiar with the workings of Compose.jl.

dcjones commented 9 years ago

Sorry, I completely missed the dpi setting. I'm getting the same thing now.

It looks like pango does superscript by raising the text some fixed amount: (https://github.com/GNOME/pango/blob/master/pango/pango-markup.c#L1482)

In cairo that translates to raising the text by a fixed number of pixels, regardless of the text size. Surprising, since that seems like an entirely wrong thing to do. I guess I need to to set the rise manually, since pango can't be trusted to do it correctly.

jdtuck commented 9 years ago

That makes complete sense and I would agree pango's approach is not the right thing to do. Thanks

tlnagy commented 8 years ago

I just ran into this bug. Are there any workarounds?