Imported Upstream version 2.3.1
[platform/upstream/harfbuzz.git] / docs / html / a-clustering-example-for-levels-0-and-1.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>A clustering example for levels 0 and 1: HarfBuzz Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="index.html" title="HarfBuzz Manual">
8 <link rel="up" href="clusters.html" title="Clusters">
9 <link rel="prev" href="working-with-harfbuzz-clusters.html" title="Working with HarfBuzz clusters">
10 <link rel="next" href="reordering-in-levels-0-and-1.html" title="Reordering in levels 0 and 1">
11 <meta name="generator" content="GTK-Doc V1.25 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
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="clusters.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
19 <td><a accesskey="p" href="working-with-harfbuzz-clusters.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="reordering-in-levels-0-and-1.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
21 </tr></table>
22 <div class="section">
23 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
24 <a name="a-clustering-example-for-levels-0-and-1"></a>A clustering example for levels 0 and 1</h2></div></div></div>
25 <p>
26       The basic shaping operations affect clusters in a predictable
27       manner when using level 0 or level 1: 
28     </p>
29 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
30 <li class="listitem"><p>
31           When two or more clusters <span class="emphasis"><em>merge</em></span>, the
32           resulting merged cluster takes as its cluster value the
33           <span class="emphasis"><em>minimum</em></span> of the incoming cluster values.
34         </p></li>
35 <li class="listitem"><p>
36           When a cluster <span class="emphasis"><em>decomposes</em></span>, all of the
37           resulting child clusters inherit as their cluster value the
38           cluster value of the parent cluster.
39         </p></li>
40 <li class="listitem"><p>
41           When a character is <span class="emphasis"><em>reordered</em></span>, the
42           reordered character and all clusters that the character
43           moves past as part of the reordering are merged into one cluster.
44         </p></li>
45 </ul></div>
46 <p>
47       The functionality, guarantees, and benefits of level 0 and level
48       1 behavior can be seen with some examples. First, let us examine
49       what happens with cluster values when shaping involves cluster
50       merging with ligatures and decomposition.
51     </p>
52 <p>
53       Let's say we start with the following character sequence (top row) and
54       initial cluster values (bottom row):
55     </p>
56 <pre class="programlisting">
57       A,B,C,D,E
58       0,1,2,3,4
59     </pre>
60 <p>
61       During shaping, HarfBuzz maps these characters to glyphs from
62       the font. For simplicity, let us assume that each character maps
63       to the corresponding, identical-looking glyph:
64     </p>
65 <pre class="programlisting">
66       A,B,C,D,E
67       0,1,2,3,4
68     </pre>
69 <p>
70       Now if, for example, <code class="literal">B</code> and <code class="literal">C</code>
71       form a ligature, then the clusters to which they belong
72       "merge". This merged cluster takes for its cluster
73       value the minimum of all the cluster values of the clusters that
74       went in to the ligature. In this case, we get:
75     </p>
76 <pre class="programlisting">
77       A,BC,D,E
78       0,1 ,3,4
79     </pre>
80 <p>
81       because 1 is the minimum of the set {1,2}, which were the
82       cluster values of <code class="literal">B</code> and
83       <code class="literal">C</code>. 
84     </p>
85 <p>
86       Next, let us say that the <code class="literal">BC</code> ligature glyph
87       decomposes into three components, and <code class="literal">D</code> also
88       decomposes into two components. Whenever a cluster decomposes,
89       its components each inherit the cluster value of their parent: 
90     </p>
91 <pre class="programlisting">
92       A,BC0,BC1,BC2,D0,D1,E
93       0,1  ,1  ,1  ,3 ,3 ,4
94     </pre>
95 <p>
96       Next, if <code class="literal">BC2</code> and <code class="literal">D0</code> form a
97       ligature, then their clusters (cluster values 1 and 3) merge into
98       <code class="literal">min(1,3) = 1</code>:
99     </p>
100 <pre class="programlisting">
101       A,BC0,BC1,BC2D0,D1,E
102       0,1  ,1  ,1    ,1 ,4
103     </pre>
104 <p>
105       Note that the entirety of cluster 3 merges into cluster 1, not
106       just the <code class="literal">D0</code> glyph. This reflects the fact
107       that the cluster <span class="emphasis"><em>must</em></span> be treated as an
108       indivisible unit.
109     </p>
110 <p>
111       At this point, cluster 1 means: the character sequence
112       <code class="literal">BCD</code> is represented by glyphs
113       <code class="literal">BC0,BC1,BC2D0,D1</code> and cannot be broken down any
114       further.
115     </p>
116 </div>
117 <div class="footer">
118 <hr>Generated by GTK-Doc V1.25</div>
119 </body>
120 </html>