1 #ifndef __gfxoutputdev_h__
2 #define __gfxoutputdev_h__
4 #include "../gfxdevice.h"
5 #include "../gfxsource.h"
6 #include "../gfxtools.h"
9 #include "InfoOutputDev.h"
12 typedef struct _fontlist
19 class GFXOutputState {
24 char transparencygroup;
31 gfxresult_t* grouprecording; // for transparency groups
32 gfxresult_t* softmaskrecording; // for soft masks
34 gfxdevice_t* olddevice;
37 typedef struct _parameter
41 struct _parameter*next;
44 void addGlobalFont(const char*filename);
45 void addGlobalLanguageDir(const char*dir);
46 void addGlobalFontDir(const char*dirname);
48 class GFXOutputDev: public OutputDev {
53 GFXOutputDev(parameter_t*p);
54 void setDevice(gfxdevice_t*dev);
57 virtual ~GFXOutputDev() ;
59 void setMove(int x,int y);
60 void setClip(int x1,int y1,int x2,int y2);
61 void setParameter(const char*key, const char*value);
63 void setInfo(InfoOutputDev*info) {this->info = info;}
66 void startFrame(int width, int height);
68 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
72 //----- get info about output device
74 // Does this device use upside-down coordinates?
75 // (Upside-down means (0,0) is the top left corner of the page.)
76 virtual GBool upsideDown();
78 // Does this device use drawChar() or drawString()?
79 virtual GBool useDrawChar();
81 virtual GBool interpretType3Chars();
83 //virtual GBool useShadedFills() { return gTrue; }
85 //----- initialization and control
87 void setXRef(PDFDoc*doc, XRef *xref);
90 virtual void processLink(Link *link, Catalog *catalog);
92 //----- save/restore graphics state
93 virtual void saveState(GfxState *state) ;
94 virtual void restoreState(GfxState *state) ;
96 //----- update graphics state
98 virtual void updateFont(GfxState *state);
99 virtual void updateFontMatrix(GfxState *state);
100 virtual void updateFillColor(GfxState *state);
101 virtual void updateStrokeColor(GfxState *state);
102 virtual void updateLineWidth(GfxState *state);
103 virtual void updateLineJoin(GfxState *state);
104 virtual void updateLineCap(GfxState *state);
105 virtual void updateFillOpacity(GfxState *state);
106 virtual void updateStrokeOpacity(GfxState *state);
107 virtual void updateFillOverprint(GfxState *state);
108 virtual void updateStrokeOverprint(GfxState *state);
109 virtual void updateTransfer(GfxState *state);
111 virtual void updateAll(GfxState *state)
114 updateFillColor(state);
115 updateStrokeColor(state);
116 updateLineWidth(state);
117 updateLineJoin(state);
118 updateLineCap(state);
121 //----- path painting
122 virtual void stroke(GfxState *state) ;
123 virtual void fill(GfxState *state) ;
124 virtual void eoFill(GfxState *state) ;
126 //----- path clipping
127 virtual void clip(GfxState *state) ;
128 virtual void eoClip(GfxState *state) ;
129 virtual void clipToStrokePath(GfxState *state);
132 virtual GBool useTilingPatternFill();
133 virtual GBool useShadedFills();
136 virtual void tilingPatternFill(GfxState *state, Object *str,
137 int paintType, Dict *resDict,
138 double *mat, double *bbox,
139 int x0, int y0, int x1, int y1,
140 double xStep, double yStep) {}
141 virtual void functionShadedFill(GfxState *state,
142 GfxFunctionShading *shading) {}
143 virtual void axialShadedFill(GfxState *state, GfxAxialShading *shading) {}
144 virtual void radialShadedFill(GfxState *state, GfxRadialShading *shading) {}
148 virtual void beginString(GfxState *state, GString *s) ;
149 virtual void endString(GfxState *state) ;
150 virtual void endTextObject(GfxState *state);
151 virtual void drawChar(GfxState *state, double x, double y,
152 double dx, double dy,
153 double originX, double originY,
154 CharCode code, int nBytes, Unicode *u, int uLen);
156 //----- image drawing
157 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
158 int width, int height, GBool invert,
160 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
161 int width, int height, GfxImageColorMap *colorMap,
162 int *maskColors, GBool inlineImg);
163 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
164 int width, int height,
165 GfxImageColorMap *colorMap,
166 Stream *maskStr, int maskWidth, int maskHeight,
168 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
169 int width, int height,
170 GfxImageColorMap *colorMap,
172 int maskWidth, int maskHeight,
173 GfxImageColorMap *maskColorMap);
175 //----- transparency groups and soft masks (xpdf >= ~ 3.01.16)
176 virtual void beginTransparencyGroup(GfxState *state, double *bbox,
177 GfxColorSpace *blendingColorSpace,
178 GBool isolated, GBool knockout,
180 virtual void endTransparencyGroup(GfxState *state);
181 virtual void paintTransparencyGroup(GfxState *state, double *bbox);
182 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor);
183 virtual void clearSoftMask(GfxState *state);
186 virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
187 virtual void endType3Char(GfxState *state);
189 virtual void type3D0(GfxState *state, double wx, double wy);
190 virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
192 void preparePage(int pdfpage, int outputpage);
194 char* searchForSuitableFont(GfxFont*gfxFont);
198 virtual GBool useDrawForm();
199 virtual void drawForm(Ref id);
200 virtual GBool needNonText();
201 virtual void endPage();
203 //virtual void dump();
204 //virtual void beginStringOp(GfxState *state);
205 //virtual void drawString(GfxState *state, GString *s);
206 //virtual void endStringOp(GfxState *state);
207 //virtual GBool getVectorAntialias() { return gFalse; }
208 //virtual void setVectorAntialias(GBool vaa) {}
209 //virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
212 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
213 int width, int height, GfxImageColorMap*colorMap, GBool invert,
214 GBool inlineImg, int mask, int *maskColors,
215 Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
216 int setGfxFont(char*id, char*name, char*filename, double maxSize, CharCodeToUnicode*ctu);
217 void strokeGfxline(GfxState *state, gfxline_t*line, int flags);
218 void clipToGfxLine(GfxState *state, gfxline_t*line);
219 void fillGfxLine(GfxState *state, gfxline_t*line);
221 void showfeature(const char*feature,char fully, char warn);
222 void warnfeature(const char*feature,char fully);
223 void infofeature(const char*feature);
225 char outer_clip_box; //whether the page clip box is still on
227 gfxfontlist_t*gfxfontlist;
229 GBool do_interpretType3Chars;
232 GFXOutputState states[64];
240 char* searchFont(const char*name);
241 char* substituteFont(GfxFont*gfxFont, char*oldname);
242 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
244 int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
245 int jpeginfo; // did we write "File contains jpegs" yet?
246 int pbminfo; // did we write "File contains jpegs" yet?
247 int linkinfo; // did we write "File contains links" yet?
249 int type3active; // are we between beginType3()/endType3()?
255 const char* substitutetarget[256];
256 const char* substitutesource[256];
259 int user_movex,user_movey;
260 int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
262 /* upper left corner of clipping rectangle (cropbox)- needs to be
263 added to all drawing coordinates to give the impression that all
264 pages start at (0,0)*/
270 gfxline_t* current_text_stroke;
271 gfxline_t* current_text_clip;
272 char* current_font_id;
273 gfxfont_t* current_gfxfont;
274 FontInfo*current_fontinfo;
275 gfxmatrix_t current_font_matrix;
282 int config_use_fontconfig;
283 int config_break_on_warning;
284 int config_remapunicode;
285 int config_transparent;
286 int config_extrafontdata;
288 parameter_t*parameters;
291 class GFXGlobalParams: public GlobalParams {
295 virtual DisplayFontParam *getDisplayFont(GString *fontName);
298 #endif //__gfxoutputdev_h__