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