# ps and eps export with cairo in inkscape no usable with psfrag

Bug #375323 reported by fogman on 2009-05-12
This bug affects 30 people
Affects Status Importance Assigned to Milestone
Undecided
Unassigned
Nominated for 0.47.x by Ferdinand Rau
Nominated for 0.48.x by Ferdinand Rau

### Bug Description

In current svn inkscape versions (0.47 and later), pdf and ps/eps export is handled by cairo.
The problem is that cairo sometimes will export text as paths and sometimes with embeded fonts?!
Since the text is not exported as a whole plain text to ps/eps by cairo, psfrag in LaTeX is not capable of finding the to replaced text.

This makes inkscape and its eps export function for using with psfrag in LaTeX useless.

Older versions (like 0.46) of inkscape are working fine, with minor other/different problems in the ps/eps export.

Question to the developers: Is where a way of getting this resolved, for example with a question in the save dialog?
(So, that text is saved as whole without any fonts, since this text is replaced anyway.)
Or is there a special way inside cairo, which could solve this problem?

Tags: Edit Tag help
 ScislaC (scislac) wrote on 2009-05-12: #1

If you would kindly provide an example SVG, steps to reproduce the issue, and also a reference "bad" file, I will gladly confirm and bump importance due to it being a regression. Also, what versions of related software/libs are you using? (hopefully it will help to diagnose and potentially get a fix in sooner rather than later)

 fogman (sv) wrote on 2009-05-12: #2

Hello and thanks for the fast reply.

I have attached a simple svg file, crated with inkscape-svn from today under ubuntu (jaunty).
It is just a simple "Hello" which i then exported to eps.

Saved with:
1. Postscript Level 3
2. Export area is whole canvas (checked)
3. Export area is the drawing (checked)
4. Convert text to paths (NOT checked)
5. Rasterize filter effects (NOT checked)

In the corresponding/attached eps file, the "Hello" should be searchable with any texteditor in order to function with psfrag.
It is shown correctly with any eps/ps viewer, but the text is converted to paths? and therewith not findable.

 fogman (sv) wrote on 2009-05-12: #3
 Adrian Johnson (ajohnson-redneon) wrote on 2009-05-12: #4

The eps file contains a subsetted font and the "Hello" text. You won't see the string "Hello" inside the eps file because as a result of the subsetting the glyphs have been remapped to 1, 2, 3, ... etc

The part of the eps file that draws the "Hello" text is:

<0102030304>Tj

The subsetting is something that cairo does as it reduces the output size and allows complex scripts to be printed. This is not going to work with psfrag which according to the psfrag guide "relies on some sensitive PostScript tricks". Also since the subsetted font contains only the glyphs used, changing the text would not work if different glyphs are required.

 Alvin Penner (apenner) wrote on 2009-05-12: #5

I hate to ask a dumb question, but is this the origin of Bug 284680, which I personally find very upsetting?
If this is the case, then it seems that ideally we should have three different options for saving text:
1. save as glyphs (or what I previously thought was a bitmap because it looked 'binary')
2. save as a path, which is important to people using equipment like desktop cutting plotters
3. save as actual text, which is what I assume the originator of this report wants

 Alvin Penner (apenner) wrote on 2009-05-12: #6

of these options, the only one that currently works is option 1, afaict

 Alvin Penner (apenner) wrote on 2009-05-13: #7

attached is a sample of the difference between 0.46 and 0.47.
the original svg file contains only text...

 Alvin Penner (apenner) wrote on 2009-05-14: #8

the attached file was saved in Inkscape 0.46 using the output type .ps (not Cairo) and _not_ 'text converted to paths'.
The .ps file still contains the original raw text.

 Alvin Penner (apenner) wrote on 2009-05-14: #9

the attached file was saved in Inkscape development version using output .ps and _not_ 'text converted to paths'.
The .ps file no longer contains the original raw text.

 fogman (sv) wrote on 2009-05-14: #10

Thanks Alvin,

this is exactly what i mean.
As a workaround, i'm still using 0.46 with its eps-exporting flaws.
But i'm afraid, that 0.47 is unasable for people like me writing scintific papers which needs to include graphics.
The text in these graphics needs to be replaced with other text and more seriuosly with math formular (using psfrag) from the LaTeX code.

I like inkscape very much and i'm used to it.
So, i already started to look inside the source code, but didn't find a good starting point for a solution.

Alvin Penner (apenner) on 2009-05-14
 Changed in inkscape: status: New → Confirmed
 Adrian Johnson (ajohnson-redneon) wrote on 2009-05-14: #11

The problem with psfrag is it only works with simple PostScript output. ie it assumes a Type 1 font with an 8-bit Latin encoding. Modern applications that support TrueType fonts and complex scripts use more sophisticated methods to generate PostScript output. Generally this means subsetting the fonts since TrueType fonts may have up to 65536 glyphs while PostScript fonts only support 256. Also many TrueType fonts are quite large and would exceed memory limitations of some printers.

Doesn't Effects->Render->LaTeX formula provide the same functionality as psfrag?

If you are interested in working on the code for PostScript output, the library used is cairographics.org.

 fogman (sv) wrote on 2009-05-14: #12

Effects->Render->LaTeX formula is almost providing the same effect.
The drawback from this is, that once you change the font or/and its size, then you have to redo all the work in inkscape.
With psfrag, you only need one re-compilation of the LaTeX source.

Lets see, if i find some more time to look into the cairo eps+ps+pdf export functionality.

 fogman (sv) wrote on 2009-05-29: #13

Hello all,

I did some work on that issue today by looking into the cairo code.
As Adrian pointed out earlier, cairo will subset the string.

One possible workaround i'm doing right now is to find these subsettings.
In the provided example from above, this would be:

<0102030304>Tj

