4349 |
Serge |
1 |
|
|
|
2 |
"http://www.w3.org/TR/html4/loose.dtd"> |
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
FreeType-2.5.0 API Reference |
|
|
7 |
|
|
|
8 |
body { font-family: Verdana, Geneva, Arial, Helvetica, serif; |
|
|
9 |
color: #000000; |
|
|
10 |
background: #FFFFFF; } |
|
|
11 |
|
|
|
12 |
p { text-align: justify; } |
|
|
13 |
h1 { text-align: center; } |
|
|
14 |
li { text-align: justify; } |
|
|
15 |
td { padding: 0 0.5em 0 0.5em; } |
|
|
16 |
td.left { padding: 0 0.5em 0 0.5em; |
|
|
17 |
text-align: left; } |
|
|
18 |
|
|
|
19 |
a:link { color: #0000EF; } |
|
|
20 |
a:visited { color: #51188E; } |
|
|
21 |
a:hover { color: #FF0000; } |
|
|
22 |
|
|
|
23 |
span.keyword { font-family: monospace; |
|
|
24 |
text-align: left; |
|
|
25 |
white-space: pre; |
|
|
26 |
color: darkblue; } |
|
|
27 |
|
|
|
28 |
pre.colored { color: blue; } |
|
|
29 |
|
|
|
30 |
ul.empty { list-style-type: none; } |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
38 |
FreeType-2.5.0 API Reference
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
Glyph Management |
|
|
42 |
|
|
|
43 |
Synopsis
|
|
|
44 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
This section contains definitions used to manage glyph data through generic FT_Glyph objects. Each of them can contain a bitmap, a vector outline, or even images in other formats.
|
|
|
54 |
|
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
Defined in FT_GLYPH_H (freetype/ftglyph.h). |
|
|
59 |
|
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
typedef struct FT_GlyphRec_* FT_Glyph; |
|
|
63 |
|
|
|
64 |
|
|
|
|
65 |
|
|
|
66 |
Handle to an object used to model generic glyph images. It is a pointer to the FT_GlyphRec structure and can contain a glyph bitmap or pointer.
|
|
|
67 |
|
|
|
|
68 |
|
|
|
71 |
|
|
|
|
72 |
|
|
|
73 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
Defined in FT_GLYPH_H (freetype/ftglyph.h). |
|
|
81 |
|
|
|
|
82 |
|
|
|
94 |
|
|
|
95 |
The root glyph structure contains a given glyph image plus its advance width in 16.16 fixed-point format.
|
|
|
96 |
|
|
|
|
97 |
fields | |
|
|
98 |
|
|
|
99 |
|
|
100 |
library | |
|
|
101 |
A handle to the FreeType library object.
|
|
|
102 |
|
|
|
|
103 |
clazz | |
|
|
104 |
A pointer to the glyph's class. Private.
|
|
|
105 |
|
|
|
|
106 |
format | |
|
|
107 |
The format of the glyph's image.
|
|
|
108 |
|
|
|
|
109 |
advance | |
|
|
110 |
A 16.16 vector that gives the glyph's advance width.
|
|
|
111 |
|
|
|
|
112 |
| |
|
|
113 |
|
|
|
|
114 |
|
|
|
|
115 |
|
|
|
116 |
|
|
|
119 |
|
|
|
120 |
|
|
|
134 |
|
|
|
135 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
Defined in FT_GLYPH_H (freetype/ftglyph.h). |
|
|
143 |
|
|
|
|
144 |
|
|
|
156 |
|
|
|
157 |
A structure used for bitmap glyph images. This really is a ‘sub-class’ of FT_GlyphRec.
|
|
|
158 |
|
|
|
|
159 |
fields | |
|
|
160 |
|
|
|
161 |
|
|
162 |
root | |
|
|
163 |
The root FT_Glyph fields.
|
|
|
164 |
|
|
|
|
165 |
left | |
|
|
166 |
The left-side bearing, i.e., the horizontal distance from the current pen position to the left border of the glyph bitmap.
|
|
|
167 |
|
|
|
|
168 |
top | |
|
|
169 |
The top-side bearing, i.e., the vertical distance from the current pen position to the top border of the glyph bitmap. This distance is positive for upwards y!
|
|
|
170 |
|
|
|
|
171 |
bitmap | |
|
|
172 |
A descriptor for the bitmap.
|
|
|
173 |
|
|
|
|
174 |
| |
|
|
175 |
|
|
|
|
176 |
note | |
|
|
177 |
You can typecast an FT_Glyph to FT_BitmapGlyph if you have ‘glyph->format == FT_GLYPH_FORMAT_BITMAP’. This lets you access the bitmap's contents easily.
|
|
|
178 |
The corresponding pixel buffer is always owned by FT_BitmapGlyph and is thus created and destroyed with it.
|
|
|
179 |
|
|
|
|
180 |
|
|
|
|
181 |
|
|
|
182 |
|
|
|
185 |
|
|
|
186 |
|
|
|
200 |
|
|
|
201 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
Defined in FT_GLYPH_H (freetype/ftglyph.h). |
|
|
209 |
|
|
|
|
210 |
|
|
|
220 |
|
|
|
221 |
A structure used for outline (vectorial) glyph images. This really is a ‘sub-class’ of FT_GlyphRec.
|
|
|
222 |
|
|
|
|
223 |
|
|
|
234 |
note | |
|
|
235 |
You can typecast an FT_Glyph to FT_OutlineGlyph if you have ‘glyph->format == FT_GLYPH_FORMAT_OUTLINE’. This lets you access the outline's content easily.
|
|
|
236 |
As the outline is extracted from a glyph slot, its coordinates are expressed normally in 26.6 pixels, unless the flag FT_LOAD_NO_SCALE was used in FT_Load_Glyph() or FT_Load_Char().
|
|
|
237 |
The outline's tables are always owned by the object and are destroyed with it.
|
|
|
238 |
|
|
|
|
239 |
|
|
|
|
240 |
|
|
|
241 |
|
|
|
244 |
|
|
|
245 |
|
|
|
280 |
|
|
|
281 |
|
|
|
284 |
|
|
|
285 |
|
|
|
320 |
|
|
|
321 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
Defined in FT_GLYPH_H (freetype/ftglyph.h). |
|
|
329 |
|
|
|
|
330 |
|
|
|
338 |
|
|
|
339 |
Transform a glyph image if its format is scalable.
|
|
|
340 |
|
|
|
|
341 |
|
|
|
349 |
input | |
|
|
350 |
|
|
|
351 |
|
|
352 |
matrix | |
|
|
353 |
A pointer to a 2x2 matrix to apply.
|
|
|
354 |
|
|
|
|
355 |
delta | |
|
|
356 |
A pointer to a 2d vector to apply. Coordinates are expressed in 1/64th of a pixel.
|
|
|
357 |
|
|
|
|
358 |
| |
|
|
359 |
|
|
|
|
360 |
return | |
|
|
361 |
FreeType error code (if not 0, the glyph format is not scalable).
|
|
|
362 |
|
|
|
|
363 |
note | |
|
|
364 |
The 2x2 transformation matrix is also applied to the glyph's advance vector.
|
|
|
365 |
|
|
|
|
366 |
|
|
|
|
367 |
|
|
|
368 |
|
|
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
|
374 |
|
|
|
375 |
Defined in FT_GLYPH_H (freetype/ftglyph.h). |
|
|
376 |
|
|
|
|
377 |
|
|
|
390 |
|
|
|
393 |
values | |
|
|
394 |
|
|
|
395 |
|
|
396 |
FT_GLYPH_BBOX_UNSCALED | |
|
|
397 |
Return unscaled font units.
|
|
|
398 |
|
|
|
|
399 |
FT_GLYPH_BBOX_SUBPIXELS |
|
|
|
400 |
| |
|
|
401 |
Return unfitted 26.6 coordinates.
|
|
|
402 |
|
|
|
|
403 |
FT_GLYPH_BBOX_GRIDFIT | |
|
|
404 |
Return grid-fitted 26.6 coordinates.
|
|
|
405 |
|
|
|
|
406 |
FT_GLYPH_BBOX_TRUNCATE | |
|
|
407 |
Return coordinates in integer pixels.
|
|
|
408 |
|
|
|
|
409 |
FT_GLYPH_BBOX_PIXELS | |
|
|
410 |
Return grid-fitted pixel coordinates.
|
|
|
411 |
|
|
|
|
412 |
| |
|
|
413 |
|
|
|
|
414 |
|
|
|
|
415 |
|
|
|
416 |
|
|
|
419 |
|
|
|
420 |
|
|
|
459 |
|
|
|
460 |
|
|
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
|
467 |
Defined in FT_GLYPH_H (freetype/ftglyph.h). |
|
|
468 |
|
|
|
|
469 |
|
|
|
477 |
|
|
|
478 |
Return a glyph's ‘control box’. The control box encloses all the outline's points, including Bézier control points. Though it coincides with the exact bounding box for most glyphs, it can be slightly larger in some situations (like when rotating an outline which contains Bézier outside arcs).
|
|
|
479 |
Computing the control box is very fast, while getting the bounding box can take much more time as it needs to walk over all segments and arcs in the outline. To get the latter, you can use the ‘ftbbox’ component which is dedicated to this single task.
|
|
|
480 |
|
|
|
|
481 |
input | |
|
|
482 |
|
|
|
483 |
|
|
484 |
glyph | |
|
|
485 |
A handle to the source glyph object.
|
|
|
486 |
|
|
|
|
487 |
mode | |
|
|
488 |
The mode which indicates how to interpret the returned bounding box values.
|
|
|
489 |
|
|
|
|
490 |
| |
|
|
491 |
|
|
|
|
492 |
output | |
|
|
493 |
|
|
|
494 |
|
|
495 |
acbox | |
|
|
496 |
The glyph coordinate bounding box. Coordinates are expressed in 1/64th of pixels if it is grid-fitted.
|
|
|
497 |
|
|
|
|
498 |
| |
|
|
499 |
|
|
|
|
500 |
note | |
|
|
501 |
Coordinates are relative to the glyph origin, using the y upwards convention.
|
|
|
502 |
If the glyph has been loaded with FT_LOAD_NO_SCALE, ‘bbox_mode’ must be set to FT_GLYPH_BBOX_UNSCALED to get unscaled font units in 26.6 pixel format. The value FT_GLYPH_BBOX_SUBPIXELS is another name for this constant.
|
|
|
503 |
If the font is tricky and the glyph has been loaded with FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get reasonable values for the CBox it is necessary to load the glyph at a large ppem value (so that the hinting instructions can properly shift and scale the subglyphs), then extracting the CBox which can be eventually converted back to font units.
|
|
|
504 |
Note that the maximum coordinates are exclusive, which means that one can compute the width and height of the glyph image (be it in integer or 26.6 pixels) as:
|
|
|
505 |
|
|
|
506 |
width = bbox.xMax - bbox.xMin; |
|
|
507 |
height = bbox.yMax - bbox.yMin; |
|
|
508 |
|
|
|
509 |
Note also that for 26.6 coordinates, if ‘bbox_mode’ is set to FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, which corresponds to:
|
|
|
510 |
|
|
|
511 |
bbox.xMin = FLOOR(bbox.xMin); |
|
|
512 |
bbox.yMin = FLOOR(bbox.yMin); |
|
|
513 |
bbox.xMax = CEILING(bbox.xMax); |
|
|
514 |
bbox.yMax = CEILING(bbox.yMax); |
|
|
515 |
|
|
|
516 |
To get the bbox in pixel coordinates, set ‘bbox_mode’ to FT_GLYPH_BBOX_TRUNCATE.
|
|
|
517 |
To get the bbox in grid-fitted pixel coordinates, set ‘bbox_mode’ to FT_GLYPH_BBOX_PIXELS.
|
|
|
518 |
|
|
|
|
519 |
|
|
|
|
520 |
|
|
|
521 |
|
|
|
524 |
|
|
|
525 |
|
|
|
526 |
|
|
|
527 |
|
|
|
528 |
Defined in FT_GLYPH_H (freetype/ftglyph.h). |
|
|
529 |
|
|
|
|
530 |
|
|
|
539 |
|
|
|
540 |
Convert a given glyph object to a bitmap glyph object.
|
|
|
541 |
|
|
|
|
542 |
|
|
|
550 |
input | |
|
|
551 |
|
|
|
552 |
|
|
553 |
render_mode | |
|
|
554 |
An enumeration that describes how the data is rendered.
|
|
|
555 |
|
|
|
|
556 |
origin | |
|
|
557 |
A pointer to a vector used to translate the glyph image before rendering. Can be 0 (if no translation). The origin is expressed in 26.6 pixels.
|
|
|
558 |
|
|
|
|
559 |
destroy | |
|
|
560 |
A boolean that indicates that the original glyph image should be destroyed by this function. It is never destroyed in case of error.
|
|
|
561 |
|
|
|
|
562 |
| |
|
|
563 |
|
|
|
|
564 |
return | |
|
|
565 |
FreeType error code. 0 means success.
|
|
|
566 |
|
|
|
|
567 |
note | |
|
|
568 |
This function does nothing if the glyph format isn't scalable.
|
|
|
569 |
The glyph image is translated with the ‘origin’ vector before rendering.
|
|
|
570 |
The first parameter is a pointer to an FT_Glyph handle, that will be replaced by this function (with newly allocated data). Typically, you would use (omitting error handling):
|
|
|
571 |
|
|
|
572 |
|
|
|
573 |
FT_Glyph glyph; |
|
|
574 |
FT_BitmapGlyph glyph_bitmap; |
|
|
575 |
|
|
|
576 |
|
|
|
577 |
// load glyph |
|
|
578 |
error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); |
|
|
579 |
|
|
|
580 |
// extract glyph image |
|
|
581 |
error = FT_Get_Glyph( face->glyph, &glyph ); |
|
|
582 |
|
|
|
583 |
// convert to a bitmap (default render mode + destroying old) |
|
|
584 |
if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) |
|
|
585 |
{ |
|
|
586 |
error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, |
|
|
587 |
0, 1 ); |
|
|
588 |
if ( error ) // `glyph' unchanged |
|
|
589 |
... |
|
|
590 |
} |
|
|
591 |
|
|
|
592 |
// access bitmap content by typecasting |
|
|
593 |
glyph_bitmap = (FT_BitmapGlyph)glyph; |
|
|
594 |
|
|
|
595 |
// do funny stuff with it, like blitting/drawing |
|
|
596 |
... |
|
|
597 |
|
|
|
598 |
// discard glyph image (bitmap or not) |
|
|
599 |
FT_Done_Glyph( glyph ); |
|
|
600 |
|
|
|
601 |
|
|
|
602 |
Here another example, again without error handling:
|
|
|
603 |
|
|
|
604 |
|
|
|
605 |
FT_Glyph glyphs[MAX_GLYPHS] |
|
|
606 |
|
|
|
607 |
|
|
|
608 |
... |
|
|
609 |
|
|
|
610 |
for ( idx = 0; i < MAX_GLYPHS; i++ ) |
|
|
611 |
error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || |
|
|
612 |
FT_Get_Glyph ( face->glyph, &glyph[idx] ); |
|
|
613 |
|
|
|
614 |
... |
|
|
615 |
|
|
|
616 |
for ( idx = 0; i < MAX_GLYPHS; i++ ) |
|
|
617 |
{ |
|
|
618 |
FT_Glyph bitmap = glyphs[idx]; |
|
|
619 |
|
|
|
620 |
|
|
|
621 |
... |
|
|
622 |
|
|
|
623 |
// after this call, `bitmap' no longer points into |
|
|
624 |
// the `glyphs' array (and the old value isn't destroyed) |
|
|
625 |
FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); |
|
|
626 |
|
|
|
627 |
... |
|
|
628 |
|
|
|
629 |
FT_Done_Glyph( bitmap ); |
|
|
630 |
} |
|
|
631 |
|
|
|
632 |
... |
|
|
633 |
|
|
|
634 |
for ( idx = 0; i < MAX_GLYPHS; i++ ) |
|
|
635 |
FT_Done_Glyph( glyphs[idx] ); |
|
|
636 |
|
|
|
637 |
|
|
|
|
638 |
|
|
|
|
639 |
|
|
|
640 |
|
|
|
643 |
|
|
|
644 |
|
|
|
667 |
|
|
|
668 |
|
|
|
671 |
|
|
|
672 |
|
|
|
673 |
|
!DOCTYPE>