2018-10-29 22:10:53 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
|
|
|
|
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
|
|
|
|
<!ENTITY version SYSTEM "version.xml">
|
|
|
|
]>
|
2015-08-31 09:39:10 +00:00
|
|
|
<chapter id="buffers-language-script-and-direction">
|
2015-08-29 07:21:18 +00:00
|
|
|
<title>Buffers, language, script and direction</title>
|
|
|
|
<para>
|
2017-11-20 23:07:48 +00:00
|
|
|
The input to HarfBuzz is a series of Unicode characters, stored in a
|
2015-08-29 07:21:18 +00:00
|
|
|
buffer. In this chapter, we'll look at how to set up a buffer with
|
|
|
|
the text that we want and then customize the properties of the
|
|
|
|
buffer.
|
|
|
|
</para>
|
2015-08-31 09:39:10 +00:00
|
|
|
<section id="creating-and-destroying-buffers">
|
2015-08-29 07:21:18 +00:00
|
|
|
<title>Creating and destroying buffers</title>
|
|
|
|
<para>
|
|
|
|
As we saw in our initial example, a buffer is created and
|
|
|
|
initialized with <literal>hb_buffer_create()</literal>. This
|
|
|
|
produces a new, empty buffer object, instantiated with some
|
|
|
|
default values and ready to accept your Unicode strings.
|
|
|
|
</para>
|
|
|
|
<para>
|
2017-11-20 23:07:48 +00:00
|
|
|
HarfBuzz manages the memory of objects that it creates (such as
|
2015-08-29 07:21:18 +00:00
|
|
|
buffers), so you don't have to. When you have finished working on
|
|
|
|
a buffer, you can call <literal>hb_buffer_destroy()</literal>:
|
|
|
|
</para>
|
|
|
|
<programlisting language="C">
|
|
|
|
hb_buffer_t *buffer = hb_buffer_create();
|
|
|
|
...
|
|
|
|
hb_buffer_destroy(buffer);
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
|
|
|
This will destroy the object and free its associated memory -
|
|
|
|
unless some other part of the program holds a reference to this
|
2017-11-20 23:07:48 +00:00
|
|
|
buffer. If you acquire a HarfBuzz buffer from another subsystem
|
2015-08-29 07:21:18 +00:00
|
|
|
and want to ensure that it is not garbage collected by someone
|
|
|
|
else destroying it, you should increase its reference count:
|
|
|
|
</para>
|
|
|
|
<programlisting language="C">
|
|
|
|
void somefunc(hb_buffer_t *buffer) {
|
|
|
|
buffer = hb_buffer_reference(buffer);
|
|
|
|
...
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
|
|
|
And then decrease it once you're done with it:
|
|
|
|
</para>
|
|
|
|
<programlisting language="C">
|
|
|
|
hb_buffer_destroy(buffer);
|
|
|
|
}
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
|
|
|
To throw away all the data in your buffer and start from scratch,
|
|
|
|
call <literal>hb_buffer_reset(buffer)</literal>. If you want to
|
|
|
|
throw away the string in the buffer but keep the options, you can
|
|
|
|
instead call <literal>hb_buffer_clear_contents(buffer)</literal>.
|
|
|
|
</para>
|
2015-08-31 09:39:10 +00:00
|
|
|
</section>
|
|
|
|
<section id="adding-text-to-the-buffer">
|
2015-08-29 07:21:18 +00:00
|
|
|
<title>Adding text to the buffer</title>
|
|
|
|
<para>
|
2017-11-20 23:07:48 +00:00
|
|
|
Now we have a brand new HarfBuzz buffer. Let's start filling it
|
|
|
|
with text! From HarfBuzz's perspective, a buffer is just a stream
|
2015-08-29 07:21:18 +00:00
|
|
|
of Unicode codepoints, but your input string is probably in one of
|
2015-08-31 09:12:05 +00:00
|
|
|
the standard Unicode character encodings (UTF-8, UTF-16, UTF-32)
|
2015-08-29 07:21:18 +00:00
|
|
|
</para>
|
2015-08-31 09:39:10 +00:00
|
|
|
</section>
|
|
|
|
<section id="setting-buffer-properties">
|
2015-08-29 07:21:18 +00:00
|
|
|
<title>Setting buffer properties</title>
|
|
|
|
<para>
|
|
|
|
</para>
|
2015-08-31 09:39:10 +00:00
|
|
|
</section>
|
|
|
|
<section id="what-about-the-other-scripts">
|
2015-08-29 07:21:18 +00:00
|
|
|
<title>What about the other scripts?</title>
|
|
|
|
<para>
|
|
|
|
</para>
|
2015-08-31 09:39:10 +00:00
|
|
|
</section>
|
|
|
|
<section id="customizing-unicode-functions">
|
2015-08-29 07:21:18 +00:00
|
|
|
<title>Customizing Unicode functions</title>
|
|
|
|
<para>
|
|
|
|
</para>
|
2015-08-31 09:39:10 +00:00
|
|
|
</section>
|
2018-10-29 22:10:53 +00:00
|
|
|
</chapter>
|