d791d4705bb223cba527b7f171f01f50518d05f2
[platform/upstream/harfbuzz.git] / docs / html / what-is-harfbuzz.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>What is Harfbuzz?: HarfBuzz Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
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="pt01.html" title="Part I. User's manual">
10 <link rel="next" href="why-is-it-called-harfbuzz.html" title="Why is it called Harfbuzz?">
11 <meta name="generator" content="GTK-Doc V1.24.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="pt01.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
19 <td><a accesskey="p" href="pt01.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="why-is-it-called-harfbuzz.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
21 </tr></table>
22 <div class="chapter">
23 <div class="titlepage"><div><div><h2 class="title">
24 <a name="what-is-harfbuzz"></a>What is Harfbuzz?</h2></div></div></div>
25 <div class="toc"><dl class="toc">
26 <dt><span class="section"><a href="what-is-harfbuzz.html#why-do-i-need-it">Why do I need it?</a></span></dt>
27 <dt><span class="section"><a href="why-is-it-called-harfbuzz.html">Why is it called Harfbuzz?</a></span></dt>
28 </dl></div>
29 <p>
30     Harfbuzz is a <span class="emphasis"><em>text shaping engine</em></span>. It solves
31     the problem of selecting and positioning glyphs from a font given a
32     Unicode string.
33   </p>
34 <div class="section">
35 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
36 <a name="why-do-i-need-it"></a>Why do I need it?</h2></div></div></div>
37 <p>
38       Text shaping is an integral part of preparing text for display. It
39       is a fairly low level operation; Harfbuzz is used directly by
40       graphic rendering libraries such as Pango, and the layout engines
41       in Firefox, LibreOffice and Chromium. Unless you are
42       <span class="emphasis"><em>writing</em></span> one of these layout engines yourself,
43       you will probably not need to use Harfbuzz - normally higher level
44       libraries will turn text into glyphs for you.
45     </p>
46 <p>
47       However, if you <span class="emphasis"><em>are</em></span> writing a layout engine
48       or graphics library yourself, you will need to perform text
49       shaping, and this is where Harfbuzz can help you. Here are some
50       reasons why you need it:
51     </p>
52 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
53 <li class="listitem"><p>
54           OpenType fonts contain a set of glyphs, indexed by glyph ID.
55           The glyph ID within the font does not necessarily relate to a
56           Unicode codepoint. For instance, some fonts have the letter
57           "a" as glyph ID 1. To pull the right glyph out of
58           the font in order to display it, you need to consult a table
59           within the font (the "cmap" table) which maps
60           Unicode codepoints to glyph IDs. Text shaping turns codepoints
61           into glyph IDs.
62         </p></li>
63 <li class="listitem"><p>
64           Many OpenType fonts contain ligatures: combinations of
65           characters which are rendered together. For instance, it's
66           common for the <code class="literal">fi</code> combination to appear in
67           print as the single ligature "fi". Whether you should
68           render text as <code class="literal">fi</code> or "fi" does not
69           depend on the input text, but on the capabilities of the font
70           and the level of ligature application you wish to perform.
71           Text shaping involves querying the font's ligature tables and
72           determining what substitutions should be made.
73         </p></li>
74 <li class="listitem"><p>
75           While ligatures like "fi" are typographic
76           refinements, some languages <span class="emphasis"><em>require</em></span> such
77           substitutions to be made in order to display text correctly.
78           In Tamil, when the letter "TTA" (ட) letter is
79           followed by "U" (உ), the combination should appear
80           as the single glyph "டு". The sequence of Unicode
81           characters "டஉ" needs to be rendered as a single
82           glyph from the font - text shaping chooses the correct glyph
83           from the sequence of characters provided.
84         </p></li>
85 <li class="listitem"><p>
86           Similarly, each Arabic character has four different variants:
87           within a font, there will be glyphs for the initial, medial,
88           final, and isolated forms of each letter. Unicode only encodes
89           one codepoint per character, and so a Unicode string will not
90           tell you which glyph to use. Text shaping chooses the correct
91           form of the letter and returns the correct glyph from the font
92           that you need to render.
93         </p></li>
94 <li class="listitem"><p>
95           Other languages have marks and accents which need to be
96           rendered in certain positions around a base character. For
97           instance, the Moldovan language has the Cyrillic letter
98           "zhe" (ж) with a breve accent, like so: ӂ. Some
99           fonts will contain this character as an individual glyph,
100           whereas other fonts will not contain a zhe-with-breve glyph
101           but expect the rendering engine to form the character by
102           overlaying the two glyphs ж and ˘. Where you should draw the
103           combining breve depends on the height of the preceding glyph.
104           Again, for Arabic, the correct positioning of vowel marks
105           depends on the height of the character on which you are
106           placing the mark. Text shaping tells you whether you have a
107           precomposed glyph within your font or if you need to compose a
108           glyph yourself out of combining marks, and if so, where to
109           position those marks.
110         </p></li>
111 </ul></div>
112 <p>
113       If this is something that you need to do, then you need a text
114       shaping engine: you could use Uniscribe if you are using Windows;
115       you could use CoreText on OS X; or you could use Harfbuzz. In the
116       rest of this manual, we are going to assume that you are the
117       implementor of a text layout engine.
118     </p>
119 </div>
120 </div>
121 <div class="footer">
122 <hr>Generated by GTK-Doc V1.24.1</div>
123 </body>
124 </html>