fonts pixelated in rotated text

On the trunk, it appears that font anti-aliasing is turned off on
rotated text, as in this example:

n [26]: import datetime

In [27]: dt = datetime.date.today()

In [28]: dates = [dt-datetime.timedelta(days=i) for i in range(10)]

In [29]: plot(dates, range(10))
Out[29]: [<matplotlib.lines.Line2D object at 0x98f96ac>]

# after rotation the fonts are pixelated
In [34]: gcf().autofmt_xdate ()

In [35]: draw()

font.png

They don't look non-antialiased to me (in your attachment or a file I generated locally). Remember, the rotation happens in raster (not vector) space, because that was the path of least resistance, but is a bit of a hack.

The difference is that the trunk appears slightly darker than 0.91.x. (And 0.90.x, if I recall correctly, didn't support non-90 degree rotations of text at all). 0.91.x is using spline36 interpolation, trunk is using spline16. I *think* I changed it because I thought spline16 looked slightly cleaner (though technically less accurate), and of course is faster, but I'm not sure anymore -- SVN blame isn't helping me remember. It could have just been the example I was using at the time looked better.

In any case, you should be able to change this line in _backend_agg.cpp:2197

  filter.calculate(agg::image_filter_spline16());

to any of the interpolation kernels that Agg offers, and experiment until you find something suitable.

Cheers,
Mike

John Hunter wrote:

···

On the trunk, it appears that font anti-aliasing is turned off on
rotated text, as in this example:

n [26]: import datetime

In [27]: dt = datetime.date.today()

In [28]: dates = [dt-datetime.timedelta(days=i) for i in range(10)]

In [29]: plot(dates, range(10))
Out[29]: [<matplotlib.lines.Line2D object at 0x98f96ac>]

# after rotation the fonts are pixelated
In [34]: gcf().autofmt_xdate ()

In [35]: draw()
  
------------------------------------------------------------------------

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
------------------------------------------------------------------------

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Hmm, I tried setting the interpolation back to what it is on the
branch, but this doesn't explain it. If you run

t = text(0.5, 0.5, 'hi mom', fontsize=20)
t.set_rotation(30); draw()

and save the results from the trunk and the branch (using
agg::image_filter_spline36) on both, it appears (as you say) that the
font weight is darker for rotated text, but not for non-rotated text.

JDH

···

On Fri, Apr 25, 2008 at 1:08 PM, Michael Droettboom <mdroe@...31...> wrote:

They don't look non-antialiased to me (in your attachment or a file I
generated locally). Remember, the rotation happens in raster (not vector)
space, because that was the path of least resistance, but is a bit of a
hack.

The difference is that the trunk appears slightly darker than 0.91.x. (And
0.90.x, if I recall correctly, didn't support non-90 degree rotations of
text at all). 0.91.x is using spline36 interpolation, trunk is using
spline16. I *think* I changed it because I thought spline16 looked slightly
cleaner (though technically less accurate), and of course is faster, but I'm
not sure anymore -- SVN blame isn't helping me remember. It could have just
been the example I was using at the time looked better.

In any case, you should be able to change this line in
_backend_agg.cpp:2197

  filter.calculate(agg::image_filter_spline16());

to any of the interpolation kernels that Agg offers, and experiment until
you find something suitable.

I'm stumped. It looks like the code (and even the inputs to draw_text_image) are virtually identical, modulo the differences between Agg 2.3 and 2.4. Maybe the change is in Agg, and 2.4 is theoretically more correct? We can always experiment with different kernels and parameters until finding one that looks right.

Cheers,
Mike

John Hunter wrote:

···

On Fri, Apr 25, 2008 at 1:08 PM, Michael Droettboom <mdroe@...31...> wrote:
  

They don't look non-antialiased to me (in your attachment or a file I
generated locally). Remember, the rotation happens in raster (not vector)
space, because that was the path of least resistance, but is a bit of a
hack.

The difference is that the trunk appears slightly darker than 0.91.x. (And
0.90.x, if I recall correctly, didn't support non-90 degree rotations of
text at all). 0.91.x is using spline36 interpolation, trunk is using
spline16. I *think* I changed it because I thought spline16 looked slightly
cleaner (though technically less accurate), and of course is faster, but I'm
not sure anymore -- SVN blame isn't helping me remember. It could have just
been the example I was using at the time looked better.

In any case, you should be able to change this line in
_backend_agg.cpp:2197

  filter.calculate(agg::image_filter_spline16());

to any of the interpolation kernels that Agg offers, and experiment until
you find something suitable.
    
Hmm, I tried setting the interpolation back to what it is on the
branch, but this doesn't explain it. If you run

t = text(0.5, 0.5, 'hi mom', fontsize=20)
t.set_rotation(30); draw()

and save the results from the trunk and the branch (using
agg::image_filter_spline36) on both, it appears (as you say) that the
font weight is darker for rotated text, but not for non-rotated text.

JDH
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

I'll poke around with this then -- I was hoping the report would
trigger some memory about a font change you made. The differences in
the 2.3 and 2.4 agg incantations were all I could see too -- I wonder
if some default template parameter that is different in 2. is creeping
in.

JDH

···

On Fri, Apr 25, 2008 at 2:12 PM, Michael Droettboom <mdroe@...31...> wrote:

I'm stumped. It looks like the code (and even the inputs to
draw_text_image) are virtually identical, modulo the differences between Agg
2.3 and 2.4. Maybe the change is in Agg, and 2.4 is theoretically more
correct? We can always experiment with different kernels and parameters
until finding one that looks right.

John Hunter wrote:

I'm stumped. It looks like the code (and even the inputs to
draw_text_image) are virtually identical, modulo the differences between Agg
2.3 and 2.4. Maybe the change is in Agg, and 2.4 is theoretically more
correct? We can always experiment with different kernels and parameters
until finding one that looks right.
    
I'll poke around with this then -- I was hoping the report would
trigger some memory about a font change you made.

I don't recall any font changes -- if you diff ft2font.cpp in 0.91.2 and trunk you'll see they're virtually identical. And the unrotated text looks identical to me.

The differences in
the 2.3 and 2.4 agg incantations were all I could see too -- I wonder
if some default template parameter that is different in 2. is creeping
in.
  

Perhaps. I was going to check the Agg examples to see if the spline filters look different there, too, but I can't get 2.3 to compile anymore for some reason, so I gave up for now.

Cheers,
Mike

···

On Fri, Apr 25, 2008 at 2:12 PM, Michael Droettboom <mdroe@...31...> wrote:

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA