]> git.saurik.com Git - wxWidgets.git/blob - src/freetype/freetype/internal/autohint.h
5d35a5dcd4637ae6a94bb5165367b6e7f96e4ca1
[wxWidgets.git] / src / freetype / freetype / internal / autohint.h
1 /***************************************************************************/
2 /* */
3 /* autohint.h */
4 /* */
5 /* High-level `autohint' module-specific interface (specification). */
6 /* */
7 /* Copyright 1996-2000 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
17
18
19 /*************************************************************************/
20 /* */
21 /* The auto-hinter is used to load and automatically hint glyphs if a */
22 /* format-specific hinter isn't available. */
23 /* */
24 /*************************************************************************/
25
26
27 #ifndef AUTOHINT_H
28 #define AUTOHINT_H
29
30
31 /*************************************************************************/
32 /* */
33 /* A small technical note regarding automatic hinting in order to */
34 /* clarify this module interface. */
35 /* */
36 /* An automatic hinter might compute two kinds of data for a given face: */
37 /* */
38 /* - global hints: Usually some metrics that describe global properties */
39 /* of the face. It is computed by scanning more or less */
40 /* agressively the glyphs in the face, and thus can be */
41 /* very slow to compute (even if the size of global */
42 /* hints is really small). */
43 /* */
44 /* - glyph hints: These describe some important features of the glyph */
45 /* outline, as well as how to align them. They are */
46 /* generally much faster to compute than global hints. */
47 /* */
48 /* The current FreeType auto-hinter does a pretty good job while */
49 /* performing fast computations for both global and glyph hints. */
50 /* However, we might be interested in introducing more complex and */
51 /* powerful algorithms in the future, like the one described in the John */
52 /* D. Hobby paper, which unfortunately requires a lot more horsepower. */
53 /* */
54 /* Because a sufficiently sophisticated font management system would */
55 /* typically implement an LRU cache of opened face objects to reduce */
56 /* memory usage, it is a good idea to be able to avoid recomputing */
57 /* global hints every time the same face is re-opened. */
58 /* */
59 /* We thus provide the ability to cache global hints outside of the face */
60 /* object, in order to speed up font re-opening time. Of course, this */
61 /* feature is purely optional, so most client programs won't even notice */
62 /* it. */
63 /* */
64 /* I initially thought that it would be a good idea to cache the glyph */
65 /* hints too. However, my general idea now is that if you really need */
66 /* to cache these too, you are simply in need of a new font format, */
67 /* where all this information could be stored within the font file and */
68 /* decoded on the fly. */
69 /* */
70 /*************************************************************************/
71
72
73 #include <freetype/freetype.h>
74
75
76 typedef struct FT_AutoHinterRec_ *FT_AutoHinter;
77
78
79 /*************************************************************************/
80 /* */
81 /* <FuncType> */
82 /* FT_AutoHinter_Get_Global_Func */
83 /* */
84 /* <Description> */
85 /* Retrieves the global hints computed for a given face object the */
86 /* resulting data is dissociated from the face and will survive a */
87 /* call to FT_Done_Face(). It must be discarded through the API */
88 /* FT_AutoHinter_Done_Global_Func(). */
89 /* */
90 /* <Input> */
91 /* hinter :: A handle to the source auto-hinter. */
92 /* */
93 /* face :: A handle to the source face object. */
94 /* */
95 /* <Output> */
96 /* global_hints :: A typeless pointer to the global hints. */
97 /* */
98 /* global_len :: The size in bytes of the global hints. */
99 /* */
100 typedef void (*FT_AutoHinter_Get_Global_Func)(
101 FT_AutoHinter hinter,
102 FT_Face face,
103 void** global_hints,
104 long* global_len );
105
106
107 /*************************************************************************/
108 /* */
109 /* <FuncType> */
110 /* FT_AutoHinter_Done_Global_Func */
111 /* */
112 /* <Description> */
113 /* Discards the global hints retrieved through */
114 /* FT_AutoHinter_Get_Global_Func(). This is the only way these hints */
115 /* are freed from memory. */
116 /* */
117 /* <Input> */
118 /* hinter :: A handle to the auto-hinter module. */
119 /* */
120 /* global :: A pointer to retrieved global hints to discard. */
121 /* */
122 typedef void (*FT_AutoHinter_Done_Global_Func)( FT_AutoHinter hinter,
123 void* global );
124
125
126 /*************************************************************************/
127 /* */
128 /* <FuncType> */
129 /* FT_AutoHinter_Reset_Func */
130 /* */
131 /* <Description> */
132 /* This function is used to recompute the global metrics in a given */
133 /* font. This is useful when global font data changes (e.g. Multiple */
134 /* Masters fonts where blend coordinates change). */
135 /* */
136 /* <Input> */
137 /* hinter :: A handle to the source auto-hinter. */
138 /* */
139 /* face :: A handle to the face. */
140 /* */
141 typedef void (*FT_AutoHinter_Reset_Func)( FT_AutoHinter hinter,
142 FT_Face face );
143
144
145 /*************************************************************************/
146 /* */
147 /* <FuncType> */
148 /* FT_AutoHinter_Load_Func */
149 /* */
150 /* <Description> */
151 /* This function is used to load, scale, and automatically hint a */
152 /* glyph from a given face. */
153 /* */
154 /* <Input> */
155 /* face :: A handle to the face. */
156 /* glyph_index :: The glyph index. */
157 /* load_flags :: The load flags. */
158 /* */
159 /* <Note> */
160 /* This function is capable of loading composite glyphs by hinting */
161 /* each sub-glyph independently (which improves quality). */
162 /* */
163 /* It will call the font driver with FT_Load_Glyph(), with */
164 /* FT_LOAD_NO_SCALE set. */
165 /* */
166 typedef FT_Error (*FT_AutoHinter_Load_Func)( FT_AutoHinter hinter,
167 FT_GlyphSlot slot,
168 FT_Size size,
169 FT_UInt glyph_index,
170 FT_ULong load_flags );
171
172
173 /*************************************************************************/
174 /* */
175 /* <Struct> */
176 /* FT_AutoHinter_Interface */
177 /* */
178 /* <Description> */
179 /* The auto-hinter module's interface. */
180 /* */
181 typedef struct FT_AutoHinter_Interface
182 {
183 FT_AutoHinter_Reset_Func reset_face;
184 FT_AutoHinter_Load_Func load_glyph;
185
186 FT_AutoHinter_Get_Global_Func get_global_hints;
187 FT_AutoHinter_Done_Global_Func done_global_hints;
188
189 } FT_AutoHinter_Interface;
190
191
192 #endif /* AUTOHINT_H */
193
194
195 /* END */