| 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 FAQ"> |
| 15 |
<meta name="Author" |
| 16 |
content="David Turner"> |
| 17 |
|
| 18 |
<link rel="icon" |
| 19 |
href="image/favicon_-90.ico"> |
| 20 |
<link rel="shortcut icon" |
| 21 |
href="image/favicon_-90.ico"> |
| 22 |
<link rel="stylesheet" |
| 23 |
type="text/css" |
| 24 |
href="css/freetype2_-90.css"> |
| 25 |
|
| 26 |
</script> |
| 27 |
<script type="text/javascript" |
| 28 |
src="../../js/freetype2.js"> |
| 29 |
</script> |
| 30 |
|
| 31 |
<title>FreeType FAQ</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> FAQ</h1> |
| 40 |
</div> |
| 41 |
|
| 42 |
|
| 43 |
<div id="wrapper"> |
| 44 |
|
| 45 |
<div class="colmask leftmenu"> |
| 46 |
<div class="colright"> |
| 47 |
<div class="col1wrap"> |
| 48 |
<div class="col1"> |
| 49 |
|
| 50 |
|
| 51 |
<!-- ************************************************** --> |
| 52 |
|
| 53 |
<div id="contents"> |
| 54 |
<h3><a href="#general">General questions</a></h3> |
| 55 |
<ul> |
| 56 |
<li> |
| 57 |
<a href="#general-what">What is FreeType?</a> |
| 58 |
</li> |
| 59 |
<li> |
| 60 |
<a href="#general-uses">What can I do with FreeType?</a> |
| 61 |
</li> |
| 62 |
<li> |
| 63 |
<a href="#general-donts">What can I not do with |
| 64 |
FreeType?</a> |
| 65 |
</li> |
| 66 |
<li> |
| 67 |
<a href="#general-portability">How portable is |
| 68 |
FreeType?</a> |
| 69 |
</li> |
| 70 |
<li> |
| 71 |
<a href="#general-edit">Can I use FreeType to edit fonts |
| 72 |
or create new ones?</a> |
| 73 |
</li> |
| 74 |
<li> |
| 75 |
<a href="#general-typesetting">How do I render a line of |
| 76 |
text in FreeType?</a> |
| 77 |
</li> |
| 78 |
</ul> |
| 79 |
|
| 80 |
<h3><a href="#builds">Compilation & |
| 81 |
configuration</a></h3> |
| 82 |
<ul> |
| 83 |
<li> |
| 84 |
<a href="#builds-compile">How do I compile the FreeType |
| 85 |
library?</a> |
| 86 |
</li> |
| 87 |
<li> |
| 88 |
<a href="#builds-config">How do I configure my build of |
| 89 |
the library?</a> |
| 90 |
</li> |
| 91 |
<li> |
| 92 |
<a href="#builds-differences">Why does FreeType render |
| 93 |
differently on different platforms?</a> |
| 94 |
</li> |
| 95 |
</ul> |
| 96 |
|
| 97 |
<h3><a href="#autohint">The FreeType auto-hinter</a></h3> |
| 98 |
<ul> |
| 99 |
<li> |
| 100 |
<a href="#autohint-work">How does the auto-hinter |
| 101 |
work?</a> |
| 102 |
</li> |
| 103 |
<li> |
| 104 |
<a href="#autohint-other-scripts">Why doesn't the |
| 105 |
auto-hinter work well with my script?</a> |
| 106 |
</li> |
| 107 |
</ul> |
| 108 |
|
| 109 |
<h3><a href="#other">Other questions</a></h3> |
| 110 |
<ul> |
| 111 |
<li> |
| 112 |
<a href="#other-depth">Can I use FreeType to draw text |
| 113 |
on a pixmap with arbitrary depth?</a> |
| 114 |
</li> |
| 115 |
<li> |
| 116 |
<a href="#other-color">How can I set the colour of text |
| 117 |
rendered by FreeType?</a> |
| 118 |
</li> |
| 119 |
<li> |
| 120 |
<a href="#other-size">I set the pixel size to 8×8, |
| 121 |
but the resulting glyphs are larger (or smaller) than |
| 122 |
that. Why?</a> |
| 123 |
</li> |
| 124 |
<li> |
| 125 |
<a href="#other-bbox">How can I compute the bounding box |
| 126 |
of a text string without loading its glyphs |
| 127 |
before?</a> |
| 128 |
</li> |
| 129 |
<li> |
| 130 |
<a href="#other-antialias">Which anti-aliasing algorithm |
| 131 |
is used by FreeType?</a> |
| 132 |
</li> |
| 133 |
<li> |
| 134 |
<a href="#other-opentype">When will FreeType support |
| 135 |
OpenType?</a> |
| 136 |
</li> |
| 137 |
<li> |
| 138 |
<a href="#other-vertical">How to implement Asian |
| 139 |
vertical writing text with FreeType?</a> |
| 140 |
</li> |
| 141 |
</ul> |
| 142 |
</div> |
| 143 |
|
| 144 |
|
| 145 |
<!-- ************************************************** --> |
| 146 |
|
| 147 |
<div id="faq"> |
| 148 |
<a name="general"></a> |
| 149 |
<h1>General questions</h1> |
| 150 |
|
| 151 |
<a name="general-what"></a> |
| 152 |
<h3>What is FreeType?</h3> |
| 153 |
|
| 154 |
<p>It is a software library that can be used by all kinds of |
| 155 |
applications to access the contents of font files. Most |
| 156 |
notably, it supports the following features.</p> |
| 157 |
|
| 158 |
<ul> |
| 159 |
<li> |
| 160 |
<p>It provides a uniform interface to access font files. |
| 161 |
It supports both bitmap and scalable formats, |
| 162 |
including TrueType, OpenType, Type1, CID, CFF, Windows |
| 163 |
FON/FNT, X11 PCF, and others.</p> |
| 164 |
</li> |
| 165 |
|
| 166 |
<li> |
| 167 |
<p>It supports high-speed, anti-aliased glyph bitmap |
| 168 |
generation with 256 gray levels.</p> |
| 169 |
</li> |
| 170 |
|
| 171 |
<li> |
| 172 |
<p>It is extremely modular, each font format being |
| 173 |
supported by a specific module. A build of the |
| 174 |
library can be tailored to support only the formats |
| 175 |
you need, thus reducing code size. A minimal |
| 176 |
anti-aliasing build of FreeType can be less than |
| 177 |
30kByte.</p> |
| 178 |
</li> |
| 179 |
</ul> |
| 180 |
|
| 181 |
<a name="general-uses"></a> |
| 182 |
<h3>What can I do with FreeType?</h3> |
| 183 |
|
| 184 |
<p>FreeType is already used in many products. For example, |
| 185 |
it serves as a font rendering engine</p> |
| 186 |
|
| 187 |
<ul> |
| 188 |
<li> |
| 189 |
in graphics subsystem and libraries to display text |
| 190 |
(Android OS, Apple's iOS, and others), |
| 191 |
</li> |
| 192 |
<li> |
| 193 |
in text layout and pagination services to measure and |
| 194 |
eventually render text, |
| 195 |
</li> |
| 196 |
<li> |
| 197 |
in font inspection and conversion tools. |
| 198 |
</li> |
| 199 |
</ul> |
| 200 |
|
| 201 |
<p>Generally speaking, the library allows you to access and |
| 202 |
manage the contents of font files in a very easy way.</p> |
| 203 |
|
| 204 |
<a name="general-donts"></a> |
| 205 |
<h3>What can I not do with FreeType?</h3> |
| 206 |
|
| 207 |
<p>FreeType doesn't try to perform a number of sophisticated |
| 208 |
things, because it focuses on being an excellent <em>font |
| 209 |
service</em>.</p> |
| 210 |
|
| 211 |
<p>This means that the following features are not supported |
| 212 |
directly by the library, even though they can be more or |
| 213 |
less implemented on top of it, or by using it.</p> |
| 214 |
|
| 215 |
<ul> |
| 216 |
<li> |
| 217 |
<p><b>rendering glyphs to arbitrary surfaces</b><br> |
| 218 |
|
| 219 |
FreeType doesn't try to be a graphics library and thus |
| 220 |
only supports a very small number of pixel formats |
| 221 |
when rendering glyphs, in particular monochrome 1-bit |
| 222 |
bitmaps and 8-bit gray-level pixmaps.</p> |
| 223 |
|
| 224 |
<p>If you need to draw glyphs to other kinds of surfaces |
| 225 |
(for example, a 24-bit RGB pixmap), you need to use |
| 226 |
your favorite graphics library to do just that.</p> |
| 227 |
|
| 228 |
<p><em>Note, however, that in the case of rendering |
| 229 |
scalable glyph outlines to anti-aliased pixmaps, an |
| 230 |
application can also provide its own rendering |
| 231 |
callback in order to draw or compose directly the |
| 232 |
anti-aliased glyph on any target surface.</em></p> |
| 233 |
</li> |
| 234 |
|
| 235 |
<li> |
| 236 |
<p><b>glyph caching</b><br> |
| 237 |
|
| 238 |
Each time you request a glyph image from a font, |
| 239 |
FreeType does it by parsing the relevant portion of |
| 240 |
the font file or font stream and interpreting it |
| 241 |
according to its font format. This can be very slow |
| 242 |
for certain formats, including scalable ones like |
| 243 |
TrueType or CFF.</p> |
| 244 |
|
| 245 |
<p>Any decent text-rendering sub-system must thus be |
| 246 |
capable of caching glyph data in order to reach |
| 247 |
appropriate rendering speed.</p> |
| 248 |
|
| 249 |
<p><em>Note that we provide a caching sub-system with |
| 250 |
FreeType. However, it might not suit your |
| 251 |
needs.</em></p> |
| 252 |
</li> |
| 253 |
|
| 254 |
<li> |
| 255 |
<p><b>text layout</b><br> |
| 256 |
|
| 257 |
The library doesn't support text layout operations. |
| 258 |
Sophisticated features like glyph substitution, |
| 259 |
positioning (kerning), justification, bi-directional |
| 260 |
ordering, etc., are not part of a |
| 261 |
<em>font service</em> in itself. They must be handled |
| 262 |
(at least) one level higher.</p> |
| 263 |
</li> |
| 264 |
</ul> |
| 265 |
|
| 266 |
<a name="general-portability"></a> |
| 267 |
<h3>How portable is FreeType?</h3> |
| 268 |
|
| 269 |
<p>FreeType's source code is <em>extremely</em> portable for |
| 270 |
the following reasons.</p> |
| 271 |
|
| 272 |
<ul> |
| 273 |
<li> |
| 274 |
<p>Everything is written in standard ANSI C.</p> |
| 275 |
</li> |
| 276 |
<li> |
| 277 |
<p>We are very pedantic to avoid any kinds of compiler |
| 278 |
warnings. The current source code has been compiled |
| 279 |
with many compilers without producing a single |
| 280 |
warning.</p> |
| 281 |
</li> |
| 282 |
<li> |
| 283 |
<p>The library doesn't use any static writable data at |
| 284 |
all, making it an ideal choice on various embedded |
| 285 |
systems (e.g., it can be run from ROM directly). It |
| 286 |
is completely thread-safe too.</p> |
| 287 |
</li> |
| 288 |
</ul> |
| 289 |
|
| 290 |
<p>We have made great efforts to ensure that the library is |
| 291 |
efficient, compact, and customizable.</p> |
| 292 |
|
| 293 |
<a name="general-edit"></a> |
| 294 |
<h3>Can I use FreeType to edit fonts or create new |
| 295 |
ones?</h3> |
| 296 |
|
| 297 |
<p>No. The library is specifically designed |
| 298 |
to <em>read</em> font files with small code size and very |
| 299 |
low memory usage.</p> |
| 300 |
|
| 301 |
<p>A good, freely available font editor |
| 302 |
is <a href="https://fontforge.org/">FontForge</a>.</p> |
| 303 |
|
| 304 |
<a name="general-typesetting"></a> |
| 305 |
<h3>How do I render a line of text in FreeType?</h3> |
| 306 |
|
| 307 |
<p>FreeType is a very low-level rendering engine. All it |
| 308 |
knows how to do is render individual glyphs and return |
| 309 |
metrics for them.</p> |
| 310 |
|
| 311 |
<p>Arranging glyphs into words and lines is best left to a |
| 312 |
2D graphics rendering library |
| 313 |
like <a href="https://www.cairographics.org">Cairo</a>. |
| 314 |
Cairo is able to do some primitive typesetting, including |
| 315 |
very basic translation of Unicode character codes to |
| 316 |
glyphs; for a more general solution, it |
| 317 |
uses <a href="https://pango.org">Pango</a> for text |
| 318 |
layout, which in turn relies |
| 319 |
on <a href="https://harfbuzz.github.io/">HarfBuzz</a> to |
| 320 |
implement the full OpenType rules for glyph substitution |
| 321 |
and placement (Cairo still handles the actual text |
| 322 |
drawing). To deal with right-to-left (Arabic, Hebrew) |
| 323 |
text layout, you will also need |
| 324 |
<a href="https://github.com/fribidi/fribidi">FriBidi</a>, |
| 325 |
which handles the details of the Unicode bidirectional |
| 326 |
layout algorithm.</p> |
| 327 |
|
| 328 |
<p>And finally, to cope with additional niceties like |
| 329 |
dealing with writing-system-specific rules for word breaks |
| 330 |
and line breaks, you might like to look at |
| 331 |
<a href="https://icu-project.org/">ICU</a>, which |
| 332 |
includes a whole range of internationalization and |
| 333 |
localization facilities.</p> |
| 334 |
|
| 335 |
|
| 336 |
<a name="builds"></a> |
| 337 |
<h1>Compilation & configuration</h1> |
| 338 |
|
| 339 |
<a name="builds-compile"></a> |
| 340 |
<h3>How do I compile the FreeType library?</h3> |
| 341 |
|
| 342 |
<p>The library can be compiled in various ways, and detailed |
| 343 |
documentation is available in documentation directory of |
| 344 |
FreeType's source tree.</p> |
| 345 |
|
| 346 |
<p>For compilation on the command |
| 347 |
line, <a href="https://www.gnu.org/software/make/">GNU |
| 348 |
make</a> is the standard tool. The source bundle also |
| 349 |
comes with support files |
| 350 |
for <a href="https://cmake.org">CMake</a> and |
| 351 |
<a href="https://mesonbuild.org">meson</a> builds, |
| 352 |
together with project files |
| 353 |
for <a href="https://learn.microsoft.com/visualstudio/windows/">Visual |
| 354 |
C++</a> and some other, older graphical IDEs. Note, |
| 355 |
however, that those files are sometimes not up to date |
| 356 |
since it is contributed code not used by the core |
| 357 |
developers.</p> |
| 358 |
|
| 359 |
<a name="builds-config"></a> |
| 360 |
<h3>How do I configure my build of the library?</h3> |
| 361 |
|
| 362 |
<p>This is fully described in the |
| 363 |
file <a href="https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/docs/CUSTOMIZE"><code>CUSTOMIZE</code></a> |
| 364 |
in FreeType's documentation directory. Basically, you |
| 365 |
have to edit the header |
| 366 |
file <a href="https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/include/freetype/config/ftoption.h"><code>ftoption.h</code></a> |
| 367 |
for compile-time options and to select the modules with |
| 368 |
the |
| 369 |
file <a href="https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/modules.cfg"><code>modules.cfg</code></a>. |
| 370 |
Finally, it is possible to replace the standard system |
| 371 |
interface (dealing with memory allocation and stream I/O) |
| 372 |
with a custom one.</p> |
| 373 |
|
| 374 |
<a name="builds-differences"></a> |
| 375 |
<h3>Why does FreeType render differently on different |
| 376 |
platforms?</h3> |
| 377 |
|
| 378 |
<p>Different distributions compile FreeType with different |
| 379 |
options. The developer version of a distribution's |
| 380 |
FreeType package, which is needed to compile your program |
| 381 |
against FreeType, includes the file |
| 382 |
<a href="https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/include/freetype/config/ftoption.h"><code>ftoption.h</code></a>. |
| 383 |
Compare each platform's copy of |
| 384 |
<code>ftoption.h</code> to find the differences.</p> |
| 385 |
|
| 386 |
|
| 387 |
<a name="autohint"></a> |
| 388 |
<h1>The FreeType auto-hinter</h1> |
| 389 |
|
| 390 |
<a name="autohint-work"></a> |
| 391 |
<h3>How does the auto-hinter work?</h3> |
| 392 |
|
| 393 |
<p><em>Please note that the name of auto-hinter module is |
| 394 |
<b>autofit</b>, which is a reimplementation of the old |
| 395 |
‘autohint’ module.</em></p> |
| 396 |
|
| 397 |
<p>A rather complete description of the hinting algorithm |
| 398 |
(which is slightly out of date regarding the internal |
| 399 |
structures) can be found in the TUGboat |
| 400 |
article <a href="https://tug.org/TUGboat/Articles/tb24-3/lemberg.pdf">Real-Time |
| 401 |
Grid Fitting of Typographic Outlines</a>.</p> |
| 402 |
|
| 403 |
<p>The auto-hinter performs grid-fitting on scalable font |
| 404 |
formats that use Bézier outlines as their primary |
| 405 |
glyph image format (this means nearly all scalable font |
| 406 |
formats today). If a given font driver doesn't provide |
| 407 |
its own hinter, the auto-hinter is used by default. If a |
| 408 |
format-specific hinter is provided, it is still possible |
| 409 |
to use the auto-hinter using |
| 410 |
the <a href="https://freetype.org/freetype2/docs/reference/ft2-glyph_retrieval.html#ft_load_xxx"><code>FT_LOAD_FORCE_AUTOHINT</code></a> |
| 411 |
bit flag when calling |
| 412 |
function <a href="https://freetype.org/freetype2/docs/reference/ft2-glyph_retrieval.html#ft_load_glyph"><code>FT_Load_Glyph</code></a>.</p> |
| 413 |
|
| 414 |
<p>Currently, the auto-hinter doesn't use external hints to |
| 415 |
do its job, as it automatically computes global metrics |
| 416 |
(when it ‘opens’ a font for the first time) |
| 417 |
and glyph ‘hints’ from their outline.</p> |
| 418 |
|
| 419 |
<a name="autohint-other-scripts"></a> |
| 420 |
<h3>Why doesn't the auto-hinter work well with my |
| 421 |
script?</h3> |
| 422 |
|
| 423 |
<p>The auto-hinter was first designed to manage and hint |
| 424 |
Latin-based fonts, as they consist of most of the fonts |
| 425 |
available today. It now supports almost all scripts |
| 426 |
available in Unicode.</p> |
| 427 |
|
| 428 |
<p>Hinting various scripts isn't really more difficult than |
| 429 |
Latin, just different, with a set of different |
| 430 |
constraints, which must be hard-coded into the autofit |
| 431 |
module. If your particular script is still missing and |
| 432 |
you are an expert for this script, we would be very glad |
| 433 |
to add the necessary code with your help!</p> |
| 434 |
|
| 435 |
|
| 436 |
<a name="other"></a> |
| 437 |
<h1>Other questions</h1> |
| 438 |
|
| 439 |
<a name="other-depth"></a> |
| 440 |
<h3>Can I use FreeType to draw text on a pixmap with |
| 441 |
arbitrary depth?</h3> |
| 442 |
|
| 443 |
<p>Not directly, as FreeType is a font library, not a |
| 444 |
general-purpose graphics library or text rendering |
| 445 |
service. However, the anti-aliased renderer allows you to |
| 446 |
convert a vectorial glyph outline into a list of |
| 447 |
‘spans’ (i.e., horizontal pixel segments with |
| 448 |
the same coverage) that can be rendered through |
| 449 |
user-provided callbacks.</p> |
| 450 |
|
| 451 |
<p>By providing an appropriate span callback, you can render |
| 452 |
anti-aliased text to any kind of surface. You can also |
| 453 |
use any colour, fill pattern or fill image if you want to. |
| 454 |
This process is called <em>direct rendering</em>.</p> |
| 455 |
|
| 456 |
<p>A complete example is given in |
| 457 |
the <a href="tutorial/step3.html">FreeType tutorial</a>. |
| 458 |
|
| 459 |
<p>Note that direct rendering is <em>not</em> available with |
| 460 |
monochrome output, as the current renderer uses a two-pass |
| 461 |
algorithm to generate glyphs with correct drop-out |
| 462 |
control.</p> |
| 463 |
|
| 464 |
<a name="other-color"></a> |
| 465 |
<h3>How can I set the colour of text rendered by |
| 466 |
FreeType?</h3> |
| 467 |
|
| 468 |
<p>Basically, you can't do that, because FreeType is simply |
| 469 |
a font library. In general, you need to use your favorite |
| 470 |
graphics library to draw the FreeType glyphs with the |
| 471 |
appropriate colour.</p> |
| 472 |
|
| 473 |
<p>Note that for anti-aliased glyphs, you can ‘set the |
| 474 |
colour’ by using <em>direct rendering</em> as |
| 475 |
described in <a href="#other-depth">this answer</a>.</p> |
| 476 |
|
| 477 |
<a name="other-size"></a> |
| 478 |
<h3>I set the pixel size to 8×8, but the resulting |
| 479 |
glyphs are larger (or smaller) than that. Why?</h3> |
| 480 |
|
| 481 |
<p>A lot of people have difficulties to understand this |
| 482 |
topic, because they think of glyphs as fixed-width or |
| 483 |
fixed-height ‘cells’, like those of fonts used |
| 484 |
in terminals or consoles. This assumption is not valid |
| 485 |
with most ‘modern’ font formats, it even fails |
| 486 |
for bitmapped-based ones like <b>PCF</b> or |
| 487 |
<b>BDF</b>.</p> |
| 488 |
|
| 489 |
<p>Be aware that the <em>character size</em> that is set |
| 490 |
either through |
| 491 |
function <a href="https://freetype.org/freetype2/docs/reference/ft2-sizing_and_scaling.html#ft_set_char_size"><code>FT_Set_Char_Size</code></a> |
| 492 |
or <a href="https://freetype.org/freetype2/docs/reference/ft2-sizing_and_scaling.html#ft_set_pixel_sizes"><code>FT_Set_Pixel_Sizes()</code></a> |
| 493 |
isn't directly related to the dimension of the generated |
| 494 |
glyph bitmaps!</p> |
| 495 |
|
| 496 |
<p>Rather, the character size is indeed the size of <em>an |
| 497 |
abstract square</em>, called the <em>EM Square</em>, |
| 498 |
used by typographers to design fonts. Scaling two |
| 499 |
distinct fonts to the same character size, be it |
| 500 |
expressed in points or pixels, generally results in |
| 501 |
bitmaps with <em>distinct dimensions</em>!</p> |
| 502 |
|
| 503 |
<p>Note that historically, the EM Square corresponded to the |
| 504 |
width of a capital ‘M’ in Latin typefaces |
| 505 |
(thus the name). However, later improvements in |
| 506 |
typography led to designs that greatly deviate from this |
| 507 |
rule. Today, it is not possible to connect the EM size to |
| 508 |
a specific font ‘feature’ in a reliable |
| 509 |
way.</p> |
| 510 |
|
| 511 |
<a name="other-bbox"></a> |
| 512 |
<h3>How can I compute the bounding box of a text string |
| 513 |
without loading its glyphs before?</h3> |
| 514 |
|
| 515 |
<p>This is not possible in general. Reason is that hinting |
| 516 |
distorts the glyph shape for optimal rasterization, and |
| 517 |
this process sometimes creates outlines that have |
| 518 |
considerably different metrics. The TrueType format |
| 519 |
provides the (optional) ‘hdmx’ table that |
| 520 |
contains device horizontal metrics for selected pixel |
| 521 |
sizes, but even here the vertical metrics are missing.</p> |
| 522 |
|
| 523 |
<p>It is probably best to use both a glyph and a metrics |
| 524 |
cache to avoid recomputation.</p> |
| 525 |
|
| 526 |
<a name="other-antialias"></a> |
| 527 |
<h3>Which anti-aliasing algorithm is used by FreeType?</h3> |
| 528 |
|
| 529 |
<p>The algorithm has been specifically designed for |
| 530 |
FreeType. It is based on ideas that were originally found |
| 531 |
in the implementation of the |
| 532 |
<a href="http://www.levien.com/libart/">libArt</a> |
| 533 |
graphics library to compute the <em>exact pixel |
| 534 |
coverage</em> of a vector image with no sub-sampling and |
| 535 |
filtering.</p> |
| 536 |
|
| 537 |
<p>However, these two implementations are radically distinct |
| 538 |
and use vastly different models. The FreeType renderer is |
| 539 |
optimized specifically for rendering small complex shapes, |
| 540 |
like glyphs, at very high speed while using very few |
| 541 |
memory. On the other hand, libArt has been designed for |
| 542 |
general shape and polygon processing, especially large |
| 543 |
ones.</p> |
| 544 |
|
| 545 |
<p>The FreeType anti-aliasing renderer is indeed |
| 546 |
<em>faster</em> than the monochrome renderer for small |
| 547 |
character sizes (typically <20 pixels). The |
| 548 |
reason is that the monochrome renderer must perform two |
| 549 |
passes on the outline in order to perform drop-out control |
| 550 |
according to the TrueType specification.</p> |
| 551 |
|
| 552 |
<a name="other-opentype"></a> |
| 553 |
<h3>When will FreeType support OpenType?</h3> |
| 554 |
|
| 555 |
<p>Well, the engine already reads OpenType/CFF files |
| 556 |
perfectly. What it doesn't do is handling ‘OpenType |
| 557 |
Layout’ tables.</p> |
| 558 |
|
| 559 |
<p>The predecessor of FreeType 2, the now defunct |
| 560 |
FreeType 1 series, came with a set of extensions that |
| 561 |
were used to load and manage OpenType Layout tables. It |
| 562 |
even had a demonstration program |
| 563 |
named <code>ftstrtto</code> to show its capabilities. |
| 564 |
However, this code is no longer maintained, and we |
| 565 |
strongly advise to not use it.</p> |
| 566 |
|
| 567 |
<p>See <a href="#general-typesetting">this answer</a> for |
| 568 |
more.</p> |
| 569 |
|
| 570 |
<a name="other-vertical"></a> |
| 571 |
<h3>How to implement Asian vertical writing text with |
| 572 |
FreeType?</h3> |
| 573 |
|
| 574 |
<p>FreeType 2 no longer supports it. Before the |
| 575 |
general adoption |
| 576 |
of <a href="https://learn.microsoft.com/typography/opentype/spec/">OpenType</a> |
| 577 |
in the font industry, text renderers implemented many |
| 578 |
hacks to handle vertical typesetting, like detection of |
| 579 |
the vertical writing mode by relying on modified font |
| 580 |
names, renderer-side rotation to obtain vertical glyph |
| 581 |
representation forms, or putting pre-rotated glyphs at |
| 582 |
non-standard <a href="https://www.unicode.org/faq/private_use.html">Unicode |
| 583 |
PUA codepoints</a> in the font. Modern operating systems |
| 584 |
and font developers switched to TrueType GX and later to |
| 585 |
OpenType many years ago, and fonts designed for such |
| 586 |
legacy technologies are no longer widely distributed.</p> |
| 587 |
|
| 588 |
<p>See <a href="#general-typesetting">this answer</a> for |
| 589 |
more.</p> |
| 590 |
|
| 591 |
</div> |
| 592 |
|
| 593 |
<!-- ************************************************** --> |
| 594 |
|
| 595 |
<div class="updated"> |
| 596 |
<p>Last update: 16-May-2021</p> |
| 597 |
</div> |
| 598 |
</div> |
| 599 |
</div> |
| 600 |
|
| 601 |
|
| 602 |
<!-- ************************************************** --> |
| 603 |
|
| 604 |
<div class="col2"> |
| 605 |
</div> |
| 606 |
</div> |
| 607 |
</div> |
| 608 |
|
| 609 |
|
| 610 |
<!-- ************************************************** --> |
| 611 |
|
| 612 |
<div id="TOC"> |
| 613 |
<ul> |
| 614 |
<li class="funding"> |
| 615 |
<form action="https://www.paypal.com/cgi-bin/webscr" |
| 616 |
method="post" |
| 617 |
target="_top"> |
| 618 |
<input type="hidden" |
| 619 |
name="cmd" |
| 620 |
value="_s-xclick"> |
| 621 |
<input type="hidden" |
| 622 |
name="hosted_button_id" |
| 623 |
value="SK827YKEALMT4"> |
| 624 |
<input type="image" |
| 625 |
src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" |
| 626 |
name="submit" |
| 627 |
alt="PayPal - The safer, easier way to pay online!"> |
| 628 |
</form> |
| 629 |
</li> |
| 630 |
<li class="primary"> |
| 631 |
<a href="http://freetype.org/index.html">Home</a> |
| 632 |
</li> |
| 633 |
<li class="primary"> |
| 634 |
<a href="http://freetype.org/index.html#news">News</a> |
| 635 |
</li> |
| 636 |
<li class="primary"> |
| 637 |
<a href="index.html">Overview</a> |
| 638 |
</li> |
| 639 |
<li class="primary"> |
| 640 |
<a href="documentation.html">Documentation</a> |
| 641 |
</li> |
| 642 |
<li class="primary"> |
| 643 |
<a href="http://freetype.org/developer.html">Development</a> |
| 644 |
</li> |
| 645 |
<li class="primary"> |
| 646 |
<a href="http://freetype.org/contact.html" |
| 647 |
class="emphasis">Contact</a> |
| 648 |
</li> |
| 649 |
|
| 650 |
<li> |
| 651 |
<!-- separate primary from secondary entries --> |
| 652 |
</li> |
| 653 |
|
| 654 |
<li class="secondary"> |
| 655 |
<a href="ft2faq.html" class="current">FreeType FAQ</a> |
| 656 |
</li> |
| 657 |
<li class="tertiary"> |
| 658 |
<a href="#general">General questions</a> |
| 659 |
</li> |
| 660 |
<li class="tertiary"> |
| 661 |
<a href="#builds">Compilation & configuration</a> |
| 662 |
</li> |
| 663 |
<li class="tertiary"> |
| 664 |
<a href="#autohint">The FreeType auto-hinter</a> |
| 665 |
</li> |
| 666 |
<li class="tertiary"> |
| 667 |
<a href="#other">Other questions</a> |
| 668 |
</li> |
| 669 |
</ul> |
| 670 |
</div> |
| 671 |
|
| 672 |
</div> <!-- id="wrapper" --> |
| 673 |
|
| 674 |
<div id="TOC-bottom"> |
| 675 |
</div> |
| 676 |
|
| 677 |
</body> |
| 678 |
</html> |