<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type"
content="text/css">
<meta http-equiv="Content-Script-Type"
content="text/javascript">
<meta name="description"
content="FreeType Documentation">
<meta name="Author"
content="David Turner">
<link rel="icon"
href="../image/favicon_-90.ico">
<link rel="shortcut icon"
href="../image/favicon_-90.ico">
<link rel="stylesheet"
type="text/css"
href="../css/freetype2_-90.css">
<script type="text/javascript"
src="../../../js/jquery-1.11.0.min.js">
</script>
<script type="text/javascript"
src="../../../js/jquery.ba-resize.min.js">
</script>
<script type="text/javascript"
src="../../../js/freetype2.js">
</script>
<title>FreeType Design / I</title>
</head>
<body>
<div id="top"
class="bar">
<h1><a href="http://freetype.org/index.html">FreeType</a>
Design / I</h1>
</div>
<div id="wrapper">
<div class="colmask leftmenu">
<div class="colright">
<div class="col1wrap">
<div class="col1">
<!-- ************************************************** -->
<div id="components-and-apis">
<h2>I. Components and APIs</h2>
<p>It is better to describe FreeType 2 as a collection
of <em>components</em>. Each one of them is a more or
less abstract part of the library that is in charge of one
specific task. We will now explain the connections and
relationships between them.</p>
<p>A first brief description of this system of components
could be as follows.</p>
<ul>
<li>
<p>Client applications typically call the
FreeType 2 <b>high-level API</b>, whose functions
are implemented in a single component called
the <em>Base Layer</em>.</p>
</li>
<li>
<p>Depending on the context or the task, the base layer
then calls one or more <em>module</em> components to
perform the work. In most cases, the client
application doesn't need to know which module was
called.</p>
</li>
<li>
<p>The base layer also contains a set of routines that
are used for generic things like memory allocation,
list processing, I/O stream parsing, fixed-point
computation, etc. These functions can also be called
by a module at any time, and they form what is called
the <b>low-level base API</b>.</p>
</li>
</ul>
<p>This is illustrated by the following graphics (note that
component entry points are represented as colored
triangles).</p>
<center>
<img src="basic-design.png"
width="394"
height="313"
alt="Basic FreeType design">
</center>
<p>A few additional things must be added to complete this
picture.</p>
<ul>
<li>
<p>Some parts of the base layer can be replaced for
specific builds of the library, and can thus be
considered as components themselves. This is the case
for the <tt>ftsystem</tt> component, which is in
charge of implementing memory management and input
stream access, as well as <tt>ftinit</tt>, which is in
charge of library initialization (i.e., implementing
the <a href="../reference/ft2-base_interface.html#FT_Init_FreeType"><code>FT_Init_FreeType</code></a>
function).</p>
</li>
<li>
<p>FreeType 2 comes also with a set of <em>optional
components</em>, which can be used either as a
convenience layer for client applications (e.g.,
the <tt>ftglyph</tt> component, used to provide a
simple API to manage glyph images independently of
their internal representation), or to access
format-specific features (e.g., the
<tt>ftmm</tt> component used to access and manage
Multiple Masters and OpenType variations fonts).</p>
</li>
<li>
<p>A module is capable of calling functions provided by
another module. This is very useful to share code and
tables between several font driver modules (for
example, the <tt>truetype</tt> and <tt>cff</tt>
modules both use the routines provided by
the <tt>sfnt</tt> module).</p>
</li>
<li>
<p>Finally, FreeType provides <em>services</em>, which
are a more light-weight way to access certain features
across multiple modules, or to access some
functionality provided by a single module.</p>
<p>Services are internal to FreeType; similar to
modules, it is necessary to ‘load’ a
service, which can fail if the service's module is not
available.</p>
<p>An example for a service provided by a single module
is ‘winfonts’ (see
file <tt>svwinfnt.h</tt>), which allows access to the
header of Windows bitmap fonts. An example for a
service provided by multiple modules is
‘multi-masters’ (see file <tt>svmm.h</tt>)
to manage the abovementioned <tt>ftmm</tt> component
across the <tt>truetype</tt>, <tt>type1</tt>,
and <tt>cff</tt> modules.</p>
</li>
</ul>
<p>The following graphics shows the additional components
(without services).</p>
<center>
<img src="detailed-design.png"
width="390"
height="429"
alt="Detailed FreeType design">
</center>
<p>Please take note of the following important points.</p>
<ul>
<li>
<p>An optional component can use either the high-level
or base API. This is the case of <tt>ftglyph</tt> in
the above picture.</p>
</li>
<li>
<p>Some optional components can use module-specific
interfaces or services ignored by the base layer. In
the above example, <tt>ftmm</tt> directly accesses the
Type 1 and TrueType modules to set and query
data.</p>
</li>
<li>
<p>A replaceable component can provide a function of the
high-level API. For example, <tt>ftinit</tt> provides
<tt>FT_Init_FreeType</tt> to client applications.</p>
</li>
</ul>
</div>
<!-- ************************************************** -->
<div class="updated">
<p>Last update: 13-Feb-2018</p>
</div>
</div>
</div>
<!-- ************************************************** -->
<div class="col2">
</div>
</div>
</div>
<!-- ************************************************** -->
<div id="TOC">
<ul>
<li class="funding">
<form action="https://www.paypal.com/cgi-bin/webscr"
method="post"
target="_top">
<input type="hidden"
name="cmd"
value="_s-xclick">
<input type="hidden"
name="hosted_button_id"
value="SK827YKEALMT4">
<input type="image"
src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif"
name="submit"
alt="PayPal - The safer, easier way to pay online!">
<img alt=""
border="0"
src="https://www.paypalobjects.com/de_DE/i/scr/pixel.gif"
width="1"
height="1">
</form>
</li>
<li class="primary">
<a href="http://freetype.org/index.html">Home</a>
</li>
<li class="primary">
<a href="http://freetype.org/index.html#news">News</a>
</li>
<li class="primary">
<a href="../index.html">Overview</a>
</li>
<li class="primary">
<a href="../documentation.html">Documentation</a>
</li>
<li class="primary">
<a href="http://freetype.org/developer.html">Development</a>
</li>
<li class="primary">
<a href="http://freetype.org/contact.html"
class="emphasis">Contact</a>
</li>
<li>
<!-- separate primary from secondary entries -->
</li>
<li class="secondary">
<a href="index.html">FreeType Design</a>
</li>
<li class="tertiary">
<a href="design-1.html">Introduction</a>
</li>
<li class="tertiary">
<a href="design-2.html" class="current">Components and APIs</a>
</li>
<li class="tertiary">
<a href="design-3.html">Public Objects and Classes</a>
</li>
<li class="tertiary">
<a href="design-4.html">Internal Objects and Classes</a>
</li>
<li class="tertiary">
<a href="design-5.html">Module Classes</a>
</li>
<li class="tertiary">
<a href="design-6.html">Interfaces and Services</a>
</li>
</ul>
</div>
</div> <!-- id="wrapper" -->
<div id="TOC-bottom">
</div>
</body>
</html>