3 ttfopen, ttfscale, ttfclose, ttffindchar, ttfenumchar, ttfgetglyph,
4 ttfputglyph, ttfgetcontour, ttfrender, ttfrunerender, ttfnewbitmap,
5 ttffreebitmap, ttfblit \- TrueType renderer
20 int width, height, stride;
25 int xminpx, xmaxpx, yminpx, ymaxpx, advanceWidthpx;
30 int ppem, ascentpx, descentpx;
34 .ta +\w'\fLTTBitmap* \fP'u
35 TTFont* ttfopen(char *filename, int size, int flags);
36 TTFont* ttfscale(TTFont *f, int size, int flags);
37 void ttfclose(TTFont *f);
39 int ttffindchar(TTFont *f, Rune r);
40 int ttfenumchar(TTFont *f, Rune r, Rune *rp);
42 TTGlyph* ttfgetglyph(TTFont *f, int glyphidx, int render);
43 void ttfputglyph(TTGlyph *g);
44 int ttfgetcontour(TTGlyph *g, int idx, float **fp, int *nfp);
46 TTBitmap* ttfrender(TTFont *f, char *s, char *e, int w, int h,
47 int flags, char **pp);
48 TTBitmap* ttfrunerender(TTFont *f, Rune *s, Rune *e, int w, int h,
49 int flags, Rune **pp);
51 TTBitmap* ttfnewbitmap(int w, int h);
52 void ttfblit(TTBitmap *dst, int dstx, int dsty, TTBitmap *src,
53 int srcx, int srcy, int w, int h);
54 void ttffreebitmap(TTBitmap *);
58 is a parser and renderer of TrueType fonts.
59 Given a \fLttf\fR font file it can produce the rendered versions of characters at a given size.
64 and initialises it for rendering at size
66 (specified in pixels per em).
68 is reserved for future use and should be zero.
69 If rendering at multiple sizes is desired,
71 reopens the font at a different size (internally the size-independent data is shared).
73 closes an opened font.
74 Each instance of a font created by
78 must be closed separately.
80 A character in a TrueType font is called a glyph.
81 Glyphs are numbered starting from 0 and the glyph indices do not need to follow any established coding scheme.
83 finds the glyph number of a given rune (Unicode codepoint).
84 If the character does not exist in the font, zero is returned.
85 Note that, in TrueType fonts, glyph 0 conventionally contains the "glyph not found" character.
89 but will continue searching if the character is not in the font, returning the rune number for which it found a glyph in
91 It returns character in ascending Unicode order and it can be used to enumerate the characters in a font.
92 Zero is returned if there are no further characters.
95 interprets the actual data for a glyph specified by its index
99 set to zero, the data is left uninterpreted; currently its only use is
103 set to one, the glyph is also rendered, i.e. a pixel representation is produced and stored in the
107 structure it returns.
108 Although TrueType uses a right handed coordinate system (y increases going up), the bitmap data returns follows Plan 9 conventions (and is compatible with the
111 The bottom left hand corner is at position (\fIxmin\fR, \fIymin\fR) in the TrueType coordinate system.
113 should be used to return
115 structures for cleanup.
118 can be used to obtain raw contour data for a glyph.
121 it returns the corresponding contour (counting from zero), storing a pointer to a list of (\fIx\fR, \fIy\fR) pairs in
123 The array is allocated with
125 The (always odd) number of points is stored in
127 The contours correspond to closed quadratic Bézier curves and the points with odd indices are the control points.
128 For an invalid index, zero is returned and
133 For a valid index, the number returned is the number of contours with index ≥ \fIi\fR.
138 typeset a string of text (specified as UTF-8 or raw Unicode, respectively) and return a bitmap of size
142 It attempts to typeset text starting from
144 and up to and not including
150 text is typeset until a null byte is encountered.
152 specifies the alignment.
157 specify left-aligned, right-aligned and centered text, respectively.
159 can be or'ed with these three options to produce text where any ``wrapped'' line is justified.
161 For reasons of efficiency and simplicity,
163 includes its own format for 1 bpp bitmaps.
165 0 corresponds to transparent and 1 corresponds to opaque.
166 Otherwise, the format is identical to
173 allocate and deallocate such bitmaps, respectively.
175 structures can be used in place of bitmaps but must be deallocated with
180 copies part of one bitmap onto another.
181 Note that bits are or'ed together \(-- blitting a transparent over an opaque pixel does not produce an transparent pixel.
185 Apple, ``TrueType™ Reference Manual''.
187 Microsoft, ``OpenType® specification''.
189 FreeType, source code (the only accurate source).
193 Following standard conventions, routines returning pointers return
195 on error and return an error message in
198 Both ``standards'' are packages of contradictions and lies.
200 Apple Advanced Typography and Microsoft OpenType extensions are not supported; similarly non-TrueType (Postscript, Bitmap) fonts packaged as
202 files are not supported.
204 The library is immature and interfaces are virtually guaranteed to change.
208 files are not supported.
211 first appeared in 9front in June, 2018.