[cairo] Inkscape eps export for Latex

Adrian Johnson ajohnson at redneon.com
Sat Aug 29 23:56:09 PDT 2009


Bernd Bandemer wrote:
> Any ideas on a robust solution for this? I also noticed that the
> roadmap for Cairo has enabling/disabling certain subsetters scheduled
> for 2.12, but this is very far in the future... It would be great if a
> solution can be found sooner.

Currently as long as cairo is subsetting the font any hack based around 
substituting placeholder text will not work since the substituted text 
may use glyphs that are not in the subset.

Possible solutions are:

1) Fix Inkscape

The purpose of psfrag is to embed LaTex equations in the drawings. 
However Inkscape already provides this functionality with 
Extensions->Render->LaTeX formula. In a comment 12 on the Inkscape bug 
report [1] you pointed out that after embedding an equation in Inkscape, 
changing the font or font size requires requires reentering the 
equation. This appears to be because Inkscape converts the rendered 
equation to paths and embeds the paths in the SVG file.

This could be fixed if Inkscape also embedded the LaTex equation in the 
SVG file and automatically rerendered it when the font is changed. I'm 
not an SVG expert but reading the SVG 1.1 specification there is a 
"Foreign namespaces and private data" feature that can be used for 
"Application-specific information so that authoring applications can 
include model-level data in the SVG content to serve their 
"roundtripping" purposes".


2) Changes to cairo subsetting

One of the items on my TODO list is to look into providing the option to 
allow embedding non-subsetted fonts in PDF. This is so the PDF output 
can be roundtripped though applications that modify the PDF file. I am 
also planning to look into putting Latin text into a separate 8-bit 
subset from the 16-bit CID subset similar to what some other PDF files 
I've seen do.

Implementing both of these features for the PostScript backend will 
allow generating PostScript files with "(Some ASCII text)" style 
PostScript strings. Using "Tj" instead of "show" is not the issue since 
psfrag already handles redefinitions of the show operator.


3) Filter the cairo output

If using one of the standard PostScript fonts is acceptable it may be 
possible to write a script to substitute cairo subsetted placeholder 
text with the PostScript to select a standard PostScript font. You would 
need to ensure the placeholder text is in a different font to other text 
in the document to ensure the mapping between the placeholder text and 
the subset does not change when other text in the document is changed.

eg search for:

BT
20 0 0 20 100 742 Tm
/f-0-0 1 Tf
<01020304>Tj
ET

and replace with:

/Helvetica findfont
20 scalefont setfont
100 742 moveto
(Hello) show

If you can provide a simple test case for psfrag that I can test with I 
can look into how feasible this would be. If this works with the 
standard fonts you should be able to use any Type 1 font by inserting 
the Type 1 font into the PostScript file.


[1] https://bugs.launchpad.net/inkscape/+bug/375323/comments/12



More information about the cairo mailing list