|
Packit |
874993 |
|
|
Packit |
874993 |
<html>
|
|
Packit |
874993 |
<head>
|
|
Packit |
874993 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
Packit |
874993 |
<title>Buffers, language, script and direction: HarfBuzz Manual</title>
|
|
Packit |
874993 |
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
Packit |
874993 |
<link rel="home" href="index.html" title="HarfBuzz Manual">
|
|
Packit |
874993 |
<link rel="up" href="pt01.html" title="Part I. User's manual">
|
|
Packit |
874993 |
<link rel="prev" href="hello-harfbuzz.html" title="Hello, Harfbuzz">
|
|
Packit |
874993 |
<link rel="next" href="adding-text-to-the-buffer.html" title="Adding text to the buffer">
|
|
Packit |
874993 |
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
|
|
Packit |
874993 |
<link rel="stylesheet" href="style.css" type="text/css">
|
|
Packit |
874993 |
</head>
|
|
Packit |
874993 |
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Buffers, language, script and direction
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Creating and destroying buffers
|
|
Packit |
874993 |
Adding text to the buffer
|
|
Packit |
874993 |
Setting buffer properties
|
|
Packit |
874993 |
What about the other scripts?
|
|
Packit |
874993 |
Customizing Unicode functions
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
The input to Harfbuzz is a series of Unicode characters, stored in a
|
|
Packit |
874993 |
buffer. In this chapter, we'll look at how to set up a buffer with
|
|
Packit |
874993 |
the text that we want and then customize the properties of the
|
|
Packit |
874993 |
buffer.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Creating and destroying buffers
|
|
Packit |
874993 |
|
|
Packit |
874993 |
As we saw in our initial example, a buffer is created and
|
|
Packit |
874993 |
initialized with hb_buffer_create() . This
|
|
Packit |
874993 |
produces a new, empty buffer object, instantiated with some
|
|
Packit |
874993 |
default values and ready to accept your Unicode strings.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Harfbuzz manages the memory of objects that it creates (such as
|
|
Packit |
874993 |
buffers), so you don't have to. When you have finished working on
|
|
Packit |
874993 |
a buffer, you can call hb_buffer_destroy() :
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
hb_buffer_t *buffer = hb_buffer_create();
|
|
Packit |
874993 |
...
|
|
Packit |
874993 |
hb_buffer_destroy(buffer);
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
This will destroy the object and free its associated memory -
|
|
Packit |
874993 |
unless some other part of the program holds a reference to this
|
|
Packit |
874993 |
buffer. If you acquire a Harfbuzz buffer from another subsystem
|
|
Packit |
874993 |
and want to ensure that it is not garbage collected by someone
|
|
Packit |
874993 |
else destroying it, you should increase its reference count:
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
void somefunc(hb_buffer_t *buffer) {
|
|
Packit |
874993 |
buffer = hb_buffer_reference(buffer);
|
|
Packit |
874993 |
...
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
And then decrease it once you're done with it:
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
hb_buffer_destroy(buffer);
|
|
Packit |
874993 |
}
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
To throw away all the data in your buffer and start from scratch,
|
|
Packit |
874993 |
call hb_buffer_reset(buffer) . If you want to
|
|
Packit |
874993 |
throw away the string in the buffer but keep the options, you can
|
|
Packit |
874993 |
instead call hb_buffer_clear_contents(buffer) .
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Generated by GTK-Doc V1.25.1
|
|
Packit |
874993 |
</body>
|
|
Packit |
874993 |
</html>
|