-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuffers-language-script-and-direction.html
100 lines (100 loc) · 4.85 KB
/
buffers-language-script-and-direction.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Buffers, language, script and direction: HarfBuzz Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="HarfBuzz Manual">
<link rel="up" href="user-manual.html" title="Part I. User's manual">
<link rel="prev" href="object-model-blobs.html" title="Blobs">
<link rel="next" href="adding-text-to-the-buffer.html" title="Adding text to the buffer">
<meta name="generator" content="GTK-Doc V1.32 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="user-manual.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="object-model-blobs.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<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>
</tr></table>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="buffers-language-script-and-direction"></a>Buffers, language, script and direction</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="buffers-language-script-and-direction.html#creating-and-destroying-buffers">Creating and destroying buffers</a></span></dt>
<dt><span class="section"><a href="adding-text-to-the-buffer.html">Adding text to the buffer</a></span></dt>
<dt><span class="section"><a href="setting-buffer-properties.html">Setting buffer properties</a></span></dt>
<dt><span class="section"><a href="customizing-unicode-functions.html">Customizing Unicode functions</a></span></dt>
</dl></div>
<p>
The input to the HarfBuzz shaper is a series of Unicode characters, stored in a
buffer. In this chapter, we'll look at how to set up a buffer with
the text that we want and how to customize the properties of the
buffer. We'll also look at a piece of lower-level machinery that
you will need to understand before proceeding: the functions that
HarfBuzz uses to retrieve Unicode information.
</p>
<p>
After shaping is complete, HarfBuzz puts its output back
into the buffer. But getting that output requires setting up a
face and a font first, so we will look at that in the next chapter
instead of here.
</p>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="creating-and-destroying-buffers"></a>Creating and destroying buffers</h2></div></div></div>
<p>
As we saw in our <span class="emphasis"><em>Getting Started</em></span> example, a
buffer is created and
initialized with <code class="function">hb_buffer_create()</code>. This
produces a new, empty buffer object, instantiated with some
default values and ready to accept your Unicode strings.
</p>
<p>
HarfBuzz manages the memory of objects (such as buffers) that it
creates, so you don't have to. When you have finished working on
a buffer, you can call <code class="function">hb_buffer_destroy()</code>:
</p>
<pre class="programlisting">
hb_buffer_t *buf = hb_buffer_create();
...
hb_buffer_destroy(buf);
</pre>
<p>
This will destroy the object and free its associated memory -
unless some other part of the program holds a reference to this
buffer. If you acquire a HarfBuzz buffer from another subsystem
and want to ensure that it is not garbage collected by someone
else destroying it, you should increase its reference count:
</p>
<pre class="programlisting">
void somefunc(hb_buffer_t *buf) {
buf = hb_buffer_reference(buf);
...
</pre>
<p>
And then decrease it once you're done with it:
</p>
<pre class="programlisting">
hb_buffer_destroy(buf);
}
</pre>
<p>
While we are on the subject of reference-counting buffers, it is
worth noting that an individual buffer can only meaningfully be
used by one thread at a time.
</p>
<p>
To throw away all the data in your buffer and start from scratch,
call <code class="function">hb_buffer_reset(buf)</code>. If you want to
throw away the string in the buffer but keep the options, you can
instead call <code class="function">hb_buffer_clear_contents(buf)</code>.
</p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.32</div>
</body>
</html>