Debian Codegraph @

ft2docs/docs/design/design-2.html

raw ◀ ▶
1 Debian patch touch this file
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3
4 <html lang="en">
5
6 <head>
7 <meta http-equiv="Content-Type"
8 content="text/html; charset=utf-8">
9 <meta http-equiv="Content-Style-Type"
10 content="text/css">
11 <meta http-equiv="Content-Script-Type"
12 content="text/javascript">
13 <meta name="description"
14 content="FreeType Documentation - Design - Components and
15 APIs">
16 <meta name="Author"
17 content="David Turner">
18
19 <link rel="icon"
20 href="../image/favicon_-90.ico">
21 <link rel="shortcut icon"
22 href="../image/favicon_-90.ico">
23 <link rel="stylesheet"
24 type="text/css"
25 href="../css/freetype2_-90.css">
26
27 <script type="text/javascript"
28 src="../../../js/freetype2.js">
29 </script>
30
31 <title>FreeType Design | Components and APIs</title>
32 </head>
33
34
35 <body>
36
37 <div id="top"
38 class="bar">
39 <h1><a href="http://freetype.org/index.html">FreeType</a>
40 Design&nbsp;/&nbsp;I</h1>
41 </div>
42
43
44 <div id="wrapper">
45
46 <div class="colmask leftmenu">
47 <div class="colright">
48 <div class="col1wrap">
49 <div class="col1">
50
51
52 <!-- ************************************************** -->
53
54 <div id="components-and-apis">
55 <h2>I. Components and APIs</h2>
56
57 <p>It is better to describe FreeType&nbsp;2 as a collection
58 of <em>components</em>. Each one of them is a more or
59 less abstract part of the library that is in charge of one
60 specific task. We will now explain the connections and
61 relationships between them.</p>
62
63 <p>A first brief description of this system of components
64 could be as follows.</p>
65
66 <ul>
67 <li>
68 <p>Client applications typically call the
69 FreeType&nbsp;2 <b>high-level API</b>, whose functions
70 are implemented in a single component called
71 the <em>Base Layer</em>.</p>
72 </li>
73 <li>
74 <p>Depending on the context or the task, the base layer
75 then calls one or more <em>module</em> components to
76 perform the work. In most cases, the client
77 application doesn't need to know which module was
78 called.</p>
79 </li>
80 <li>
81 <p>The base layer also contains a set of routines that
82 are used for generic things like memory allocation,
83 list processing, I/O stream parsing, fixed-point
84 computation, etc. These functions can also be called
85 by a module at any time, and they form what is called
86 the <b>low-level base API</b>.</p>
87 </li>
88 </ul>
89
90 <p>This is illustrated by the following graphics (note that
91 component entry points are represented as colored
92 triangles).</p>
93
94 <center>
95 <img src="components-1.svg"
96 width="70%"
97 height="70%"
98 alt="Basic FreeType design">
99 </center>
100
101 <p>A few additional things must be added to complete this
102 picture.</p>
103
104 <ul>
105 <li>
106 <p>Some parts of the base layer can be replaced for
107 specific builds of the library, and can thus be
108 considered as components themselves. This is the case
109 for the <tt>ftsystem</tt> component, which is in
110 charge of implementing memory management and input
111 stream access, as well as <tt>ftinit</tt>, which is in
112 charge of library initialization (i.e., implementing
113 the <a href="../reference/ft2-library_setup.html#ft_init_freetype"><code>FT_Init_FreeType</code></a>
114 function).</p>
115 </li>
116 <li>
117 <p>FreeType&nbsp;2 comes also with a set of <em>optional
118 components</em>, which can be used either as a
119 convenience layer for client applications (e.g.,
120 the <tt>ftglyph</tt> component, used to provide a
121 simple API to manage glyph images independently of
122 their internal representation), or to access
123 format-specific features (e.g., the
124 <tt>ftmm</tt> component used to access and manage
125 Multiple Masters and OpenType variations fonts).</p>
126 </li>
127 <li>
128 <p>A module is capable of calling functions provided by
129 another module. This is very useful to share code and
130 tables between several font driver modules (for
131 example, the <tt>truetype</tt> and <tt>cff</tt>
132 modules both use the routines provided by
133 the <tt>sfnt</tt> module).</p>
134 </li>
135 <li>
136 <p>Finally, FreeType provides <em>services</em>, which
137 are a more light-weight way to access certain features
138 across multiple modules, or to access some
139 functionality provided by a single module.</p>
140
141 <p>Services are internal to FreeType; similar to
142 modules, it is necessary to &lsquo;load&rsquo; a
143 service, which can fail if the service's module is not
144 available.</p>
145
146 <p>An example for a service provided by a single module
147 is &lsquo;winfonts&rsquo; (see
148 file <tt>svwinfnt.h</tt>), which allows access to the
149 header of Windows bitmap fonts. An example for a
150 service provided by multiple modules is
151 &lsquo;multi-masters&rsquo; (see file <tt>svmm.h</tt>)
152 to manage the abovementioned <tt>ftmm</tt> component
153 across the <tt>truetype</tt>, <tt>type1</tt>,
154 and <tt>cff</tt> modules.</p>
155 </li>
156 </ul>
157
158 <p>The following graphics shows the additional components;
159 optional ones are represented by dashed boxes.</p>
160
161 <center>
162 <img src="components-2.svg"
163 width="80%"
164 height="80%"
165 alt="Detailed FreeType design">
166 </center>
167
168 <p>Please take note of the following important points.</p>
169
170 <ul>
171 <li>
172 <p>An optional component can use either the high-level
173 or base API. This is the case of <tt>ftglyph</tt> in
174 the above picture.</p>
175 </li>
176 <li>
177 <p>Some optional components can use module-specific
178 interfaces or services ignored by the base layer. In
179 the above example, <tt>ftmm</tt> directly accesses the
180 Type&nbsp;1 and TrueType modules to set and query
181 data.</p>
182 </li>
183 <li>
184 <p>A replaceable component can provide a function of the
185 high-level API. For example, <tt>ftinit</tt> provides
186 <tt>FT_Init_FreeType</tt> to client applications.</p>
187 </li>
188 </ul>
189 </div>
190
191 <!-- ************************************************** -->
192
193 <div class="updated">
194 <p>Last update: 16-Oct-2022</p>
195 </div>
196 </div>
197 </div>
198
199
200 <!-- ************************************************** -->
201
202 <div class="col2">
203 </div>
204 </div>
205 </div>
206
207
208 <!-- ************************************************** -->
209
210 <div id="TOC">
211 <ul>
212 <li class="funding">
213 <form action="https://www.paypal.com/cgi-bin/webscr"
214 method="post"
215 target="_top">
216 <input type="hidden"
217 name="cmd"
218 value="_s-xclick">
219 <input type="hidden"
220 name="hosted_button_id"
221 value="SK827YKEALMT4">
•222 <input type="submit"
223 value="Donate"
224 name="submit"
225 alt="PayPal - The safer, easier way to pay online!">
226 </form>
227 </li>
228 <li class="primary">
229 <a href="http://freetype.org/index.html">Home</a>
230 </li>
231 <li class="primary">
232 <a href="http://freetype.org/index.html#news">News</a>
233 </li>
234 <li class="primary">
235 <a href="../index.html">Overview</a>
236 </li>
237 <li class="primary">
238 <a href="../documentation.html">Documentation</a>
239 </li>
240 <li class="primary">
241 <a href="http://freetype.org/developer.html">Development</a>
242 </li>
243 <li class="primary">
244 <a href="http://freetype.org/contact.html"
245 class="emphasis">Contact</a>
246 </li>
247
248 <li>
249 &nbsp; <!-- separate primary from secondary entries -->
250 </li>
251
252 <li class="secondary">
253 <a href="index.html">FreeType Design</a>
254 </li>
255 <li class="tertiary">
256 <a href="design-1.html">Introduction</a>
257 </li>
258 <li class="tertiary">
259 <a href="design-2.html" class="current">Components and APIs</a>
260 </li>
261 <li class="tertiary">
262 <a href="design-3.html">Public Objects and Classes</a>
263 </li>
264 <li class="tertiary">
265 <a href="design-4.html">Internal Objects and Classes</a>
266 </li>
267 <li class="tertiary">
268 <a href="design-5.html">Module Classes</a>
269 </li>
270 <li class="tertiary">
271 <a href="design-6.html">Interfaces and Services</a>
272 </li>
273 </ul>
274 </div>
275
276 </div> <!-- id="wrapper" -->
277
278 <div id="TOC-bottom">
279 </div>
280
281 </body>
282 </html>