By removing the "<0102030304>Tj" part and putting "(Hello)Tj" at the same place will destroy the specific text in the eps.
Instead of the text, rectangles with the font size are drawn.
But psfrag is now capable to find the exact position of "Hello" inside the eps figure.
The graphic as itself is not touched. (If there would be any graphic e.g. Line, dots etc. in the eps file.)

This is a dirty hack, but it works for me at the moment.

Btw. ps2text, ps2ascii and others will not work with the cairo ps+pdf export!
Someone should file a Bug report to them.

This Bug should be closed, since it is more related to cairo!

Thanks.

 emw (emw-bugs-inkscape) wrote on 2009-10-03: #14

Hi all,

I just hit the same problem described by fogman while trying to prepare a figure with inkscape 0.47pre3 for some latex paper using psfrag. The reason for using psfrag is a kind of "coding style", because I use a lot of complex symbols/equations defined by \newcommand statements in the latex document. For a consistent layout, I'd highly prefer to reuse these commands via psfrag in the figures.

Although I learned from the comments above that this issue is more related to cairo, my question would be if there is some news for inkscape users. For my colleagues and me, inkscape is currently *the* tool of choice, however, for stability reasons, we'd like to upgrade to the new release. For me, it's currently possible to have both inkscape 0.46 (for eps export) and 0.47 (for editing) installed. However, I fear, that other people relying on binary packages or complete linux distributions might experience some problems using the new release.

Is there any related bug or feature request reported for cairo? Any way to steer cairo's behavior by the inkscape GUI?

Anyway, thanks a lot to the inkscape team for the nice new 0.47!

Best regards,
Martin

 Adrian Johnson (ajohnson-redneon) wrote on 2009-10-04: #15

I'm currently looking into making cairo emit "(some text)" style PostScript strings for latin text. This will make psfrag work again.

Until this feature is available in a released version of cairo I suggest using 0.46 or the overpic.sty package for doing your labels.

 quazgar (quazgar) wrote on 2009-10-27: #16

The same regression bug over at freedesktop:
https://bugs.freedesktop.org/show_bug.cgi?id=23551

 nclm (nclm) wrote on 2009-10-27: #17

Is there a compilded version of 0.46 for Karmic? I tried the latest build 0.46 Karmic build from http://launchpadlibrarian.net/27807795/inkscape_0.46-9ubuntu1_i386.deb but that version segfaults...

 su_v (suv-lp) wrote on 2009-10-27: #18

@Adrian - if possible, could you please take a look at bug #271695 “Kerned text embeds too many fonts and blows up the file size in EPS/PS” if it is related to this switch to cairo PS/EPS export or if it is an Inkscape bug? It only is reproducible with win32 builds however, not on osx (no tests on linux so far).

 alfazaz (yalmeras) wrote on 2009-11-08: #19

I have the same bug... I cannot use eps export from inkscape 0.47 with psfrag and it's really a problem for me because I can't compile inkscape 0.46 on my new Mandriva 2010 (if it was possible, I could convert my svg of inkscape 0.47 into "good" eps for psfrag but...).

It's really annoying.

 Jiri Kosinka (jiri-kosinka) wrote on 2009-11-12: #20

Hi, I'm also using Inkscape, LaTeX and psfrag to write math papers. Now I need to downgrade inkscape from 0.47 to 0.46 to avoid the font problem mentioned above. So, please, include the 'text only' option for saving text in eps files in future versions of inkscape. Thank you.

su_v (suv-lp) on 2009-11-13
 Bas (sirslak) wrote on 2009-11-26: #21

I desperately hoped for a solution on this in 0.47! After having been made enthousiastic about Inkscape I created a bunge of nice svg drawings that I want to use them in my graduation thesis as eps with psfrag. They are stored on my pc since September awaiting better eps times (export functionality with plain text?) and now I still cannot use them. I hope there will become a quick solution available before I have to redo everything in e.g. ipe, my deadline is nearing...

Thanks for making this possible, because apart from this (Cairo) flaw I love Inkscape!

 nclm (nclm) wrote on 2009-11-26: #22

You can nstall 0.46 from jaunty repositories with its required dependencies...

 cmh (the-donkey) wrote on 2009-12-15: #23

@ Adrian: This would be wonderful, if in succeeding versions the option --export-embed-fonts could be somehow re-included.
I only can repeat and emphasize: Inkscape is *the* (free and most efficient) tool for creation of figures (block-diagram, flowcharts, ...) in e.g. mathematical or scientific papers. But without the possibility to export plain text within eps/ps files, it seems useless, when psfragging is considered. Therefore, I stay with 0.46 and hope for re-inclusion of the option ---export-embed-fonts YES/NO.

 jasonphysics (jason-physics-harvard) wrote on 2010-01-30: #24

psfrag is essential for making label font/size identical to the rest of the document -- extremely difficult when using the otherwise excellent Effects->Render->LaTeX. I too am forced to stick with 0.46

Does subsetting ruin the ability to copy text from an exported eps/pdf document in evince/acroread and pasting into a text document?

Can there be a simple way to turn off subsetting (especially for latin-only documents) or turn off font embedding?

 Adrian Johnson (ajohnson-redneon) wrote on 2010-01-30: Re: [Bug 375323] Re: ps and eps export with cairo in inkscape no usable with psfrag #25

jasonphysics wrote:
> psfrag is essential for making label font/size identical to the rest of
> the document -- extremely difficult when using the otherwise excellent
> Effects->Render->LaTeX. I too am forced to stick with 0.46

The cairo bug report linked from this bug contains a fix. It is waiting
for someone to test with psfrag.

> Does subsetting ruin the ability to copy text from an exported eps/pdf
> document in evince/acroread and pasting into a text document?

Did you try it? Did it not work for you?

> Can there be a simple way to turn off subsetting (especially for latin-
> only documents) or turn off font embedding?

