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>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">
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>
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>
26 The basic shaping operations affect clusters in a predictable
27 manner when using level 0 or level 1:
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.
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.
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.
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.
53 Let's say we start with the following character sequence (top row) and
54 initial cluster values (bottom row):
56 <pre class="programlisting">
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:
65 <pre class="programlisting">
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:
76 <pre class="programlisting">
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>.
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:
91 <pre class="programlisting">
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>:
100 <pre class="programlisting">
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
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
118 <hr>Generated by GTK-Doc V1.25</div>