77ed5f3e2ee23b865d51fd526e0faa7c12395a1b
[platform/upstream/harfbuzz.git] / docs / html / buffers-language-script-and-direction.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>HarfBuzz Manual: Buffers, language, script and direction</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="hello-harfbuzz.html" title="Hello, Harfbuzz">
10 <link rel="next" href="adding-text-to-the-buffer.html" title="Adding text to the buffer">
11 <meta name="generator" content="GTK-Doc V1.20 (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="10"><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="hello-harfbuzz.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="adding-text-to-the-buffer.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="buffers-language-script-and-direction"></a>Buffers, language, script and direction</h2></div></div></div>
25 <div class="toc"><dl class="toc">
26 <dt><span class="section"><a href="buffers-language-script-and-direction.html#creating-and-destroying-buffers">Creating and destroying buffers</a></span></dt>
27 <dt><span class="section"><a href="adding-text-to-the-buffer.html">Adding text to the buffer</a></span></dt>
28 <dt><span class="section"><a href="setting-buffer-properties.html">Setting buffer properties</a></span></dt>
29 <dt><span class="section"><a href="what-about-the-other-scripts.html">What about the other scripts?</a></span></dt>
30 <dt><span class="section"><a href="customizing-unicode-functions.html">Customizing Unicode functions</a></span></dt>
31 </dl></div>
32 <p>
33     The input to Harfbuzz is a series of Unicode characters, stored in a
34     buffer. In this chapter, we'll look at how to set up a buffer with
35     the text that we want and then customize the properties of the
36     buffer.
37   </p>
38 <div class="section">
39 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
40 <a name="creating-and-destroying-buffers"></a>Creating and destroying buffers</h2></div></div></div>
41 <p>
42       As we saw in our initial example, a buffer is created and
43       initialized with <code class="literal">hb_buffer_create()</code>. This
44       produces a new, empty buffer object, instantiated with some
45       default values and ready to accept your Unicode strings.
46     </p>
47 <p>
48       Harfbuzz manages the memory of objects that it creates (such as
49       buffers), so you don't have to. When you have finished working on
50       a buffer, you can call <code class="literal">hb_buffer_destroy()</code>:
51     </p>
52 <pre class="programlisting">
53   hb_buffer_t *buffer = hb_buffer_create();
54   ...
55   hb_buffer_destroy(buffer);
56 </pre>
57 <p>
58       This will destroy the object and free its associated memory -
59       unless some other part of the program holds a reference to this
60       buffer. If you acquire a Harfbuzz buffer from another subsystem
61       and want to ensure that it is not garbage collected by someone
62       else destroying it, you should increase its reference count:
63     </p>
64 <pre class="programlisting">
65 void somefunc(hb_buffer_t *buffer) {
66   buffer = hb_buffer_reference(buffer);
67   ...
68 </pre>
69 <p>
70       And then decrease it once you're done with it:
71     </p>
72 <pre class="programlisting">
73   hb_buffer_destroy(buffer);
74 }
75 </pre>
76 <p>
77       To throw away all the data in your buffer and start from scratch,
78       call <code class="literal">hb_buffer_reset(buffer)</code>. If you want to
79       throw away the string in the buffer but keep the options, you can
80       instead call <code class="literal">hb_buffer_clear_contents(buffer)</code>.
81     </p>
82 </div>
83 </div>
84 <div class="footer">
85 <hr>
86           Generated by GTK-Doc V1.20</div>
87 </body>
88 </html>