1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Clusters: HarfBuzz Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
7 <link rel="home" href="index.html" title="HarfBuzz Manual">
8 <link rel="up" href="pt01.html" title="Part I. User's manual">
9 <link rel="prev" href="using-your-own-font-functions.html" title="Using your own font functions">
10 <link rel="next" href="working-with-harfbuzz-clusters.html" title="Working with HarfBuzz clusters">
11 <meta name="generator" content="GTK-Doc V1.29 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts"></td>
17 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
18 <td><a accesskey="u" href="pt01.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
19 <td><a accesskey="p" href="using-your-own-font-functions.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="working-with-harfbuzz-clusters.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
23 <div class="titlepage"><div><div><h2 class="title">
24 <a name="clusters"></a>Clusters</h2></div></div></div>
25 <div class="toc"><dl class="toc">
26 <dt><span class="section"><a href="clusters.html#clusters-and-shaping">Clusters and shaping</a></span></dt>
27 <dt><span class="section"><a href="working-with-harfbuzz-clusters.html">Working with HarfBuzz clusters</a></span></dt>
28 <dt><span class="section"><a href="a-clustering-example-for-levels-0-and-1.html">A clustering example for levels 0 and 1</a></span></dt>
29 <dt><span class="section"><a href="reordering-in-levels-0-and-1.html">Reordering in levels 0 and 1</a></span></dt>
30 <dt><span class="section"><a href="the-distinction-between-levels-0-and-1.html">The distinction between levels 0 and 1</a></span></dt>
31 <dt><span class="section"><a href="level-2.html">Level 2</a></span></dt>
33 <dt><span class="section"><a href="level-2.html#ligatures-with-combining-marks-in-level-2">Ligatures with combining marks in level 2</a></span></dt>
34 <dt><span class="section"><a href="level-2.html#reordering-in-level-2">Reordering in level 2</a></span></dt>
35 <dt><span class="section"><a href="level-2.html#other-considerations-in-level-2">Other considerations in level 2</a></span></dt>
39 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
40 <a name="clusters-and-shaping"></a>Clusters and shaping</h2></div></div></div>
42 In text shaping, a <span class="emphasis"><em>cluster</em></span> is a sequence of
43 characters that needs to be treated as a single, indivisible
44 unit. A single letter or symbol can be a cluster of its
45 own. Other clusters correspond to longer subsequences of the
46 input code points — such as a ligature or conjunct form
47 — and require the shaper to ensure that the cluster is not
48 broken during the shaping process.
51 A cluster is distinct from a <span class="emphasis"><em>grapheme</em></span>,
52 which is the smallest unit of meaning in a writing system or
56 The definitions of the two terms are similar. However, clusters
57 are only relevant for script shaping and glyph layout. In
58 contrast, graphemes are a property of the underlying script, and
59 are of interest when client programs implement orthographic
60 or linguistic functionality.
63 For example, two individual letters are often two separate
64 graphemes. When two letters form a ligature, however, they
65 combine into a single glyph. They are then part of the same
66 cluster and are treated as a unit by the shaping engine —
67 even though the two original, underlying letters remain separate
71 HarfBuzz is concerned with clusters, <span class="emphasis"><em>not</em></span>
72 with graphemes — although client programs using HarfBuzz
73 may still care about graphemes for other reasons from time to time.
76 During the shaping process, there are several shaping operations
77 that may merge adjacent characters (for example, when two code
78 points form a ligature or a conjunct form and are replaced by a
79 single glyph) or split one character into several (for example,
80 when decomposing a code point through the
81 <code class="literal">ccmp</code> feature). Operations like these alter
82 clusters; HarfBuzz tracks the changes to ensure that no clusters
83 get lost or broken during shaping.
86 HarfBuzz records cluster information independently from how
87 shaping operations affect the individual glyphs returned in an
88 output buffer. Consequently, a client program using HarfBuzz can
89 utilize the cluster information to implement features such as:
91 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
92 <li class="listitem"><p>
93 Correctly positioning the cursor within a shaped text run,
94 even when characters have formed ligatures, composed or
95 decomposed, reordered, or undergone other shaping operations.
97 <li class="listitem"><p>
98 Correctly highlighting a text selection that includes some,
99 but not all, of the characters in a word.
101 <li class="listitem"><p>
102 Applying text attributes (such as color or underlining) to
103 part, but not all, of a word.
105 <li class="listitem"><p>
106 Generating output document formats (such as PDF) with
107 embedded text that can be fully extracted.
109 <li class="listitem"><p>
110 Determining the mapping between input characters and output
111 glyphs, such as which glyphs are ligatures.
113 <li class="listitem"><p>
114 Performing line-breaking, justification, and other
115 line-level or paragraph-level operations that must be done
116 after shaping is complete, but which require examining
117 character-level properties.
123 <hr>Generated by GTK-Doc V1.29</div>