Imported Upstream version 1.7.6
[platform/upstream/harfbuzz.git] / docs / html / the-distinction-between-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>The distinction between 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="">
9 <link rel="prev" href="reordering-in-levels-0-and-1.html" title="Reordering in levels 0 and 1">
10 <link rel="next" href="level-2.html" title="Level 2">
11 <meta name="generator" content="GTK-Doc V1.27.1 (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="reordering-in-levels-0-and-1.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="level-2.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
21 </tr></table>
22 <div class="sect1">
23 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
24 <a name="the-distinction-between-levels-0-and-1"></a>The distinction between levels 0 and 1</h2></div></div></div>
25 <p>
26     So, the above is pretty much what cluster levels 0 and 1 do. The
27     only difference between the two is this: in level 0, at the very
28     beginning of the shaping process, we also merge clusters between
29     base characters and all Unicode marks (combining or not) following
30     them. E.g.:
31   </p>
32 <pre class="programlisting">
33   A,acute,B
34   0,1    ,2
35 </pre>
36 <p>
37     will become:
38   </p>
39 <pre class="programlisting">
40   A,acute,B
41   0,0    ,2
42 </pre>
43 <p>
44     This is the default behavior. We do it because Windows did it and
45     old HarfBuzz did it, so this remained the default. But this behavior
46     makes it impossible to color diacritic marks differently from their
47     base characters. That's why in level 1 we do not perform this
48     initial merging step.
49   </p>
50 <p>
51     For clients, level 0 is more convenient if they rely on HarfBuzz
52     clusters for cursor positioning. But that's wrong anyway: cursor
53     positions should be determined based on Unicode grapheme boundaries,
54     NOT shaping clusters. As such, level 1 clusters are preferred.
55   </p>
56 <p>
57     One last note about levels 0 and 1. We currently don't allow a
58     <code class="literal">MultipleSubst</code> lookup to replace a glyph with zero
59     glyphs (i.e., to delete a glyph). But in some other situations,
60     glyphs can be deleted. In those cases, if the glyph being deleted is
61     the last glyph of its cluster, we make sure to merge the cluster
62     with a neighboring cluster.
63   </p>
64 <p>
65     This is, primarily, to make sure that the starting cluster of the
66     text always has the cluster index pointing to the start of the text
67     for the run; more than one client currently relies on this
68     guarantee.
69   </p>
70 <p>
71     Incidentally, Apple's CoreText does something else to maintain the
72     same promise: it inserts a glyph with id 65535 at the beginning of
73     the glyph string if the glyph corresponding to the first character
74     in the run was deleted. HarfBuzz might do something similar in the
75     future.
76   </p>
77 </div>
78 <div class="footer">
79 <hr>Generated by GTK-Doc V1.27.1</div>
80 </body>
81 </html>