edeaaeac6786fbdc305593b1ad36e9a20a2cf3f1
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
40 unsigned short _dpi;
41 bool _bitmap;
42 std::set<std::string> _latin1_encoded_fonts;
43 bool _newlatin1font_proc_defined;
45 GTree * _fonts;//maps fonts used in the document, to (value=)"TRUE" only if the font was effectively embedded, "FALSE" if not.
47 //map strings of font types to enumeration of int values
48 std::map<std::string, FontType> _fontTypesMap;
50 void print_bpath(SVGOStringStream &os, NArtBpath const *bp);
52 void print_fill_style(SVGOStringStream &os, SPStyle const *style, NRRect const *pbox);
53 void print_stroke_style(SVGOStringStream &os, SPStyle const *style);
55 char const *PSFontName(SPStyle const *style);
56 bool embed_t1(SVGOStringStream &os, font_instance* font);
57 bool embed_font(SVGOStringStream &os, font_instance* font);
59 void print_glyphlist(SVGOStringStream &os, font_instance* font, Glib::ustring unistring);
61 unsigned int print_image(FILE *ofp, guchar *px, unsigned int width, unsigned int height, unsigned int rs,
62 NR::Matrix const *transform);
63 void compress_packbits(int nin, guchar *src, int *nout, guchar *dst);
65 /* ASCII 85 variables */
66 guint32 ascii85_buf;
67 int ascii85_len;
68 int ascii85_linewidth;
69 /* ASCII 85 Functions */
70 void ascii85_init(void);
71 void ascii85_flush(SVGOStringStream &os);
72 inline void ascii85_out(guchar byte, SVGOStringStream &os);
73 void ascii85_nout(int n, guchar *uptr, SVGOStringStream &os);
74 void ascii85_done(SVGOStringStream &os);
77 public:
78 PrintPS(void);
79 virtual ~PrintPS(void);
81 /* Print functions */
82 virtual unsigned int setup(Inkscape::Extension::Print *module);
83 /*
84 virtual unsigned int set_preview(Inkscape::Extension::Print *module);
85 */
87 virtual unsigned int begin(Inkscape::Extension::Print *module, SPDocument *doc);
88 virtual unsigned int finish(Inkscape::Extension::Print *module);
90 /* Rendering methods */
91 virtual unsigned int bind(Inkscape::Extension::Print *module, NR::Matrix const *transform, float opacity);
92 virtual unsigned int release(Inkscape::Extension::Print *module);
93 virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment);
94 virtual unsigned int fill(Inkscape::Extension::Print *module, const_NRBPath const *bpath, NR::Matrix const *ctm, SPStyle const *style,
95 NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
96 virtual unsigned int stroke(Inkscape::Extension::Print *module, const_NRBPath const *bpath, NR::Matrix const *transform, SPStyle const *style,
97 NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
98 virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
99 NR::Matrix const *transform, SPStyle const *style);
100 virtual unsigned int text(Inkscape::Extension::Print *module, char const *text,
101 NR::Point p, SPStyle const *style);
103 bool textToPath(Inkscape::Extension::Print *ext);
104 static void init(void);
105 bool fontEmbedded (Inkscape::Extension::Print * ext);
106 };
108 } /* namespace Internal */
109 } /* namespace Extension */
110 } /* namespace Inkscape */
113 #endif /* !EXTENSION_INTERNAL_PS_H_SEEN */
115 /*
116 Local Variables:
117 mode:c++
118 c-file-style:"stroustrup"
119 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
120 indent-tabs-mode:nil
121 fill-column:99
122 End:
123 */
124 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :