Imported Upstream version 2.3.1
[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>Buffers, language, script and direction: 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="pt01.html" title="Part I. User's manual">
9 <link rel="prev" href="aat-shaping.html" title="AAT shaping">
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.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="pt01.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
19 <td><a accesskey="p" href="aat-shaping.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 <span class="emphasis"><em>Getting Started</em></span> example, a
43       buffer is created and 
44       initialized with <code class="literal">hb_buffer_create()</code>. This
45       produces a new, empty buffer object, instantiated with some
46       default values and ready to accept your Unicode strings.
47     </p>
48 <p>
49       HarfBuzz manages the memory of objects (such as buffers) that it
50       creates, so you don't have to. When you have finished working on 
51       a buffer, you can call <code class="literal">hb_buffer_destroy()</code>:
52     </p>
53 <pre class="programlisting">
54   hb_buffer_t *buffer = hb_buffer_create();
55   ...
56   hb_buffer_destroy(buffer);
57 </pre>
58 <p>
59       This will destroy the object and free its associated memory -
60       unless some other part of the program holds a reference to this
61       buffer. If you acquire a HarfBuzz buffer from another subsystem
62       and want to ensure that it is not garbage collected by someone
63       else destroying it, you should increase its reference count:
64     </p>
65 <pre class="programlisting">
66 void somefunc(hb_buffer_t *buffer) {
67   buffer = hb_buffer_reference(buffer);
68   ...
69 </pre>
70 <p>
71       And then decrease it once you're done with it:
72     </p>
73 <pre class="programlisting">
74   hb_buffer_destroy(buffer);
75 }
76 </pre>
77 <p>
78       To throw away all the data in your buffer and start from scratch,
79       call <code class="literal">hb_buffer_reset(buffer)</code>. If you want to
80       throw away the string in the buffer but keep the options, you can
81       instead call <code class="literal">hb_buffer_clear_contents(buffer)</code>.
82     </p>
83 </div>
84 </div>
85 <div class="footer">
86 <hr>Generated by GTK-Doc V1.25</div>
87 </body>
88 </html>