Subsetting is required because PS fonts are limited to 256 characters.
TrueType/OpenType fonts can have up to 65535 glyphs.

 Lebostein (lebostein) wrote on 2010-02-02: #26

I have the same problem with 0.47 and psfrag....

 Sebastian Held (sebastian-held) wrote on 2010-02-10: #27

to get and compile the patch:

git clone git://anongit.freedesktop.org/~ajohnson/cairo
git checkout latin-subsets
./autogen.sh --prefix=/tmp/cairo
make
make install
LD_LIBRARY_PATH=/tmp/cairo/lib inkscape

This works out-of-the-box on a current Gentoo Linux.

 Johan Engelen (johanengelen) wrote on 2010-02-25: #28

Hi all, I think I have a 'work around' for you guys, that I like much better than using psfrag. Inkscape can now export to EPS/PDF with an extra LaTeX file that includes text and lays it on top of the PDF.
* http://wiki.inkscape.org/wiki/index.php/Release_notes/0.48#New_LaTeX_export_for_PDF.2FEPS.2FPS
* http://wiki.inkscape.org/wiki/images/SVG_in_LaTeX.pdf

Hope this solves your problem. Yes, I like the 'clean' 0.46 EPS export too, but this works much easier for me.

 su_v (suv-lp) wrote on 2010-02-25: #29

> Inkscape can now export to EPS/PDF with an extra LaTeX file
'now' = Inkscape 0.47+devel, BZR revision 9111

 Quang (quang) wrote on 2010-02-26: #30

Thanks. The solution described for the upcoming 0.48 (in May?) seems promising.

However I'm using Ubuntu Linux and not willing to compile source code, so I reverted to 0.46 (using a Jaunty package). I'll wait for the release of 0.48.

I have been using psfrag for more than 5 years. I second the need for an option to export .svg files to .eps files with the text intact.

 Johannes Tophøj Rasmussen (johannes-tophoj) wrote on 2010-02-26: #31

I agree. It seems unpractical to split the image into two files.

 Johan Engelen (johanengelen) wrote on 2010-02-27: #32

> It seems unpractical to split the image into two files.
Note that Inkscape does this automatically for you ! Please read the PDF document describing the feature (or let me know if it is unclear, so I can try and reword it)

 Johannes Tophøj Rasmussen (johannes-tophoj) wrote on 2010-02-28: #33

I understand that the file is created automatically and I am sure that the new feature will be useful to some. But I do not like to the idea of the 'full image' being represented by two files that must be distributed together for the image to be included properly in a latex document. As far as I understand from the instructions pdf you must specify references and write equations directly in the svg file. I presume that these could be edited in the accompanying .tex file at a later time, but I still think that a plain .eps file and psfrag is more versatile.

 Andreluiz Cunha (cunha1973) wrote on 2010-08-11: #34

Just tested the 0.48 - https://bugs.launchpad.net/inkscape/+bug/431781/
Problem remains.
0.46 still rules...

 Peter (hpek) wrote on 2010-09-19: #35

How can we put pressure on the guys who can do something - I want psfrag!!! :o)
(save to latex is not the same)

It seem to me that an even better solution would be to make psfrag understand glyphs.

 Denis Laxalde (dlax) wrote on 2010-09-19: #36

Inkscape 0.48 features new LaTeX export capabilities (for pdf or eps) which somehow make psfrag useless.
See: http://wiki.inkscape.org/wiki/index.php/Release_notes/0.48#New_LaTeX_export_for_PDF.2FEPS.2FPS

 Torsten Bronger (bronger) wrote on 2010-09-19: #37

You probably mean "superfluous" rather than "useless". But even "superfluous" is incorrect in my opinion. It is not only to be able to render text labels by LaTeX, it is also to be able to replace them with arbitrary LaTeX code. I've made heavy use of this feature in the past years. Although I can't present statistics, I'm very sure that only in trivial cases people just want to adjust the font when using psfrag. And I really don't want to have dollar signs or LaTeX command sequences with 30+ characters in my Inkscape drawings.

 Peter (hpek) wrote on 2010-09-20: #38

