/usr/share/doc/libfreetype6/glyphs/glyphs-5.html is in libfreetype6-dev 2.5.2-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | <!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"
sizes="16x16"
href="../../../image/favicon_-90.ico">
<link rel="shortcut icon"
href="../../../image/favicon_-90.ico">
<link rel="stylesheet"
type="text/css"
href="../../../freetype2_-90.css">
<script type="text/javascript"
src="../../../jquery-1.8.3.min.js">
</script>
<script type="text/javascript"
src="../../../jquery.ba-resize.min.js">
</script>
<script type="text/javascript"
src="../../../freetype2.js">
</script>
<title>FreeType Glyph Conventions / V</title>
</head>
<body>
<div id="top"
class="bar">
<h1><a href="../../../index.html">FreeType</a> Glyph
Conventions / V</h1>
</div>
<div id="wrapper">
<div class="colmask leftmenu">
<div class="colright">
<div class="col1wrap">
<div class="col1">
<!-- ************************************************** -->
<div id="text-processing">
<h2>V. Text Processing</h2>
<p>This section demonstrate algorithms which use the
concepts previously defined to render text, whatever
layout you use. It assumes <em>simple</em> text handling
suitable for scripts like Latin or Cyrillic, using a
one-to-one relationship between input character codes and
output glyphs indices. Scripts like Arabic or Khmer,
which need a ‘shaping engine’ to do the
character code to glyph index conversion, are beyond the
scope (and should be done by proper layout engines
like <a href="http://www.pango.org/">Pango</a>
anyway).</p>
<h3 id="section-1">1. Writing simple text strings</h3>
<p>In this first example, we will generate a simple string
of text in the Latin script, i.e. with a horizontal
left-to-right layout. Using exclusively pixel metrics,
the process looks like:
<ol class="algorithm">
<li>
Convert the character string into a series of glyph
indices.
</li>
<li>
Place the pen to the cursor position.
</li>
<li>
Get or load the glyph image.
</li>
<li>
Translate the glyph so that its ‘origin’
matches the pen position.
</li>
<li>
Render the glyph to the target device.
</li>
<li>
Increment the pen position by the glyph's advance
width (in pixels).
</li>
<li>
Start over at step 3 for each of the remaining
glyphs.
</li>
<li>
When all glyphs are done, set the text cursor to the
new pen position.
</li>
</ol>
<p>Note that kerning isn't part of this algorithm.</p>
<h3 id="section-2">2. Pseudo-subpixel positioning</h3>
<p>It is somewhat useful to use subpixel positioning when
rendering text. This is crucial, for example, to provide
semi-WYSIWYG text layouts. Text rendering is very similar
to the algorithm described in subsection 1, with the
following few differences:</p>
<ul>
<li>
<p>The pen position is expressed in fractional
pixels.</p>
</li>
<li>
<p>Because translating a hinted outline by a non-integer
distance will ruin its grid-fitting, the position of
the glyph origin must be rounded before rendering the
character image.</p>
</li>
<li>
<p>The advance width is expressed in fractional pixels,
and isn't necessarily an integer.</p>
</li>
</ul>
<p>Here an improved version of the algorithm:</p>
<ol class="algorithm">
<li>
Convert the character string into a series of glyph
indices.
</li>
<li>
Place the pen to the cursor position. This can be a
non-integer point.
</li>
<li>
Get or load the glyph image.
</li>
<li>
Translate the glyph so that its ‘origin’
matches the rounded pen position.
</li>
<li>
Render the glyph to the target device.
</li>
<li>
Increment the pen position by the glyph's advance width
in fractional pixels.
</li>
<li>
Start over at step 3 for each of the remaining
glyphs.
</li>
<li>
When all glyphs are done, set the text cursor to the new
pen position.
</li>
</ol>
<p>Note that with fractional pixel positioning, the space
between two given letters isn't fixed, but determined by
the accumulation of previous rounding errors in glyph
positioning. For auto-hinted glyphs, this problem can be
alleviated by using the <tt>lsb_delta</tt>
and <tt>rsb_delta</tt> values (see the documentation of
the <a href="../reference/ft2-base_interface.html#FT_GlyphSlotRec">FT_GlyphSlotRec</a>
structure for more details).</p>
<p>TODO: Real subpixel positioning with glyph shifting
before hinting.</p>
<h3 id="section-3">3. Simple kerning</h3>
<p>Adding kerning to the basic text rendering algorithm is
easy: When a kerning pair is found, simply add the scaled
kerning distance to the pen position before step 4.
Of course, the distance should be rounded in the case of
algorithm 1, though it doesn't need to for
algorithm 2. This gives us:</p>
<p>Algorithm 1 with kerning:</p>
<ol class="algorithm">
<li>
Convert the character string into a series of glyph
indices.
</li>
<li>
Place the pen to the cursor position.
</li>
<li>
Get or load the glyph image.
</li>
<li>
Add the rounded scaled kerning distance, if any, to the
pen position.
</li>
<li>
Translate the glyph so that its ‘origin’
matches the pen position.
</li>
<li>
Render the glyph to the target device.
</li>
<li>
Increment the pen position by the glyph's advance width
in pixels.
</li>
<li>
Start over at step 3 for each of the remaining
glyphs.
</li>
</ol>
<p>Algorithm 2 with kerning:</p>
<ol class="algorithm">
<li>
Convert the character string into a series of glyph
indices.
</li>
<li>
Place the pen to the cursor position.
</li>
<li>
Get or load the glyph image.
</li>
<li>
Add the scaled unrounded kerning distance, if any, to
the pen position.
</li>
<li>
Translate the glyph so that its ‘origin’
matches the rounded pen position.
</li>
<li>
Render the glyph to the target device.
</li>
<li>
Increment the pen position by the glyph's advance
width in fractional pixels.
</li>
<li>
Start over at step 3 for each of the remaining
glyphs.
</li>
</ol>
<h3 id="section-4">4. Right-to-left layout</h3>
<p>The process of laying out right-to-left scripts like
(modern) Hebrew text is very similar. The only difference
is that the pen position must be decremented before the
glyph rendering (remember: the advance width is always
positive, even for Hebrew glyphs).</p>
<p>Right-to-left algorithm 1:</p>
<ol class="algorithm">
<li>
Convert the character string into a series of glyph
indices.
</li>
<li>
Place the pen to the cursor position.
</li>
<li>
Get or load the glyph image.
</li>
<li>
Decrement the pen position by the glyph's advance
width in pixels.
</li>
<li>
Translate the glyph so that its ‘origin’
matches the pen position.
</li>
<li>
Render the glyph to the target device.
</li>
<li>
Start over at step 3 for each of the remaining
glyphs.
</li>
</ol>
<p>The changes to algorithm 2, as well as the inclusion
of kerning are left as an exercise to the reader.</p>
<h3 id="section-5">5. Vertical layouts</h3>
<p>Laying out vertical text uses exactly the same processes,
with the following significant differences:</p>
<ul>
<li>
<p>The baseline is vertical, and the vertical metrics
must be used instead of the horizontal one.</p>
</li>
<li>
<p>The left bearing is usually negative, but this
doesn't change the fact that the glyph origin must be
located on the baseline.</p>
</li>
<li>
<p>The advance height is always positive, so the pen
position must be decremented if one wants to write top
to bottom (assuming the <i>Y</i> axis is oriented
upwards).</p>
</li>
</ul>
<p>Here the algorithm:</p>
<ol class="algorithm">
<li>
Convert the character string into a series of glyph
indices.
</li>
<li>
Place the pen to the cursor position.
</li>
<li>
Get or load the glyph image.
</li>
<li>
Translate the glyph so that its ‘origin’
matches the pen position.
</li>
<li>
Render the glyph to the target device.
</li>
<li>
Decrement the vertical pen position by the glyph's
advance height in pixels.
</li>
<li>
Start over at step 3 for each of the remaining
glyphs.
</li>
<li>
When all glyphs are done, set the text cursor to the new
pen position.
</li>
</ol>
</div>
<!-- ************************************************** -->
<div class="updated">
<p>Last update: 1-Jul-2013</p>
</div>
</div>
</div>
<!-- ************************************************** -->
<div class="col2">
</div>
</div>
</div>
<!-- ************************************************** -->
<div id="TOC">
<ul>
<li class="funding">
<p><a href="http://pledgie.com/campaigns/18808">
<img alt="Click here to lend your support to the FreeType project and make a donation at pledgie.com!"
src="http://pledgie.com/campaigns/18808.png?skin_name=chrome"
border="0"
align="middle">
</a></p>
<p><a href="http://flattr.com/thing/882217/The-FreeType-Project"
target="_blank">
<img class="with-border"
src="http://api.flattr.com/button/flattr-badge-large.png"
alt="Flattr this"
title="Flattr this"
border="0"
align="middle">
</a></p>
</li>
<li class="primary">
<a href="../../../index.html">Home</a>
</li>
<li class="primary">
<a href="../../../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="../../../developer.html">Development</a>
</li>
<li class="primary">
<a href="../../../contact.html"
class="emphasis">Contact</a>
</li>
<li>
<!-- separate primary from secondary entries -->
</li>
<li class="secondary">
<a href="index.html">FreeType Glyph Conventions</a>
</li>
<li class="tertiary">
<a href="glyphs-1.html">Basic Typographic Concepts</a>
</li>
<li class="tertiary">
<a href="glyphs-2.html">Glyph Outlines</a>
</li>
<li class="tertiary">
<a href="glyphs-3.html">Glyph Metrics</a>
</li>
<li class="tertiary">
<a href="glyphs-4.html">Kerning</a>
</li>
<li class="tertiary">
<a href="glyphs-5.html" class="current">Text Processing</a>
</li>
<li class="tertiary">
<a href="glyphs-6.html">FreeType Outlines</a>
</li>
<li class="tertiary">
<a href="glyphs-7.html">FreeType Bitmaps</a>
</li>
</ul>
</div>
</div> <!-- id="wrapper" -->
<div id="TOC-bottom">
</div>
</body>
</html>
|