added font2swf
[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,2002,2003 Matthias Kramm <kramm@quiss.org> 
7  
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
21
22 #ifndef __swfoutput_h__
23 #define __swfoutput_h__
24
25 #include <t1lib.h>
26 #ifdef T1ERR_SCAN_ENCODING //t1lib 5.0.0
27 #define T1_Get_no_fonts T1_GetNoFonts
28 #endif
29
30 extern "C" {
31 #include "../lib/rfxswf.h"
32 }
33
34 extern int enablezlib; //default:0
35 extern int opennewwindow; //default:0
36 extern int ignoredraworder; //default:0
37 extern int drawonlyshapes; //default:0
38 extern int jpegquality; //default:100;
39 extern int storeallcharacters; // default:0
40 extern int insertstoptag; //default:0
41 extern int flashversion; //default:4
42 extern int splinemaxerror; //default:1
43 extern int fontsplinemaxerror; //default:1
44
45 typedef long int twip;
46
47 struct swfmatrix {
48     double m11,m12,m21,m22,m13,m23;
49 };
50
51 struct swfcoord {
52     twip x;
53     twip y;
54 };
55
56 class SWFFont
57 {
58     T1_OUTLINE**outline;
59     char**charname;
60     int*width;
61     char*used;
62
63     char*name;
64     int charnum;
65
66     U16*char2swfcharid;
67     U16*swfcharid2char;
68     int swfcharpos;
69
70     char**standardtable;
71     int standardtablesize;
72
73     public:
74     
75     int t1id;
76     char*fontid;
77     unsigned int swfid;
78
79     SWFFont(char*name, int t1id, char*filename);
80     SWFFont::~SWFFont();
81     T1_OUTLINE*getOutline(char*charname, int charnr);
82     int getSWFCharID(char*name, int charnr);
83     int getWidth(char*name);
84     char*getName();
85     char*getCharName(int t);
86     int getCharWidth(int t) {return width[t];}
87 };
88
89 struct swfoutput 
90 {
91     //int t1font;
92     double fontm11,fontm12,fontm21,fontm22;
93     unsigned short int linewidth;
94     SWFFont*font;
95     RGBA strokergb;
96     RGBA fillrgb;
97 };
98
99 #define DRAWMODE_STROKE 1
100 #define DRAWMODE_FILL 2
101 #define DRAWMODE_EOFILL 3
102 #define DRAWMODE_CLIP 4
103 #define DRAWMODE_EOCLIP 5
104
105 void swfoutput_init(struct swfoutput*, char*filename, int sizex, int sizey);
106 void swfoutput_setprotected(); //write PROTECT tag
107
108 void swfoutput_newpage(struct swfoutput*);
109
110 void swfoutput_setfont(struct swfoutput*, char*fontid, int t1font, char*filename);
111 int swfoutput_queryfont(struct swfoutput*, char*fontid);
112 void swfoutput_setdrawmode(struct swfoutput*, int drawmode);
113 void swfoutput_setfillcolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
114 void swfoutput_setstrokecolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
115 void swfoutput_setfontmatrix(struct swfoutput*,double,double,double,double);
116 void swfoutput_setlinewidth(struct swfoutput*, double linewidth);
117
118 void swfoutput_drawchar(struct swfoutput*,double x,double y,char*a, int charnr);
119 void swfoutput_drawpath(struct swfoutput*, T1_OUTLINE*outline, struct swfmatrix*m);
120 #define LINE_CAP_BUTT 0
121 #define LINE_CAP_ROUND 1 
122 #define LINE_CAP_SQUARE 2
123 #define LINE_JOIN_MITER 0 
124 #define LINE_JOIN_ROUND 1
125 #define LINE_JOIN_BEVEL 2
126 void swfoutput_drawpath2poly(struct swfoutput*, T1_OUTLINE*outline, struct swfmatrix*m, int line_join, int line_cap, double line_width, double miter_limit);
127 void swfoutput_startclip(struct swfoutput*, T1_OUTLINE*outline, struct swfmatrix*m);
128 void swfoutput_endclip(struct swfoutput*);
129 int swfoutput_drawimagejpeg(struct swfoutput*, RGBA*pic, int sizex,int sizey, 
130         double x1,double y1,
131         double x2,double y2,
132         double x3,double y3,
133         double x4,double y4);
134 int swfoutput_drawimagelossless(struct swfoutput*, RGBA*pic, int sizex, int sizey,
135         double x1,double y1,
136         double x2,double y2,
137         double x3,double y3,
138         double x4,double y4);
139 int swfoutput_drawimagelosslessN(struct swfoutput*, U8*pic, RGBA*pal, int sizex, int sizey,
140         double x1,double y1,
141         double x2,double y2,
142         double x3,double y3,
143         double x4,double y4, int n);
144 void swfoutput_drawimageagain(struct swfoutput*, int id, int sizex, int sizey,
145         double x1,double y1,
146         double x2,double y2,
147         double x3,double y3,
148         double x4,double y4);
149
150 void swfoutput_linktopage(struct swfoutput*, int page, swfcoord*points);
151 void swfoutput_linktourl(struct swfoutput*, char*url, swfcoord*points);
152 void swfoutput_namedlink(struct swfoutput*obj, char*name, swfcoord*points);
153
154 void swfoutput_destroy(struct swfoutput*);
155
156 #endif //__swfoutput_h__