Laxalde I do not agree (even with Bronger's correction - "superfluous" rather than "useless") !

I do not want latex in my drawings. I do not want two files. I want to be able to preview my eps with (non-latex)labels. I want all my latex in the main document to be able to check for notation consistency.

My label examples(latex) :
alpha( \alpha )
xandy( $x+y$ )
water( \ce{H2O} )

Result - my eps is preview-able, and distributable as preliminary. I can correct my latex in one file e.g $H_2O$ to \ce{H2O}
(\ce is from mhchem)

 Zaar Hai (haizaar) wrote on 2010-09-20: Re: [Bug 375323] Re: ps and eps export with cairo in inkscape no usable with psfrag #39

On Mon, Sep 20, 2010 at 4:06 PM, Peter <email address hidden> wrote:
> Laxalde I do not agree (even with Bronger's correction - "superfluous"
> rather than "useless") !
+1 here. Also if I want to change formula with psfrag, I just edit it
in latex document. Doing it via inkscape requires much more mouse
clicking then replacing several letters in latex source text.

--
Zaar

 Frank Hellmann (certhas) wrote on 2010-09-30: #40

I second this, I remain stuck on pre Cairo versions of inkscape. For the adjustments I needed to do for my PhD thesis the current options of switching back to inkscape for every minor change in notation would have been torturous and added a few days to my writing at least. As I have hundreds of figures the additional files are a nuissance (though not prohibitive).

I have no time to try this now, but as a new workflow would it be possible to define macros in your main tex file and have inkscapes tex file call these macros?

E.g. have the latex in the svg be \water and then call it as

\begin{figure}
\centering
\newcommand{\water}{H$_2$O}
\def\svgwidth{\columnwidth} % sets the image width, this is optional
\input{image.pdf_tex}
\end{figure}

 Adrian Johnson (ajohnson-redneon) wrote on 2010-10-01: #41

This has been fixed in cairo git master.

 Zaar Hai (haizaar) wrote on 2010-10-03: #42

On Fri, Oct 1, 2010 at 1:32 PM, Adrian Johnson <email address hidden> wrote:
> This has been fixed in cairo git master.

 Adrian Johnson (ajohnson-redneon) wrote on 2010-10-03: #43

Previously cairo would use the glyph indices to draw text. For example the generated PostScript to print "Hello" would look something like:

<0102030304>Tj

The '<>' brackets indicates ascii hexadecimal values. The advantage of using this method is cairo can print any character, not just latin characters. The problem is if "Hello" is a psfrag tag, psfrag will not be able to find it.

Now cairo will separate out all used latin characters into a separate font subset and setup the correct font encoding so that the PostScript code to print "Hello" will be:

(Hello)Tj

Now psfrag can find the tag and replace the text. I have tested this with psfrag and it works for me.

 Zaar Hai (haizaar) wrote on 2010-10-03: #44

Thanks, Adrian! This sounds really nice! I hope this fix will arrive
to end-user distributions soon.

On Sun, Oct 3, 2010 at 4:55 PM, Adrian Johnson <email address hidden> wrote:
>
> Previously cairo would use the glyph indices to draw text. For example
> the generated PostScript to print "Hello" would look something like:
>
> <0102030304>Tj
>
> using this method is cairo can print any character, not just latin
> characters. The problem is if "Hello" is a psfrag tag, psfrag will not
> be able to find it.
>
> Now cairo will separate out all used latin characters into a separate
> font subset and setup the correct font encoding so that the PostScript
> code to print "Hello" will be:
>
> (Hello)Tj
>
> Now psfrag can find the tag and replace the text. I have tested this
> with psfrag and it works for me.
>
> --
> ps and eps export with cairo in inkscape no usable with psfrag
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Inkscape: A Vector Drawing Tool: Confirmed
>
> Bug description:
> In current svn inkscape versions (0.47 and later), pdf and ps/eps export is handled by cairo.
> The problem is that cairo sometimes will export text as paths and sometimes with embeded fonts?!
> Since the text is not exported as a whole plain text to ps/eps by cairo, psfrag in LaTeX is not capable of finding the to replaced text.
>
> This makes inkscape and its eps export function for using with psfrag in LaTeX useless.
>
> Older versions (like 0.46) of inkscape are working fine, with minor other/different problems in the ps/eps export.
>
> Question to the developers: Is where a way of getting this resolved, for example with a question in the save dialog?
> (So, that text is saved as whole without any fonts, since this text is replaced anyway.)
> Or is there a special way inside cairo, which could solve this problem?
>
> To unsubscribe from this bug, go to:
>

--
Zaar

 Torsten Bronger (bronger) wrote on 2010-10-03: #45

I'm very glad to hear this. If not other programs were affected, too, one cannot take it for granted that such a thing is fixed at all. The Postscript has been valid and for most cases working after all. Kudos!

 Mju (juels) wrote on 2010-10-21: #46

I do not know anything about Cairo, but I would also very much like to solve this problem.
If there is a fix as you mention Adrian, could you possibly describe what I should do in order to utilize cairo git master?

 Adrian Johnson (ajohnson-redneon) wrote on 2010-10-21: #47

Assuming you are on Linux the following steps will build cairo from git and make inkscape use it:

mkdir ~/cairo-git
cd ~/cairo-git

git clone git://anongit.freedesktop.org/git/pixman
cd pixman
./autogen.sh --prefix=$HOME/cairo-git make install cd ~/cairo-git git clone git://anongit.freedesktop.org/git/cairo cd cairo PKG_CONFIG_PATH=$HOME/cairo-git/lib/pkgconfig ./autogen.sh --prefix=$HOME/cairo-git make install and then start inkscape with LD_LIBRARY_PATH=$HOME/cairo-git/lib inkscape

 Christoph Buchner (bilderbuchi) wrote on 2010-10-21: #48

thanks for the great work (and easy-to-follow instructions)! so we can mark this as "fix committed"?

 Benjamin Biegel (benjamin-biegel) wrote on 2010-10-21: #49

I followed the steps and have successfully built and installed cairo. However, saving as .eps and using psfrag is still not working (also not using the (...)Tj notation). Anything i have missed?

Thanks :)
Benjamin

 Adrian Johnson (ajohnson-redneon) wrote on 2010-10-21: #50

Can you attach your eps output and tell me what the tag names are.

 tikey (post-tikey) wrote on 2010-10-22: #51

I tried to use the new cairo in Windows. What I did was:
- installing inkscape 0.48
- saving a picture with text from inkscape as an eps

The eps is obviously exported with the new cairo version (1.10.0 which should be the latest). Before, it was 1.8.8. Unfortunately the text is still in the ascii-notation.

Maybe you can help me with this. Which cairo version did you use, when you said that cairo now uses a (text)TJ notation?
Do I need any special settings when saving as an eps?

Thanks
Thomas

P.S. the saved eps looks s/th like this:

(it should contain one text "Hallo" and one "\command")

