GNOME Bugzilla – Bug 688663
export to pgf latex: custom text colors are not kept in exported tikz file
Last modified: 2013-07-21 15:32:08 UTC
Hi, I just noticed the following bug in Dia 0.97.2: If I create some diagram with a text object, say "hello world", then change the text color of this object to some new individual color, and then export the diagram using "pgf latex macros", then the individually set text color is lost in the exported tikz file. I.e., if I use this exported tikz file in a latex document, then the text "hello world" inside the tikz file shows up again in black and *not* in the color, that I defined for it using dia. Hope this helps and you can reproduce this bug! Would be really cool, if someone could fix it quickly :-) Cheers!
Just reading the code shows that \pgfsetstrokecolor is set with the text color defined. Maybe it should just use \pgfsetfillcolor or something else. The PGF does not make it clear to me. If you can provide a simple Dia file and the - modified to be working - pgf file I will change the source accordingly.
Created attachment 229600 [details] dia-bug.dia: dia file in which the text color bug occurs during a PGF export
Created attachment 229601 [details] the PGF file exported from file dia-bug.dia
Created attachment 229602 [details] a manual change fixing the automatically exported faulty dia-bug.tex file
@Hans Breuer: Unfortunately, I don't have any insights into the PGF format either. As you pointed out, it seems that the export filter does not set the color of displayed text inside any node correctly (even though the color is set appropriately inside dia). A quick fix for this problem would be to simply surround all displayed text using a \textcolor{dialinecolor}{hello world} when exporting it to PGF. This is exemplified in the dia-bug-original.tex and dia-bug-fix.tex files, which I've comitted above and which solve the issue for me. However, I'm pretty certain that there is a better solution to this (i.e., a dedicated \pgf macro, which precisely allows to set the colors of texts). May be the author of the export filter can help here?! Cheers!
Created attachment 248257 [details] [review] Patch that fix pgf plugin render error on custom colors for text The color is passed as an option to the \node command, instead of set the line color.
I propose this solution to correct the problem. I modified the pgf render plugin and instead of setting the color of the line (which is still made to define a custom color), I pass the color directly into the option of the \node command.
Thanks for the patch, applied and pushed to master: https://git.gnome.org/browse/dia/commit/?id=013bbddb0b1cd92eb13bb3d8b2754d693d4eb822
Now really: https://git.gnome.org/browse/dia/commit/?id=0773ee77793219f1cbf69fab79d125558b83deae