SWFFont now also stores the character widths
[swftools.git] / pdf2swf / swfoutput.h
1 /* swfoutput.h
2    Header file for swfoutput.cc (and swfoutput_x11.cc).
3
4    Part of the swftools package.
5
6    Copyright (c) 2001 Matthias Kramm <kramm@quiss.org> 
7
8    This file is distributed under the GPL, see file COPYING for details */
9
10 #ifndef __swfoutput_h__
11 #define __swfoutput_h__
12
13 #include <t1lib.h>
14 extern "C" {
15 #include "../lib/rfxswf.h"
16 }
17
18 extern int opennewwindow; //default:0
19 extern int ignoredraworder; //default:0
20 extern int drawonlyshapes; //default:0
21 extern int jpegquality; //default:100;
22 extern int storeallcharacters; // default:0
23
24 typedef long int twip;
25
26 struct swfmatrix {
27     double m11,m12,m21,m22,m13,m23;
28 };
29
30 struct swfcoord {
31     twip x;
32     twip y;
33 };
34
35 class SWFFont
36 {
37     T1_OUTLINE**outline;
38     char**charname;
39     int*width;
40     char*used;
41
42     char*name;
43     int charnum;
44
45     U16*char2swfcharid;
46     U16*swfcharid2char;
47     int swfcharpos;
48
49     public:
50     
51     int t1id;
52     char*fontid;
53     unsigned int swfid;
54
55     SWFFont(char*name, int t1id, char*filename);
56     SWFFont::~SWFFont();
57     T1_OUTLINE*getOutline(char*charname);
58     int getSWFCharID(char*name);
59     char*getName();
60     char*getCharName(int t);
61     int getCharWidth(int t) {return width[t];}
62 };
63
64 struct swfoutput 
65 {
66     //int t1font;
67     double fontm11,fontm12,fontm21,fontm22;
68     unsigned short int linewidth;
69     SWFFont*font;
70     RGBA strokergb;
71     RGBA fillrgb;
72 };
73
74 #define DRAWMODE_STROKE 1
75 #define DRAWMODE_FILL 2
76 #define DRAWMODE_EOFILL 3
77 #define DRAWMODE_CLIP 4
78 #define DRAWMODE_EOCLIP 5
79
80 void swfoutput_init(struct swfoutput*, char*filename, int sizex, int sizey);
81 void swfoutput_setprotected(); //write PROTECT tag
82
83 void swfoutput_newpage(struct swfoutput*);
84
85 void swfoutput_setfont(struct swfoutput*, char*fontid, int t1font, char*filename);
86 int swfoutput_queryfont(struct swfoutput*, char*fontid);
87 void swfoutput_setdrawmode(struct swfoutput*, int drawmode);
88 void swfoutput_setfillcolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
89 void swfoutput_setstrokecolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
90 void swfoutput_setfontmatrix(struct swfoutput*,double,double,double,double);
91 void swfoutput_setlinewidth(struct swfoutput*, double linewidth);
92
93 void swfoutput_drawchar(struct swfoutput*,double x,double y,char*a);
94 void swfoutput_drawpath(struct swfoutput*, T1_OUTLINE*outline, struct swfmatrix*m);
95 void swfoutput_startclip(struct swfoutput*, T1_OUTLINE*outline, struct swfmatrix*m);
96 void swfoutput_endclip(struct swfoutput*);
97 int swfoutput_drawimagejpeg(struct swfoutput*, char*filename, int sizex,int sizey, 
98         double x1,double y1,
99         double x2,double y2,
100         double x3,double y3,
101         double x4,double y4);
102 int swfoutput_drawimagelossless(struct swfoutput*, RGBA*pic, int sizex, int sizey,
103         double x1,double y1,
104         double x2,double y2,
105         double x3,double y3,
106         double x4,double y4);
107 int swfoutput_drawimagelossless256(struct swfoutput*, U8*pic,RGBA*pal, int sizex, int sizey,
108         double x1,double y1,
109         double x2,double y2,
110         double x3,double y3,
111         double x4,double y4);
112 void swfoutput_drawimageagain(struct swfoutput*, int id, int sizex, int sizey,
113         double x1,double y1,
114         double x2,double y2,
115         double x3,double y3,
116         double x4,double y4);
117
118 void swfoutput_linktopage(struct swfoutput*, int page, swfcoord*points);
119 void swfoutput_linktourl(struct swfoutput*, char*url, swfcoord*points);
120
121 void swfoutput_destroy(struct swfoutput*);
122
123 #endif //__swfoutput_h__