%%Creator: cairo 1.10.0 (http://cairographics.org)
%%CreationDate: Fri Oct 22 15:28:44 2010
%%Pages: 1
%%BoundingBox: 0 -1 282 268
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%BeginProlog
/cairo_eps_state save def
/dict_count countdictstack def
/op_count count 1 sub def
userdict begin
/q { gsave } bind def
/Q { grestore } bind def
/cm { 6 array astore concat } bind def
/w { setlinewidth } bind def
/J { setlinecap } bind def
/j { setlinejoin } bind def
/M { setmiterlimit } bind def
/d { setdash } bind def
/m { moveto } bind def
/l { lineto } bind def
/c { curveto } bind def
/h { closepath } bind def
/re { exch dup neg 3 1 roll 5 3 roll moveto 0 rlineto
0 exch rlineto 0 rlineto closepath } bind def
/S { stroke } bind def
/f { fill } bind def
/f* { eofill } bind def
/n { newpath } bind def
/W { clip } bind def
/W* { eoclip } bind def
/BT { } bind def
/ET { } bind def
/pdfmark where { pop globaldict /?pdfmark /exec load put }
{ globaldict begin /?pdfmark /pop load def /pdfmark
/cleartomark load def end } ifelse
/BDC { mark 3 1 roll /BDC pdfmark } bind def
/EMC { mark /EMC pdfmark } bind def
/cairo_store_point { /cairo_point_y exch def /cairo_point_x exch def } def
/Tj { show currentpoint cairo_store_point } bind def
/TJ {
{
dup
type /stringtype eq
{ show } { -0.001 mul 0 cairo_font_matrix dtransform rmoveto } ifelse
} forall
currentpoint cairo_store_point
} bind def
/cairo_selectfont { cairo_font_matrix aload pop pop pop 0 0 6 array astore
cairo_font exch selectfont cairo_point_x cairo_point_y moveto } bind def
/Tf { pop /cairo_font exch def /cairo_font_matrix where
{ pop cairo_selectfont } if } bind def
/Td { matrix translate cairo_font_matrix matrix concatmatrix dup
/cairo_font_matrix exch def dup 4 get exch 5 get cairo_store_point
/cairo_font where { pop cairo_selectfont } if } bind def
/Tm { 2 copy 8 2 roll 6 array astore /cairo_font_matrix exch def
cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind def
/g { setgray } bind def
/rg { setrgbcolor } bind def
/d1 { setcachedevice } bind def
%%EndProlog
11 dict begin
/FontType 42 def
/FontName /ArialMT def
/PaintType 0 def
/FontMatrix [ 1 0 0 1 0 0 ] def
/FontBBox [ 0 0 0 0 ] def
/Encoding 256 array def
0 1 255 { Encoding exch /.notdef put } for
Encoding 1 /uni0048 put
Encoding 2 /uni00...

 Benjamin Biegel (benjamin-biegel) wrote on 2010-10-22: #52

Thanks for your response, it was my mistake though, i used dvi2pdf, but after using dvi2ps it worked. So many thanks for the gudie! :)

Ben

 Christoph Buchner (bilderbuchi) wrote on 2010-10-22: #53

tikey: 1.1.10 is not new enough - the fixing commit happened after that. just follow the instructions in comment #47

 Mju (juels) wrote on 2010-10-22: #54

Thanks a lot, it worked like a charm...
I just needed to install a big-ass bunch of lib-packages for the autogen to work (sudo apt-get install build-essential autoconf automake intltool libglib2.0-dev libpng12-dev libgc-dev libfreetype6-dev liblcms1-dev libgtkmm-2.4-dev libxslt1-dev libboost-dev libpopt-dev libgsl0-dev libaspell-dev libtool
), but then it was smooth sailing from there :-)...

BR
mju

 Christoph Buchner (bilderbuchi) wrote on 2010-10-23: #55

1.1.10 is not new enough. Just follow the instructions in Adrian's post.

Sent from my phone.

On Oct 22, 2010 3:51 PM, "tikey" <email address hidden> wrote:

I tried to use the new cairo in Windows. What I did was:
- installing inkscape 0.48
folder of inkscape (thus replacing the existing libcairo-2.dll)
- saving a picture with text from inkscape as an eps

The eps is obviously exported with the new cairo version (1.10.0 which
should be the latest). Before, it was 1.8.8. Unfortunately the text is
still in the ascii-notation.

Maybe you can help me with this. Which cairo version did you use, when you
said that cairo now uses a (text)TJ notation?
Do I need any special settings when saving as an eps?

Thanks
Thomas

P.S. the saved eps looks s/th like this:

(it should contain one text "Hallo" and one "\command")

