added type3 char handling
[swftools.git] / lib / pdf / InfoOutputDev.h
1 /* InfoOutputDev.h
2    A special output device which collects information about a PDF file,
3    like fonts, Type3 glyphs and so on.
4
5    This file is part of swftools.
6
7    Swftools is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    Swftools is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with swftools; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
20
21 #ifndef __infooutputdev_h__
22 #define __infooutputdev_h__
23
24 #include "GfxFont.h"
25 #include "OutputDev.h"
26 #include "SplashFont.h"
27 #include "SplashOutputDev.h"
28 #include "SplashPath.h"
29 #include "GHash.h"
30
31 struct GlyphInfo
32 {
33     SplashPath*path;
34     int unicode;
35     int glyphid;
36     double x1,y1,x2,y2;
37 };
38
39 struct FontInfo
40 {
41     FontInfo();
42     ~FontInfo();
43     void grow(int size);
44
45     GfxFont*font;
46     double max_size;
47     int num_glyphs;
48     GlyphInfo**glyphs;
49     int*charid2glyph;
50     SplashFont*splash_font;
51     char seen;
52 };
53
54 extern char*getFontID(GfxFont*font);
55
56 class InfoOutputDev: public OutputDev 
57 {
58     GHash* id2font;
59     FontInfo* currentfont;
60     GlyphInfo* currentglyph;
61     SplashOutputDev*splash;
62     public:
63     int x1,y1,x2,y2;
64     int num_links;
65     int num_images;
66     int num_fonts;
67
68     InfoOutputDev(XRef*xref);
69     virtual ~InfoOutputDev(); 
70     virtual GBool useTilingPatternFill();
71     virtual GBool upsideDown();
72     virtual GBool useDrawChar();
73     virtual GBool interpretType3Chars();
74     virtual void startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2);
75     virtual void drawLink(Link *link, Catalog *catalog);
76     virtual double getMaximumFontSize(char*id);
77     virtual void updateFont(GfxState *state);
78
79     virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
80     virtual void type3D0(GfxState *state, double wx, double wy);
81     virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
82     virtual void endType3Char(GfxState *state);
83
84     virtual void drawChar(GfxState *state, double x, double y,
85                           double dx, double dy,
86                           double originX, double originY,
87                           CharCode code, int nBytes, Unicode *u, int uLen);
88     virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
89                                int width, int height, GBool invert,
90                                GBool inlineImg);
91     virtual void drawImage(GfxState *state, Object *ref, Stream *str,
92                            int width, int height, GfxImageColorMap *colorMap,
93                            int *maskColors, GBool inlineImg);
94     virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
95                                   int width, int height,
96                                   GfxImageColorMap *colorMap,
97                                   Stream *maskStr,
98                                   int maskWidth, int maskHeight,
99                                   GBool maskInvert);
100     virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
101                                       int width, int height,
102                                       GfxImageColorMap *colorMap,
103                                       Stream *maskStr,
104                                       int maskWidth, int maskHeight,
105                                       GfxImageColorMap *maskColorMap);
106     virtual FontInfo* getFont(char*id);
107 };
108
109 #endif //__infooutputdev_h__