After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 600972 - text in boxes not centred vertically when using tex / pgf export
text in boxes not centred vertically when using tex / pgf export
Status: RESOLVED FIXED
Product: dia
Classification: Other
Component: exports
0.97
Other Linux
: Normal normal
: 0.98
Assigned To: Dia maintainers
Dia maintainers
Depends on:
Blocks:
 
 
Reported: 2009-11-06 14:24 UTC by Stanislas Couix
Modified: 2011-06-10 10:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The drawing as it looks like in Dia. (1.28 KB, image/png)
2009-11-06 15:56 UTC, Stanislas Couix
  Details
The corrected tex file to have a vertically centred text. (1.35 KB, text/x-tex)
2009-11-06 15:58 UTC, Stanislas Couix
  Details
GuiHome_alignment_dia_file (1.69 KB, application/octet-stream)
2010-07-18 17:01 UTC, guihome
  Details
GuiHome_alignment_test orig tex output (11.67 KB, text/plain)
2010-07-18 17:05 UTC, guihome
  Details
GuiHome_alignment_test corr tex output (11.79 KB, text/plain)
2010-07-18 17:06 UTC, guihome
  Details
GuiHome_alignment_test corr2 tex output (12.21 KB, text/plain)
2010-07-18 17:07 UTC, guihome
  Details
GuiHome_alignment_test pdf output (37.13 KB, application/pdf)
2010-07-18 17:08 UTC, guihome
  Details
GuiHome_alignment_test dia render (66.11 KB, image/png)
2010-07-18 17:09 UTC, guihome
  Details
GuiHome proposed patch (720 bytes, patch)
2010-07-18 17:12 UTC, guihome
none Details | Review

Description Stanislas Couix 2009-11-06 14:24:01 UTC
Hi, 

I have recently filed a bug occuring when using pgf export with dia 0.96 : the text in the boxes were not centred horizontally and vertically. [https://bugzilla.gnome.org/show_bug.cgi?id=600418]

In dia 0.97 the bug is partially resolved : the text in now perfectly centred horizontally, but not vertically.
I have to manually add [anchor=base] to every node in the pgf export.

Step to reproduce the bug :
1. Draw any box with text centred horizontally and vertically
2. Export using tex/pgf export
3. Include the pgf export in a tex document and compile it using pdflatex.

Actual results:
--> In the pdf, the text in the box is centred horizontally but not vertically

Expected results:
--> Text hould be centred vertically and horizontally

Does this happen every time?
--> Yes

The bug is not really annoying as it can be overcome very easily.

I'm using ubuntu 9.04
Comment 1 Stanislas Couix 2009-11-06 15:56:03 UTC
Created attachment 147106 [details]
The drawing as it looks like in Dia.
Comment 2 Stanislas Couix 2009-11-06 15:58:20 UTC
Created attachment 147107 [details]
The corrected tex file to have a vertically centred text.
Comment 3 Hans Breuer 2009-11-06 16:08:49 UTC
So you are using horizontally centered text and I have not made myself clear enough in the recent comment in bug #600418. 
For left- or right-aligned text Dia already writes anchor=west or anchor=east. How is that to be combined with anchor=base?
Comment 4 Stanislas Couix 2009-11-06 16:54:27 UTC
I do some testing of the pgf export and there is no way to combine west or east with base... So you're right, my workaround only works with horizontally centred text...

I've done some testing and I've found another workaround. In the dia file, if the text is vertically aligned using 'First line' (translation form french, not sure if it's the same in english, it's the last choice you can make in the list of vertical alignement options), the text is vertically centred in the pdflatex output. Wierd !
 
Can this issue be related to the way the pgf export "calculate" the coordinates of the node text ?

Tell me if you need more information

PS : I've also done some testing with text on 2 lines with 'centred' and 'first line' vertical alignement and the text is never vertically centred. I don't know if it's a related issue...

Let me know if I can help in anyway

Thanks again for all the great work with dia!
Comment 5 Hans Breuer 2009-11-07 17:17:39 UTC
First line aligns the text with it's connection point at the base line. Seems like exactly what you want and not a work-around at all. Some slight difference between display and export might result from font difference.
Comment 6 Stanislas Couix 2009-11-09 09:39:04 UTC
(In reply to comment #5)
> First line aligns the text with it's connection point at the base line. Seems
> like exactly what you want and not a work-around at all.

Ok but it's wierd because in dia, the text is not centred vertically. Why it is in latex ??

> Some slight difference between display and export might result from font difference.

I am sure it's part of the problem. I've done some testing with text boxes with various size. The text is always put X pixel down. The X doesn't change at all. It's not multiplicated by ay factor. The discrepancy is not scaled (not sure if i'm really clear here...!).

I will try with several fonts to find one that match closely latex one.

thanks for all your answers !
Comment 7 guihome 2010-07-18 17:00:04 UTC
Hi, 

I had the same vertical alignment problems in FlowChart rectangle box when exporting to PGF.

digging into Dia code, into PGF doc and with additionnal tests I got to a solution working in all the cases you mentionned and also for two or more lines of text. However, it may require some more testing.

One cannont change how Dia "weirdly" computes the text position as this position seems to work well for other export plugins but one can change how PGF handles it. anchor=base west or anchor= base east combination seems to work for my pgf version (2.00-1). Stanislas had the same solution but I don't know why the combination base west did not work for him (what was his version ?)

so adding a base in any anchor (even when alignment is CENTER) could do the job for vertical centering and this also corrects basic text (not in flowchart boxes) positionning according to other objetcts (see attachements).

I also had horizontal positionning problems that seem to come from inner and outer padding added by PGF. Setting inner sep = 0pt and outer sep=0pt for each node does the trick.

In attachement is my alignment dia file, a picture how it looks like in dia, 3 tex files (orig with version 0.97-1, corr with anchor base added everywhere and corr2 with anchor + inner sep and outer sep = 0pt) and an output test pdf rendered with pdflatex with 3 corresponding pages. The last page matches the most how dia rendering looks like. also attached is the patch.

This is my first "complex" bug report + patch proposal, please be kind and explain me any mistakes in the procedure if any.
Comment 8 guihome 2010-07-18 17:01:03 UTC
Created attachment 166122 [details]
GuiHome_alignment_dia_file
Comment 9 guihome 2010-07-18 17:05:34 UTC
Created attachment 166123 [details]
GuiHome_alignment_test orig tex output
Comment 10 guihome 2010-07-18 17:06:24 UTC
Created attachment 166124 [details]
GuiHome_alignment_test corr tex output
Comment 11 guihome 2010-07-18 17:07:11 UTC
Created attachment 166125 [details]
GuiHome_alignment_test corr2 tex output
Comment 12 guihome 2010-07-18 17:08:20 UTC
Created attachment 166126 [details]
GuiHome_alignment_test pdf output
Comment 13 guihome 2010-07-18 17:09:23 UTC
Created attachment 166127 [details]
GuiHome_alignment_test dia render
Comment 14 guihome 2010-07-18 17:12:22 UTC
Created attachment 166128 [details] [review]
GuiHome proposed patch
Comment 15 Hans Breuer 2011-06-10 10:09:32 UTC
(In reply to comment #7)
> This is my first "complex" bug report + patch proposal, please be kind and
> explain me any mistakes in the procedure if any.

Patch looks fine, I've just pushed to master:
http://git.gnome.org/browse/dia/commit/?id=5c1fccd7489e4248e0f453f5665b78a4aaa71062

Thanks and sorry for the delay.