incorrect window_extent of rendered text in pdf backend

Hi,

The pdf backend seems to return incorrect window extent (i.e., return
value of get_window_extent()) when usetex==True.
I'm attaching a small script to test this.

python test_text_window_extent.py -dPdf

Its results for the pdf backend with usetex==True is attached. For
comparison, results for the Agg backend with usetex==False (which
seems correct) is also attached.

I guess this bug is related with

http://article.gmane.org/gmane.comp.python.matplotlib.general/13997

-JJ

test_text_window_extent.py (1.71 KB)

test_pdf_usetexTrue.pdf (76.5 KB)

RendererPdf.get_text_width_height_descent() uses dviread to figure out
the text extent. It seems that the text height returned by dviread is
a height with descent not being included. Therefore, by manually
adding the amount of the descent to its height, problem seems to be
solved.

At line 1652 of "lib/backends/backend_pdf.py"

- return page.width, page.height, page.descent
+ return page.width, page.height+page.descent, page.descent

By the way, agg and ps backends do not respect baselines when
usetex=True. get_text_width_height_descent() method in these backends
just returns 0 for the descent value and baseline alignment is not
properly done. It seems that this can be fixed with the same method as
in the pdf backend (using the dviread module). Is there any reason not
doing this? While using the dviread seems to slow things down a bit, I
guess it is better being correct than being fast.

Regards,

-JJ

···

On Mon, Aug 18, 2008 at 6:09 PM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

Hi,

The pdf backend seems to return incorrect window extent (i.e., return
value of get_window_extent()) when usetex==True.
I'm attaching a small script to test this.

python test_text_window_extent.py -dPdf

Its results for the pdf backend with usetex==True is attached. For
comparison, results for the Agg backend with usetex==False (which
seems correct) is also attached.

I guess this bug is related with

http://article.gmane.org/gmane.comp.python.matplotlib.general/13997

-JJ