%%Creator: cairo 1.10.0 (http://cairographics.org)
%%CreationDate: Fri Oct 22 15:28:44 2010
%%Pages: 1
%%BoundingBox: 0 -1 282 268
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%BeginProlog
/cairo_eps_state save def
/dict_count countdictstack def
/op_count count 1 sub def
userdict begin
/q { gsave } bind def
/Q { grestore } bind def
/cm { 6 array astore concat } bind def
/w { setlinewidth } bind def
/J { setlinecap } bind def
/j { setlinejoin } bind def
/M { setmiterlimit } bind def
/d { setdash } bind def
/m { moveto } bind def
/l { lineto } bind def
/c { curveto } bind def
/h { closepath } bind def
/re { exch dup neg 3 1 roll 5 3 roll moveto 0 rlineto
0 exch rlineto 0 rlineto closepath } bind def
/S { stroke } bind def
/f { fill } bind def
/f* { eofill } bind def
/n { newpath } bind def
/W { clip } bind def
/W* { eoclip } bind def
/BT { } bind def
/ET { } bind def
/pdfmark where { pop globaldict /?pdfmark /exec load put }
{ globaldict begin /?pdfmark /pop load def /pdfmark
/cleartomark load def end } ifelse
/BDC { mark 3 1 roll /BDC pdfmark } bind def
/EMC { mark /EMC pdfmark } bind def
/cairo_store_point { /cairo_point_y exch def /cairo_point_x exch def } def
/Tj { show currentpoint cairo_store_point } bind def
/TJ {
{
dup
type /stringtype eq
{ show } { -0.001 mul 0 cairo_font_matrix dtransform rmoveto } ifelse
} forall
currentpoint cairo_store_point
} bind def
/cairo_selectfont { cairo_font_matrix aload pop pop pop 0 0 6 array astore
cairo_font exch selectfont cairo_point_x cairo_point_y moveto } bind def
/Tf { pop /cairo_font exch def /cairo_font_matrix where
{ pop cairo_selectfont } if } bind def
/Td { matrix translate cairo_font_matrix matrix concatmatrix dup
/cairo_font_matrix exch def dup 4 get exch 5 get cairo_store_point
/cairo_font where { pop cairo_selectfont } if } bind def
/Tm { 2 copy 8 2 roll 6 array astore /cairo_font_matrix exch def
cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind
def
/g { setgray } bind def
/rg { setrgbcolor } bind def
/d1 { setcachedevice } bind def
%%EndProlog
11 dict begin
/FontType 42 def
/FontName /ArialMT def
/PaintType 0 def
/FontMatrix [ 1 0 0 1 0 0 ] d...

 su_v (suv-lp) wrote on 2010-10-23: #56

Christoph Buchner wrote:
> 1.1.10 is not new enough. Just follow the instructions in Adrian's post.

It doesn't really help recommending Windows users to follow instructions that say "Assuming you are on Linux the following steps …"

Instructions to build cairo from source on Windows can be found at cairo's web site [1]. Note: The recipe was written for an older release version (1.8.8) and apparently not tested with later releases or git master. The instructions do not include how to get the sources from the git repository on Windows.

Alternatively maybe the instructions how to update the cairo libs from source for Inkscape's devlibs [2] are helpful too.

I don't know if there are current cairo builds from git master for Windows available to download. The win32 devlibs [3] for Inkscape 0.48 and current Inkscape development builds [4] still use cairo 1.8.8.

 Christoph Buchner (bilderbuchi) wrote on 2010-10-23: #57

@suv: point well taken, forgot about that. sry.

 Daniel Gölz (daniel-goelz) wrote on 2010-10-26: #58

Hello tikey and others,

have you been able to solve the problem for windows? If yes, would you please let me know, how you managed it.

Thanks,
Daniel

 Martin Weisenhorn (martin-weisenhorn) wrote on 2010-10-29: #59

Hello,

thank you very much for your efforts. I also would like to use inkskape to generate eps files and replace text with psfrag.
I really love Inkscape and the latex generated smart looking documents as well. Therefore it would be so great if someone could solve the problem for windows, too.

Martin

 Michael Otte (ottemw) wrote on 2010-11-27: #60

Thanks to Adrian for comment #47 and Mju for comment #54, These allowed me to fix the problem easily!!!
As with many of the other posters, I use Inkscape + psfrag + latex for writing scientific papers.

Michael Otte

 Sylvain Corlay (sylvain-corlay) wrote on 2010-12-03: #61

I also use Inkscape with psfrag and latex for writing scientific content. For the moment, I have to use an older version of Inkscape, 0.46 to handle this correctly. It would be so great if the problem was solved for windows.
Sylvain Corlay

 murmlgrmpf (rate007) wrote on 2010-12-14: #62

I want to second Micheal's post.

#54 Mju

solves the Problem.
Well done, I hope this fix will come with an release very soon so that everyone can enjoy the magic of psfrag.

 ZeMaria (bj-gracio) wrote on 2011-01-07: #63

How do you upgrade the cairo lib on Mac OS?

I have inkscape 0.48 which uses cairo 1.8.10 which still has the problem of not being recognized by psfrag. I downloaded the cairo lib from their website using their instructions. Nevertheless, it seems that it is not associated with the inkscape since it continues to build .eps files using cairo 1.8.10.

ZeMaria: "sudo port install cairo",
I have cairo 1.10.2 now.
The machine that builds inkscape also packs the cairo library into the app bundle.
So you need a development snapshot from a machine that has current libraries or build inkscape yourself.

 su_v (suv-lp) wrote on 2011-01-17: #65

The latest Mac OS X development builds from <http://inkscape.modevia.com/macosx-snap/?C=M;O=D> use cairo 1.10.2, but I do not know if the changes from git master (see comment #41 and 47) are in 1.10.2.

The Windows and Mac OS X packages of 0.48.1 (release imminent) will both include cairo 1.10.2.

 Adrian Johnson (ajohnson-redneon) wrote on 2011-01-24: #66

The latest development snapshot - cairo 1.11.2 contains the fix for this bug. The 1.10.x releases will not have this feature.

 jordi (jorx2002) wrote on 2011-03-17: #67

Here is my workaround to the problem:
- I have both versions installed, 0.48.1 and 0.46.
- I do my drawings with the nice 0.48.1 and save them as normal svg's.
- I export them to eps from the command line by using the 0.46 and through the command line :
'inkscape.exe drawing.svg -E drawin.eps' (so this is executed from the 0.46 directory)
I'm doing that on a mac but using the windows versions of inkscape running on wine. Note that the 0.46 does not work with new macs...
Long life psfrag!
Jordi Artigas

 Richard Mathie (richard-mathie) wrote on 2011-09-18: #68

hey guys this work around works most of the time but still breaks on longer tags, for instance tags with brackets in them "()" and also, strangely when there is a "t" followed by another letter see the 2 attached files.

12 0 0 12 101.216587 119.593786 Tm
/f-1-1 1 Tf
<01>Tj
/f-1-0 1 Tf
(he)Tj
/f-1-1 1 Tf
<01>Tj
/f-1-0 1 Tf
(a)Tj
ET

I think this should this be

12 0 0 12 101.216587 119.593786 Tm
/f-1-0 1 Tf
(theta)Tj
/f-1-1 1 Tf
ET

what's going on????

 Adrian Johnson (ajohnson-redneon) wrote on 2011-09-19: #69

I'm not sure why the 'T' character is not working. Can attach your SVG file. Are you using the very latest cairo git master? There have been some recent fixes.

The problem with using "()" is PostScript uses "(" and ")" as the string delimiters so when using "()" inside a string it must be escaped with a backslash.

On longer strings you may find the strings get split up because Inkscape is not using accurate glyph advances to position the characters. Inkscape supplies cairo with a string of glyphs along with the x, y coordinate of each glyph. If the x,y coordinate of each glyph is not exactly at the glyph advance of the previous glyph, cairo cannot output a contiguous string. Instead it has to reposition the glyphs to the required x, y.

 Richard Mathie (richard-mathie) wrote on 2011-09-19: #70

yes I was using the latest (last few days) git clone, here is the attached instance

 Adrian Johnson (ajohnson-redneon) wrote on 2011-09-19: #71

I've just pushed a fix for the 't' bug. Thanks for the bug report and test case.

 Richard Mathie (richard-mathie) wrote on 2011-09-19: #72

thanks that now works for "t", but getting similar starnge results for "T" see the attached svg results in an error with "Tw"

(qw)Tj
5.5 -11.5 Td
[(T)70(w)]TJ
4 3 Td
(Tf)Tj
ET

is this a similar issue?

 Adrian Johnson (ajohnson-redneon) wrote on 2011-09-19: #73

The "70" in "[(T)70(w)]TJ" is kerning. It brings the "w" 70/1000 font space units closer to the "T". The font you are using has a kerning value for the "Tw" pair. I suggest using a monospace font for your tags.

 Leopold Palomo-Avellaneda (wd-leo) wrote on 2011-09-28: #74

I have followed this bug because I'm a PSFrag + inkscape user. I don't think that manually change (bla bla bla)Tj for some tag would be a good solution.

The bug is solved ("partially") in the cairo lib [1]. Dia, using another option in the export menu (encapsulated postscript using postscript latin-1 fonts).

Regards,

Leo

 Kai Ritterbusch (kai-ritterbusch) wrote on 2011-09-29: #75

Hey all,

I am following this bug because Im also using Inkscape together with psfrag.

I think that I found a bug in the patched cairo lib from Post # 47:

It is not able to export a checkerboard Ive drawn into EPS. Without the patched cairo lib, it works as expected.

Im running Ubuntu 10.4,
inkscape: 0.47
libcairo2: 1.8.10

Maybe this problem is solved in a newer version of the library or inkscape?

 Alvin Penner (apenner) wrote on 2011-09-29: #76

I cannot detect any problems with the chessboard using Inkscape 0.48.2. Could you provide details, which export options were used, what error messages were produced?

 Kai Ritterbusch (kai-ritterbusch) wrote on 2011-09-29: #77

Hey,

the problem appears when using Inkscape 0.47 together with the patch proposed in #47. I can try to install 0.48.2 and check.

No message appears, but the EPS file is wrong. It basically only draws the upper left corner of the picture, while everythin else remains white. This is also true if you place this chessboard anywhere in a larger document. only the upper left corner is drawn.

I attached my resulting EPS file.

 Kai Ritterbusch (kai-ritterbusch) wrote on 2011-09-29: #78

Oh for the export details: Postscript type 3, everything unchecked except "rasterize filter effects" but also tried other options

 Leopold Palomo-Avellaneda (wd-leo) wrote on 2011-09-29: #79

well, in the inkscape documentation is clear [1] . The question is that it's not practical to modify every text you put in a svg file in the way that psfrag understand it.

I understand that this bug is not about inkscape, it's about cairo. However, as I have said, this bug is solved in the cairo lib, you _only_ have to include a new entry in the export option (or in the eps/ps) option to call the cairo function that doesn't use the cairo fonts and use a Latin-1 fonts.

Whatever I draw with inkscape, if I put a text (p.ex tag1), when I export it to eps, I don't see a tag1 text, (because cairo lib) I see something like:

[<010203>-1<0405>-1<06>-1<07>1<08>129<090a06>]TJ

but If I use that option of the cairo lib, I got a (tag1)TJ, that it's wahtever the psfrag users wants.

I hope I have been clear.

 Adrian Johnson (ajohnson-redneon) wrote on 2011-09-29: #80

There is no cairo function for using Latin-1 fonts. The latest version of cairo in git (see comment 47) will automatically use latin fonts for all latin characters used. This functionality is not yet in a released version of cairo. If you want Inkscape to use latin fonts in PS export you have to compile cairo from git.

 Kai Ritterbusch (kai-ritterbusch) wrote on 2011-09-29: #81

Hi all,

I installed 0.48.0. running with the stable cairo libs it exports the chessboard correctly, but it still fails with the patched one.

 Leopold Palomo-Avellaneda (wd-leo) wrote on 2011-09-29: #82

A Dijous 29 Setembre 2011, Adrian Johnson va escriure:
> There is no cairo function for using Latin-1 fonts. The latest version
> of cairo in git (see comment 47) will automatically use latin fonts for
> all latin characters used. This functionality is not yet in a released
> version of cairo. If you want Inkscape to use latin fonts in PS export
> you have to compile cairo from git.

It's curious. I think that _you_ or someone with the same name make the patch
and fix the bug on the cairo lib on 2010-10-01 04:23:55 PDT [1] however, your
are saying that the cairo 1.10.2 version was release on 2010-12-25, without

Anyway, I suppose that dia make some work with this job, because although uses
the same library (libcairo), it can exports to eps with the latin-1 fonts.

Well, lets wait till cairo release a new version (please, could you help? )
and then inkscape incorporate this functionality.

Best regards

https://bugs.freedesktop.org/show_bug.cgi?id=23551#c13

 Adrian Johnson (ajohnson-redneon) wrote on 2011-09-29: #83

When cairo 1.10.0 was released a 1.10 branch in the git repository was created for bug fixes. 1.10.x releases are from this branch. The latin font subsetting is a new feature so it was committed to the master branch (or trunk in svn nomenclature).

 Kai Ritterbusch (kai-ritterbusch) wrote on 2011-10-27: #84

a follow up to posts 77,78 and 81: The dark rectangles were not gray but black with a transparency. I changed it to real gray via RGB values and it works.

 Min Gi Lee (mbcgoenter) wrote on 2011-11-10: #85

this is a little comment on following inkscape's policy, not psfrag.

recently, I gave up to use psfrag (for several reasons,...) and I decided to follow the policy as in the inkscape's wiki pages,

eps+latex, it produces a small latex document, like 'fig.eps_tex'.

one is supposed to use like

\begin{figure}

\def{\svglength}[5cm]
\input{fig1.eps_tex}
\def{\svglength}[5cm]
\input{fig2.eps_tex}

\end{figure}

I only wanted to put two eps files in same line, i mean two figures to be listed horizontally, but it was not possible and the reason was so funny that

the produced latex file 'fig1.eps_tex' start with the blank line(in fact, after the long comments), the blank line is imported to original tex document that caused to generate another paragraph!

So I erased the blank line and I could put my figures on same line and I believe the produced tex file should erase "this first blank line" to be used in general context.

 Christoph Buchner (bilderbuchi) wrote on 2011-11-10: #86

This is a separate bug, please file it separately, otherwise it won't get noticed!

 Joost Ellerbroek (j-ellerbroek) wrote on 2011-11-21: #87

Hello,

I'm still having some problems, even with the latest git build, and all my svg's converted to monospaced text.
I've attached an example where eps export goes wrong.

 Joost Ellerbroek (j-ellerbroek) wrote on 2011-11-21: #88

A small update: when I change the font from "DejaVu Sans Mono" to "freemono" the problem disappears. Maybe "DejaVu Sans Mono" isn't monospaced, even though the name suggests it?

To avoid these problems, would it be possible to add an option to the export dialog that lets you disable kerning?

 Joost Ellerbroek (j-ellerbroek) wrote on 2011-11-21: #89

yet another small update: after changing all my svg's from "DejaVu Sans Mono" to "freemono", other text labels start to go wrong: some work fine with DejaVu but not with freemono, and the other way around. I've attached another example that goes wrong with freemono.

 Adrian Johnson (ajohnson-redneon) wrote on 2012-03-26: #90

Now that cairo 1.12 has now been released, psfrag compatible postscript output is available with a stable version of cairo. However inkscape will need to ensure that no kerning is used for the psfrag tags to work.

 Christoph Buchner (bilderbuchi) wrote on 2012-03-26: #91

Should this (the kerning issue) maybe be reported in a separate bug report?

 Tinne De Laet (tinne-delaet) wrote on 2012-04-26: #92

I have been using the solution proposed in #47 for a long period successfully!
However yesterday, I upgraded my computer and I had to recompile pixman and cairo.
Afterwards I have a lot of problems with psfrag
* some text is not visible in the exported eps file
* some text is visible in the exported eps file but when replaced, the original text is also still visible in the generated pdf file

I tried different scenarios and it is hard to find consistency in the behavior. In some cases just moving the text to some other part of my svg will result in it being invisible in the exported eps file.

Is there someone who has similar problems or has a solution?

 Marc Gegnon (azzzt) wrote on 2012-05-11: #93

I tried to compile cairo 1.12 for Windows following the instrucions from http://cairographics.org/end_to_end_build_for_win32/. Since this manual is not up-to-date I had to make quite some modificiations to finally compile cairo. In the end I succeeded and got a file cairo.dll that I took to replace the libcairo-2.dll in the inkscape folder. But sadly this was not enough. When inkscape starts I receive the message:

I am pretty sure this has to do with Freetype, so I tried to included freetype in the compilation procedure via setting in the makefile "CAIRO_HAS_FT_FONT=1". But there I just could not get any further. I receive error messages like this

Creating library release/cairo.lib and object release/cairo.exp
cairo-ft-font.obj : error LNK2019: unresolved external symbol _FT_Done_Face referenced in function __font_map_release_face_lock_held

I don't know really know what do now. Did anybody of you guys accomplish to compile the cairo.dll succefully? Or does anybody know how get rid of this cairo-ft-font.obj : error LNK2019?

I also tried to compile cairo via cygwin, but with resulting file inkscape is not able to start anymore.

 Marc Gegnon (azzzt) wrote on 2012-05-14: #94

Finally, I was able to compile the latest cairo source code, following the instructions from here
http://wiki.inkscape.org/wiki/index.php/Inkscape_Devlibs and here
http://wiki.inkscape.org/wiki/index.php/Compiling_Inkscape_on_Windows

There was some issue with libpng. I downloaded the latest libpng from here http://www.gtk.org/download/win32.php and copied it into MSyS and then it kinda worked. It had some error message but I still received the attached files, which enabled me to use Inkscape 0.48.2.1 with psfrag. So if one uses windows, psfrag now should work with inkscape. One just has to copy the attached files into the inkscape home directory. If there appears a message that libpng12.dll cannot be found, copying libpng12-0.dll seems to seal the deal.

As commented before there is some issue with kerning. Probably this should be a new bug, see https://bugs.freedesktop.org/show_bug.cgi?id=49902
Words longer than 6 characters do not get replaced, even when using monospaced fonts.

 superbenrique (j-c-bennett) wrote on 2012-08-25: #95

This was driving me crazy. Thanks Marc Gegnon for sorting me out - your efforts are much appreciated.

 Ferdinand Rau (rauferd) wrote on 2013-11-08: #96

I have been using the 48.x series for a several months now and both the new pdf+latex and the cairo eps export work reliably.

Unfortunately, like others, I still experience the kerning issue (see #72 https://bugs.launchpad.net/inkscape/+bug/375323/comments/72 ) for longer texts - even when using the Monospace font. However, in my opinion this is not directly related to this issue.
Therefore, as bilderbuchi suggested in #91 https://bugs.launchpad.net/inkscape/+bug/375323/comments/91 , I submitted a new bug report for this issue: https://bugs.launchpad.net/inkscape/+bug/1249361

In my opinion the original issue with Cairo (psfrag compatibility) is fixed.