Code

5f3388d55c3eb17e38c6d77b73ce993cf1447c09
[inkscape.git] / src / extension / internal / ps.h
1 #ifndef EXTENSION_INTERNAL_PS_H_SEEN
2 #define EXTENSION_INTERNAL_PS_H_SEEN
4 /** \file
5  * Declaration of PrintPS, the internal module used to do Postscript Printing.
6  */
7 /*
8  * Authors:
9  *         Lauris Kaplinski <lauris@kaplinski.com>
10  *         Ted Gould <ted@gould.cx>
11  *
12  * Lauris' original code is in the public domain.
13  * Ted's changes are licensed under the GNU GPL.
14  */
16 #include <config.h>
17 #include "extension/extension.h"
18 #include "extension/implementation/implementation.h"
19 #include <set>
20 #include <string>
22 #include "libnr/nr-path.h"
24 #include <libnrtype/font-instance.h>
26 #include "svg/stringstream.h"
28 namespace Inkscape {
29 namespace Extension {
30 namespace Internal {
32 typedef enum {FONT_TYPE1, FONT_TRUETYPE} FontType;
34 class PrintPS : public Inkscape::Extension::Implementation::Implementation {
35     float _width;
36     float _height;
37     FILE * _begin_stream;//stream to print prolog and document setup of EPS, if font embedding
38     FILE * _stream;//(main) stream to print the (E)PS output, or only the script part following prolog/document setup, if font embedding
39     Glib::ustring _tmpfilename;
41     unsigned short _dpi;
42     bool _bitmap;
43     std::set<std::string> _latin1_encoded_fonts;
44     bool _newlatin1font_proc_defined;
46     GTree * _fonts;//maps fonts used in the document, to (value=)"TRUE" only if the font was effectively embedded, "FALSE" if not.
48     //map strings of font types to enumeration of int values
49     std::map<std::string, FontType> _fontTypesMap;
51     void print_bpath(SVGOStringStream &os, NArtBpath const *bp);
53     void print_fill_style(SVGOStringStream &os, SPStyle const *style, NRRect const *pbox);
54     void print_stroke_style(SVGOStringStream &os, SPStyle const *style);
56     char const *PSFontName(SPStyle const *style);
57     bool embed_t1(SVGOStringStream &os, font_instance* font);
58     bool embed_font(SVGOStringStream &os, font_instance* font);
60     void print_glyphlist(SVGOStringStream &os, font_instance* font, Glib::ustring unistring);
62     unsigned int print_image(FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs,
63                              NRMatrix const *transform);
64     void compress_packbits(int nin, guchar *src, int *nout, guchar *dst);
66     /* ASCII 85 variables */
67     guint32 ascii85_buf;
68     int ascii85_len;
69     int ascii85_linewidth;
70     /* ASCII 85 Functions */
71     void ascii85_init(void);
72     void ascii85_flush(SVGOStringStream &os);
73     inline void ascii85_out(guchar byte, SVGOStringStream &os);
74     void ascii85_nout(int n, guchar *uptr, SVGOStringStream &os);
75     void ascii85_done(SVGOStringStream &os);
78 public:
79     PrintPS(void);
80     virtual ~PrintPS(void);
82     /* Print functions */
83     virtual unsigned int setup(Inkscape::Extension::Print *module);
84     /*
85       virtual unsigned int set_preview(Inkscape::Extension::Print *module);
86     */
88     virtual unsigned int begin(Inkscape::Extension::Print *module, SPDocument *doc);
89     virtual unsigned int finish(Inkscape::Extension::Print *module);
91     /* Rendering methods */
92     virtual unsigned int bind(Inkscape::Extension::Print *module, NRMatrix const *transform, float opacity);
93     virtual unsigned int release(Inkscape::Extension::Print *module);
94     virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment);
95     virtual unsigned int fill(Inkscape::Extension::Print *module, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style,
96                               NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
97     virtual unsigned int stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, NRMatrix const *transform, SPStyle const *style,
98                                 NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
99     virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
100                                NRMatrix const *transform, SPStyle const *style);
101     virtual unsigned int text(Inkscape::Extension::Print *module, char const *text,
102                               NR::Point p, SPStyle const *style);
104     bool textToPath(Inkscape::Extension::Print *ext);
105     static void init(void);
106     bool fontEmbedded (Inkscape::Extension::Print * ext);
107 };
109 }  /* namespace Internal */
110 }  /* namespace Extension */
111 }  /* namespace Inkscape */
114 #endif /* !EXTENSION_INTERNAL_PS_H_SEEN */
116 /*
117   Local Variables:
118   mode:c++
119   c-file-style:"stroustrup"
120   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
121   indent-tabs-mode:nil
122   fill-column:99
123   End:
124 */
125 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :