* added freetype support in ttf2pt1
[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 #ifdef T1ERR_SCAN_ENCODING //t1lib 5.0.0
15 #define T1_Get_no_fonts T1_GetNoFonts
16 #endif
17
18 extern "C" {
19 #include "../lib/rfxswf.h"
20 }
21
22 extern int enablezlib; //default:0
23 extern int opennewwindow; //default:0
24 extern int ignoredraworder; //default:0
25 extern int drawonlyshapes; //default:0
26 extern int jpegquality; //default:100;
27 extern int storeallcharacters; // default:0
28 extern int insertstoptag; //default:0
29 extern int flashversion; //default:4
30 extern int splinemaxerror; //default:1
31 extern int fontsplinemaxerror; //default:1
32
33 typedef long int twip;
34
35 struct swfmatrix {
36     double m11,m12,m21,m22,m13,m23;
37 };
38
39 struct swfcoord {
40     twip x;
41     twip y;
42 };
43
44 class SWFFont
45 {
46     T1_OUTLINE**outline;
47     char**charname;
48     int*width;
49     char*used;
50
51     char*name;
52     int charnum;
53
54     U16*char2swfcharid;
55     U16*swfcharid2char;
56     int swfcharpos;
57
58     char**standardtable;
59     int standardtablesize;
60
61     public:
62     
63     int t1id;
64     char*fontid;
65     unsigned int swfid;
66
67     SWFFont(char*name, int t1id, char*filename);
68     SWFFont::~SWFFont();
69     T1_OUTLINE*getOutline(char*charname, int charnr);
70     int getSWFCharID(char*name, int charnr);
71     int getWidth(char*name);
72     char*getName();
73     char*getCharName(int t);
74     int getCharWidth(int t) {return width[t];}
75 };
76
77 struct swfoutput 
78 {
79     //int t1font;
80     double fontm11,fontm12,fontm21,fontm22;
81     unsigned short int linewidth;
82     SWFFont*font;
83     RGBA strokergb;
84     RGBA fillrgb;
85 };
86
87 #define DRAWMODE_STROKE 1
88 #define DRAWMODE_FILL 2
89 #define DRAWMODE_EOFILL 3
90 #define DRAWMODE_CLIP 4
91 #define DRAWMODE_EOCLIP 5
92
93 void swfoutput_init(struct swfoutput*, char*filename, int sizex, int sizey);
94 void swfoutput_setprotected(); //write PROTECT tag
95
96 void swfoutput_newpage(struct swfoutput*);
97
98 void swfoutput_setfont(struct swfoutput*, char*fontid, int t1font, char*filename);
99 int swfoutput_queryfont(struct swfoutput*, char*fontid);
100 void swfoutput_setdrawmode(struct swfoutput*, int drawmode);
101 void swfoutput_setfillcolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
102 void swfoutput_setstrokecolor(struct swfoutput*, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
103 void swfoutput_setfontmatrix(struct swfoutput*,double,double,double,double);
104 void swfoutput_setlinewidth(struct swfoutput*, double linewidth);
105
106 void swfoutput_drawchar(struct swfoutput*,double x,double y,char*a, int charnr);
107 void swfoutput_drawpath(struct swfoutput*, T1_OUTLINE*outline, struct swfmatrix*m);
108 #define LINE_CAP_BUTT 0
109 #define LINE_CAP_ROUND 1 
110 #define LINE_CAP_SQUARE 2
111 #define LINE_JOIN_MITER 0 
112 #define LINE_JOIN_ROUND 1
113 #define LINE_JOIN_BEVEL 2
114 void swfoutput_drawpath2poly(struct swfoutput*, T1_OUTLINE*outline, struct swfmatrix*m, int line_join, int line_cap, double line_width, double miter_limit);
115 void swfoutput_startclip(struct swfoutput*, T1_OUTLINE*outline, struct swfmatrix*m);
116 void swfoutput_endclip(struct swfoutput*);
117 int swfoutput_drawimagejpeg(struct swfoutput*, RGBA*pic, int sizex,int sizey, 
118         double x1,double y1,
119         double x2,double y2,
120         double x3,double y3,
121         double x4,double y4);
122 int swfoutput_drawimagelossless(struct swfoutput*, RGBA*pic, int sizex, int sizey,
123         double x1,double y1,
124         double x2,double y2,
125         double x3,double y3,
126         double x4,double y4);
127 int swfoutput_drawimagelosslessN(struct swfoutput*, U8*pic, RGBA*pal, int sizex, int sizey,
128         double x1,double y1,
129         double x2,double y2,
130         double x3,double y3,
131         double x4,double y4, int n);
132 void swfoutput_drawimageagain(struct swfoutput*, int id, int sizex, int sizey,
133         double x1,double y1,
134         double x2,double y2,
135         double x3,double y3,
136         double x4,double y4);
137
138 void swfoutput_linktopage(struct swfoutput*, int page, swfcoord*points);
139 void swfoutput_linktourl(struct swfoutput*, char*url, swfcoord*points);
140 void swfoutput_namedlink(struct swfoutput*obj, char*name, swfcoord*points);
141
142 void swfoutput_destroy(struct swfoutput*);
143
144 #endif //__swfoutput_h__