I've been mulling over how best to handle compressed postscript files 
with InsetExternal.

<ramble>

insetgraphics.C has some special-casing code to handle compressed 
files (which latex can handle in their compressed state). Rather than 
retain this special-casing code in insetexternal.C, I wonder if it is 
possible to sweep it away entirely by defining Formats "ps_gz", 
"ps_bz2", "ps_Z".

I'm imagining a PostscriptImage external template

Template PostscriptImage
        InputFormat "ps, eps, ps_gz, ps_bz2, ps_Z"
        FileFilter "*.{ps,eps,ps.gz,ps.bz2,ps.Z}"
        Format LaTeX
                # LaTeX can handle these formats natively.
                # Ie, no conversion is required.
        FormatEnd
        Format PDFLaTeX
                UpdateFormat pdf
                UpdateResult "$$Basename.pdf"
        FormatEnd
TemplateEnd

It will require some modification to GetExtension in 
support/filetools.[Ch] to return these 'compressed formats' (should 
also be renamed as getFormat...), but no other compiled code I think. 
Just additions to the Formats and Converters.

The graphics display code would remain unchanged as
        string const filename = zippedFile(filename_) ?
                unzipFile(filename_) : filename_;

Does this sound like a plausible road-map?


Before I get carried away, however, I'll note that PostscriptImage and 
the existing RasterImage template differ only so:

Template RasterImage
        InputFormat "*"
        FileFilter "*.{gif,png,jpg,bmp,pbm,ppm,tga,tif,xpm,xbm}"
        Format LaTeX
                UpdateFormat eps
                UpdateResult "$$Basename.eps"
        FormatEnd
        Format PDFLaTeX
                UpdateFormat png
                UpdateResult "$$Basename.png"
        FormatEnd
TemplateEnd

In addition, I can imagine a PDFImage template that differs trivially 
again:

Template PDFImage
        InputFormat "pdf"
        FileFilter "*.pdf"
        Format LaTeX
                UpdateFormat eps
                UpdateResult "$$Basename.eps"
        FormatEnd
        Format PDFLaTeX
                # No conversion is required.
        FormatEnd
TemplateEnd

Somehow, it feels like we should be able to merge all three of these 
templates into an über template

Template ÜberImage
        InputFormat "*"
        FileFilter "*.{gif,png,jpg,bmp,pbm,ppm,tga,tif,xpm,xbm} 
                *.{ps,eps,ps.gz,ps.bz2,ps.Z}
                *.pdf"
        Format LaTeX
                UpdateFormat "ps, eps, ps_gz, ps_bz2, ps_Z"
                UpdateResult "$$Basename.$$FormatExtension"
        FormatEnd
        Format PDFLaTeX
                UpdateFormat "png, pdf"
                UpdateResult "$$Basename.$$FormatExtension"
        FormatEnd
TemplateEnd

This would require some modifications to the InsetExternal code to 
choose the appropriate UpdateFormat.

<\ramble>

Sorry for the rambling, but I'm unsure how best to proceed. Can you 
put me out of my misery?

-- 
Angus

Reply via email to