]> git.lizzy.rs Git - plan9front.git/blob - sys/include/ttf.h
merge
[plan9front.git] / sys / include / ttf.h
1 #pragma src "/sys/src/libttf"
2 #pragma lib "libttf.a"
3
4 typedef struct TTTable TTTable;
5 typedef struct TTChMap TTChMap;
6 typedef struct TTPoint TTPoint;
7 typedef struct TTGlyph TTGlyph;
8 typedef struct TTGlyphInfo TTGlyphInfo;
9 typedef struct TTFontU TTFontU;
10 typedef struct TTFont TTFont;
11 typedef struct TTFunction TTFunction;
12 typedef struct TTGState TTGState;
13 typedef struct TTBitmap TTBitmap;
14 typedef struct TTKern TTKern;
15 typedef struct Biobuf Biobuf;
16
17 struct TTTable {
18         u32int tag;
19         u32int csum;
20         u32int offset;
21         u32int len;
22 };
23 struct TTChMap {
24         int start, end, delta;
25         int *tab;
26         enum {
27                 TTCDELTA16 = 1,
28                 TTCINVALID = 2,
29         } flags;
30         int temp;
31 };
32 struct TTPoint {
33         int x, y;
34         u8int flags;
35 };
36 struct TTBitmap {
37         u8int *bit;
38         int width, height, stride;
39 };
40 struct TTGlyph {
41         TTBitmap;
42         int idx;
43         int xmin, xmax, ymin, ymax;
44         int xminpx, xmaxpx, yminpx, ymaxpx;
45         int advanceWidthpx;
46         TTPoint *pt;
47         TTPoint *ptorg;
48         int npt;
49         u16int *confst;
50         int ncon;
51         u8int *hint;
52         int nhint;
53         TTFont *font;
54         TTGlyphInfo *info;
55 };
56 struct TTGlyphInfo {
57         int loca;
58         u16int advanceWidth;
59         short lsb;
60 };
61 struct TTFunction {
62         u8int *pgm;
63         int npgm;
64 };
65 struct TTGState {
66         int pvx, pvy;
67         int dpvx, dpvy;
68         int fvx, fvy;
69         u32int instctrl;
70         u32int scanctrl;
71         u32int scantype;
72         int rperiod, rphase, rthold;
73         u8int zp;
74         int rp[3];
75         int cvci;
76         int loop;
77         int mindist;
78         int deltabase, deltashift;
79         u8int autoflip;
80         u32int singlewval, singlewci;
81 };
82 struct TTKern {
83         u32int idx;
84         int val;
85 };
86 struct TTFontU {
87         int ref;
88
89         Biobuf *bin;
90
91         TTTable *tab;
92         u16int ntab;
93         
94         TTChMap *cmap;
95         int ncmap;
96         
97         short *cvtu;
98         int ncvtu;
99
100         u16int flags;
101         int emsize;
102         short xmin, ymin, xmax, ymax;
103         u16int longloca;
104         
105         TTGlyphInfo *ginfo;
106         
107         u16int numGlyphs;
108         u16int maxPoints;
109         u16int maxCountours;
110         u16int maxComponentPoints;
111         u16int maxComponentCountours;
112         u16int maxZones;
113         u16int maxTwilightPoints;
114         u16int maxStorage;
115         u16int maxFunctionDefs;
116         u16int maxInstructionDefs;
117         u16int maxStackElements;
118         u16int maxSizeOfInstructions;
119         u16int maxComponentElements;
120         u16int maxComponentDepth;
121         
122         int ascent, descent;
123         
124         u16int advanceWidthMax;
125         u16int minLeftSideBearing;
126         u16int minRightSideBearing;
127         u16int xMaxExtent;
128         u16int numOfLongHorMetrics;
129         
130         TTKern *kern;
131         int nkern;
132 };
133 struct TTFont {
134         TTFontU *u;
135         int ascentpx, descentpx;
136         int ppem;
137         TTGState;
138         TTGState defstate;
139         TTPoint *twilight, *twiorg;
140         u32int *hintstack;
141         TTFunction *func;
142         u32int *storage;
143         int *cvt;
144         int ncvt;
145 };
146
147 TTFont *ttfopen(char *, int, int);
148 TTFont *ttfscale(TTFont *, int, int);
149 void ttfclose(TTFont *);
150 int ttffindchar(TTFont *, Rune);
151 int ttfenumchar(TTFont *, Rune, Rune *);
152 TTGlyph *ttfgetglyph(TTFont *, int, int);
153 void ttfputglyph(TTGlyph *);
154 int ttfgetcontour(TTGlyph *, int, float **, int *);
155
156 enum {
157         TTFLALIGN = 0,
158         TTFRALIGN = 1,
159         TTFCENTER = 2,
160         TTFMODE = 3,
161         TTFJUSTIFY = 4,
162 };
163
164 TTBitmap *ttfrender(TTFont *, char *, char *, int, int, int, char **);
165 TTBitmap *ttfrunerender(TTFont *, Rune *, Rune *, int, int, int, Rune **);
166 TTBitmap *ttfnewbitmap(int, int);
167 void ttffreebitmap(TTBitmap *);
168 void ttfblit(TTBitmap *, int, int, TTBitmap *, int, int, int, int);