92928b9e42415eb573bdef693ec43f268ad01ff3
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 <libnrtype/font-instance.h>
24 #include "svg/stringstream.h"
26 namespace Inkscape {
27 namespace Extension {
28 namespace Internal {
30 typedef enum {FONT_TYPE1, FONT_TRUETYPE} FontType;
32 class PrintPS : public Inkscape::Extension::Implementation::Implementation {
33 float _width;
34 float _height;
35 FILE * _begin_stream;//stream to print prolog and document setup of EPS, if font embedding
36 FILE * _stream;//(main) stream to print the (E)PS output, or only the script part following prolog/document setup, if font embedding
38 unsigned short _dpi;
39 bool _bitmap;
40 std::set<std::string> _latin1_encoded_fonts;
41 bool _newlatin1font_proc_defined;
43 GTree * _fonts;//maps fonts used in the document, to (value=)"TRUE" only if the font was effectively embedded, "FALSE" if not.
45 //map strings of font types to enumeration of int values
46 std::map<std::string, FontType> _fontTypesMap;
48 void print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c );
49 void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv);
51 void print_fill_style(SVGOStringStream &os, SPStyle const *style, NRRect const *pbox);
52 void print_stroke_style(SVGOStringStream &os, SPStyle const *style);
54 char const *PSFontName(SPStyle const *style);
55 bool embed_t1(SVGOStringStream &os, font_instance* font);
56 bool embed_font(SVGOStringStream &os, font_instance* font);
58 void print_glyphlist(SVGOStringStream &os, font_instance* font, Glib::ustring unistring);
60 unsigned int print_image(FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs,
61 Geom::Matrix const *transform);
62 void compress_packbits(int nin, guchar *src, int *nout, guchar *dst);
64 /* ASCII 85 variables */
65 guint32 ascii85_buf;
66 int ascii85_len;
67 int ascii85_linewidth;
68 /* ASCII 85 Functions */
69 void ascii85_init(void);
70 void ascii85_flush(SVGOStringStream &os);
71 inline void ascii85_out(guchar byte, SVGOStringStream &os);
72 void ascii85_nout(int n, guchar *uptr, SVGOStringStream &os);
73 void ascii85_done(SVGOStringStream &os);
76 public:
77 PrintPS(void);
78 virtual ~PrintPS(void);
80 /* Print functions */
81 virtual unsigned int setup(Inkscape::Extension::Print *module);
82 /*
83 virtual unsigned int set_preview(Inkscape::Extension::Print *module);
84 */
86 virtual unsigned int begin(Inkscape::Extension::Print *module, SPDocument *doc);
87 virtual unsigned int finish(Inkscape::Extension::Print *module);
89 /* Rendering methods */
90 virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Matrix const *transform, float opacity);
91 virtual unsigned int release(Inkscape::Extension::Print *module);
92 virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment);
93 virtual unsigned int fill(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, Geom::Matrix const *ctm, SPStyle const *style,
94 NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
95 virtual unsigned int stroke(Inkscape::Extension::Print *module, Geom::PathVector const &pathv, Geom::Matrix const *transform, SPStyle const *style,
96 NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
97 virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
98 Geom::Matrix const *transform, SPStyle const *style);
99 virtual unsigned int text(Inkscape::Extension::Print *module, char const *text,
100 Geom::Point p, SPStyle const *style);
102 bool textToPath(Inkscape::Extension::Print *ext);
103 static void init(void);
104 bool fontEmbedded (Inkscape::Extension::Print * ext);
105 };
107 } /* namespace Internal */
108 } /* namespace Extension */
109 } /* namespace Inkscape */
112 #endif /* !EXTENSION_INTERNAL_PS_H_SEEN */
114 /*
115 Local Variables:
116 mode:c++
117 c-file-style:"stroustrup"
118 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
119 indent-tabs-mode:nil
120 fill-column:99
121 End:
122 */
123 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :