summaryrefslogtreecommitdiff
path: root/module/freetype.m
blob: ce4d5c4b4480a408d32a5d5631faf8f7f1e74e52 (plain)
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
Freetype: module {
	PATH: con "$Freetype";

	Matrix: adt {
		a, b: int;	# 16.16 fixed-point coefficients
		c, d: int;
	};

	Vector: adt {
		dx: int;	# 26.6 fixed-point deltas
		dy: int;
	};

	STYLE_ITALIC,
	STYLE_BOLD: con 1 << iota;

	Face: adt {
		nfaces: int;
		index: int;
		style: int;		# STYLE_xxx
		height: int;
		ascent: int;
		familyname: string;
		stylename: string;

		# pts - point size as a 26.6 fixed-point value
		setcharsize: fn(face: self ref Face, pts, hdpi, vdpi: int): string;
		settransform: fn(face: self ref Face, m: ref Matrix, v: ref Vector): string;
		haschar: fn(face: self ref Face, c: int): int;
		loadglyph: fn(face: self ref Face, c: int): ref Glyph;
	};

	Glyph: adt {
		top: int;
		left: int;
		height: int;
		width: int;
		advance: Draw->Point;	# 26.6 fixed-point
		bitmap:	array of byte;	# (width*height) 8-bit greyscale
	};

	newface: fn(path: string, index: int): ref Face;
	newmemface: fn(data: array of byte, index: int): ref Face;
};