Top |
Functions
Types and Values
Object Hierarchy
GBoxed ├── hb_buffer_t ├── hb_glyph_info_t ├── hb_glyph_position_t ╰── hb_segment_properties_t GEnum ├── hb_buffer_cluster_level_t ├── hb_buffer_content_type_t ╰── hb_buffer_serialize_format_t GFlags ├── hb_buffer_flags_t ╰── hb_buffer_serialize_flags_t
Description
Buffers serve dual role in HarfBuzz; they hold the input characters that are
passed hb_shape()
, and after shaping they hold the output glyphs.
Functions
hb_buffer_create ()
hb_buffer_t *
hb_buffer_create (void
);
Creates a new hb_buffer_t with all properties to defaults.
[Xconstructor]
Returns
A newly allocated hb_buffer_t with a reference count of 1. The initial
reference count should be released with hb_buffer_destroy()
when you are done
using the hb_buffer_t. This function never returns NULL
. If memory cannot
be allocated, a special hb_buffer_t object will be returned on which
hb_buffer_allocation_successful()
returns false
.
[transfer full]
Since: 0.9.2
hb_buffer_reference ()
hb_buffer_t *
hb_buffer_reference (hb_buffer_t *buffer
);
Increases the reference count on buffer
by one. This prevents buffer
from
being destroyed until a matching call to hb_buffer_destroy()
is made.
[skip]
Since: 0.9.2
hb_buffer_destroy ()
void
hb_buffer_destroy (hb_buffer_t *buffer
);
Deallocate the buffer
.
Decreases the reference count on buffer
by one. If the result is zero, then
buffer
and all associated resources are freed. See hb_buffer_reference()
.
[skip]
Since: 0.9.2
hb_buffer_reset ()
void
hb_buffer_reset (hb_buffer_t *buffer
);
Resets the buffer to its initial status, as if it was just newly created
with hb_buffer_create()
.
Since: 0.9.2
hb_buffer_clear_contents ()
void
hb_buffer_clear_contents (hb_buffer_t *buffer
);
Similar to hb_buffer_reset()
, but does not clear the Unicode functions and
the replacement code point.
Since: 0.9.11
hb_buffer_pre_allocate ()
hb_bool_t hb_buffer_pre_allocate (hb_buffer_t *buffer
,unsigned int size
);
Pre allocates memory for buffer
to fit at least size
number of items.
Since: 0.9.2
hb_buffer_allocation_successful ()
hb_bool_t
hb_buffer_allocation_successful (hb_buffer_t *buffer
);
Check if allocating memory for the buffer succeeded.
Since: 0.9.2
hb_buffer_add ()
void hb_buffer_add (hb_buffer_t *buffer
,hb_codepoint_t codepoint
,unsigned int cluster
);
Appends a character with the Unicode value of codepoint
to buffer
, and
gives it the initial cluster value of cluster
. Clusters can be any thing
the client wants, they are usually used to refer to the index of the
character in the input text stream and are output in
hb_glyph_info_t.cluster field.
This function does not check the validity of codepoint
, it is up to the
caller to ensure it is a valid Unicode code point.
Parameters
buffer |
an hb_buffer_t. |
|
codepoint |
a Unicode code point. |
|
cluster |
the cluster value of |
Since: 0.9.7
hb_buffer_add_codepoints ()
void hb_buffer_add_codepoints (hb_buffer_t *buffer
,const hb_codepoint_t *text
,int text_length
,unsigned int item_offset
,int item_length
);
Appends characters from text
array to buffer
. The item_offset
is the
position of the first character from text
that will be appended, and
item_length
is the number of character. When shaping part of a larger text
(e.g. a run of text from a paragraph), instead of passing just the substring
corresponding to the run, it is preferable to pass the whole
paragraph and specify the run start and length as item_offset
and
item_length
, respectively, to give HarfBuzz the full context to be able,
for example, to do cross-run Arabic shaping or properly handle combining
marks at stat of run.
This function does not check the validity of text
, it is up to the caller
to ensure it contains a valid Unicode code points.
Parameters
buffer |
a hb_buffer_t to append characters to. |
|
text |
an array of Unicode code points to append. |
[array length=text_length] |
text_length |
the length of the |
|
item_offset |
the offset of the first code point to add to the |
|
item_length |
the number of code points to add to the |
Since: 0.9.31
hb_buffer_add_utf32 ()
void hb_buffer_add_utf32 (hb_buffer_t *buffer
,const uint32_t *text
,int text_length
,unsigned int item_offset
,int item_length
);
See hb_buffer_add_codepoints()
.
Replaces invalid UTF-32 characters with the buffer
replacement code point,
see hb_buffer_set_replacement_codepoint()
.
Parameters
buffer |
an hb_buffer_t. |
|
text |
an array of UTF-32 characters to append. |
[array length=text_length] |
text_length |
the length of the |
|
item_offset |
the offset of the first character to add to the |
|
item_length |
the number of characters to add to the |
Since: 0.9.2
hb_buffer_add_utf16 ()
void hb_buffer_add_utf16 (hb_buffer_t *buffer
,const uint16_t *text
,int text_length
,unsigned int item_offset
,int item_length
);
See hb_buffer_add_codepoints()
.
Replaces invalid UTF-16 characters with the buffer
replacement code point,
see hb_buffer_set_replacement_codepoint()
.
Parameters
buffer |
an hb_buffer_t. |
|
text |
an array of UTF-16 characters to append. |
[array length=text_length] |
text_length |
the length of the |
|
item_offset |
the offset of the first character to add to the |
|
item_length |
the number of characters to add to the |
Since: 0.9.2
hb_buffer_add_utf8 ()
void hb_buffer_add_utf8 (hb_buffer_t *buffer
,const char *text
,int text_length
,unsigned int item_offset
,int item_length
);
See hb_buffer_add_codepoints()
.
Replaces invalid UTF-8 characters with the buffer
replacement code point,
see hb_buffer_set_replacement_codepoint()
.
Parameters
buffer |
an hb_buffer_t. |
|
text |
an array of UTF-8 characters to append. |
[array length=text_length][element-type uint8_t] |
text_length |
the length of the |
|
item_offset |
the offset of the first character to add to the |
|
item_length |
the number of characters to add to the |
Since: 0.9.2
hb_buffer_add_latin1 ()
void hb_buffer_add_latin1 (hb_buffer_t *buffer
,const uint8_t *text
,int text_length
,unsigned int item_offset
,int item_length
);
Similar to hb_buffer_add_codepoints()
, but allows only access to first 256
Unicode code points that can fit in 8-bit strings.
Parameters
buffer |
an hb_buffer_t. |
|
text |
an array of UTF-8 characters to append. |
[array length=text_length][element-type uint8_t] |
text_length |
the length of the |
|
item_offset |
the offset of the first character to add to the |
|
item_length |
the number of characters to add to the |
Since: 0.9.39
hb_buffer_set_content_type ()
void hb_buffer_set_content_type (hb_buffer_t *buffer
,hb_buffer_content_type_t content_type
);
Sets the type of buffer
contents, buffers are either empty, contain
characters (before shaping) or glyphs (the result of shaping).
Since: 0.9.5
hb_buffer_get_content_type ()
hb_buffer_content_type_t
hb_buffer_get_content_type (hb_buffer_t *buffer
);
see hb_buffer_set_content_type()
.
Since: 0.9.5
hb_buffer_set_direction ()
void hb_buffer_set_direction (hb_buffer_t *buffer
,hb_direction_t direction
);
Set the text flow direction of the buffer. No shaping can happen without
setting buffer
direction, and it controls the visual direction for the
output glyphs; for RTL direction the glyphs will be reversed. Many layout
features depend on the proper setting of the direction, for example,
reversing RTL text before shaping, then shaping with LTR direction is not
the same as keeping the text in logical order and shaping with RTL
direction.
Since: 0.9.2
hb_buffer_get_direction ()
hb_direction_t
hb_buffer_get_direction (hb_buffer_t *buffer
);
Since: 0.9.2
hb_buffer_set_script ()
void hb_buffer_set_script (hb_buffer_t *buffer
,hb_script_t script
);
Sets the script of buffer
to script
.
Script is crucial for choosing the proper shaping behaviour for scripts that require it (e.g. Arabic) and the which OpenType features defined in the font to be applied.
You can pass one of the predefined hb_script_t values, or use
hb_script_from_string()
or hb_script_from_iso15924_tag()
to get the
corresponding script from an ISO 15924 script tag.
Since: 0.9.2
hb_buffer_set_language ()
void hb_buffer_set_language (hb_buffer_t *buffer
,hb_language_t language
);
Sets the language of buffer
to language
.
Languages are crucial for selecting which OpenType feature to apply to the buffer which can result in applying language-specific behaviour. Languages are orthogonal to the scripts, and though they are related, they are different concepts and should not be confused with each other.
Use hb_language_from_string()
to convert from ISO 639 language codes to
hb_language_t.
Since: 0.9.2
hb_buffer_set_flags ()
void hb_buffer_set_flags (hb_buffer_t *buffer
,hb_buffer_flags_t flags
);
Sets buffer
flags to flags
. See hb_buffer_flags_t.
Since: 0.9.7
hb_buffer_set_cluster_level ()
void hb_buffer_set_cluster_level (hb_buffer_t *buffer
,hb_buffer_cluster_level_t cluster_level
);
Since: 0.9.42
hb_buffer_get_cluster_level ()
hb_buffer_cluster_level_t
hb_buffer_get_cluster_level (hb_buffer_t *buffer
);
Since: 0.9.42
hb_buffer_set_length ()
hb_bool_t hb_buffer_set_length (hb_buffer_t *buffer
,unsigned int length
);
Similar to hb_buffer_pre_allocate()
, but clears any new items added at the
end.
Since: 0.9.2
hb_buffer_get_length ()
unsigned int
hb_buffer_get_length (hb_buffer_t *buffer
);
Returns the number of items in the buffer.
Since: 0.9.2
hb_buffer_set_segment_properties ()
void hb_buffer_set_segment_properties (hb_buffer_t *buffer
,const hb_segment_properties_t *props
);
Sets the segment properties of the buffer, a shortcut for calling
hb_buffer_set_direction()
, hb_buffer_set_script()
and
hb_buffer_set_language()
individually.
Since: 0.9.7
hb_buffer_get_segment_properties ()
void hb_buffer_get_segment_properties (hb_buffer_t *buffer
,hb_segment_properties_t *props
);
Sets props
to the hb_segment_properties_t of buffer
.
Since: 0.9.7
hb_buffer_guess_segment_properties ()
void
hb_buffer_guess_segment_properties (hb_buffer_t *buffer
);
Sets unset buffer segment properties based on buffer Unicode
contents. If buffer is not empty, it must have content type
HB_BUFFER_CONTENT_TYPE_UNICODE
.
If buffer script is not set (ie. is HB_SCRIPT_INVALID
), it
will be set to the Unicode script of the first character in
the buffer that has a script other than HB_SCRIPT_COMMON
,
HB_SCRIPT_INHERITED
, and HB_SCRIPT_UNKNOWN
.
Next, if buffer direction is not set (ie. is HB_DIRECTION_INVALID
),
it will be set to the natural horizontal direction of the
buffer script as returned by hb_script_get_horizontal_direction()
.
Finally, if buffer language is not set (ie. is HB_LANGUAGE_INVALID
),
it will be set to the process's default language as returned by
hb_language_get_default()
. This may change in the future by
taking buffer script into consideration when choosing a language.
Since: 0.9.7
hb_buffer_set_unicode_funcs ()
void hb_buffer_set_unicode_funcs (hb_buffer_t *buffer
,hb_unicode_funcs_t *unicode_funcs
);
Since: 0.9.2
hb_buffer_get_unicode_funcs ()
hb_unicode_funcs_t *
hb_buffer_get_unicode_funcs (hb_buffer_t *buffer
);
Since: 0.9.2
hb_buffer_set_user_data ()
hb_bool_t hb_buffer_set_user_data (hb_buffer_t *buffer
,hb_user_data_key_t *key
,void *data
,hb_destroy_func_t destroy
,hb_bool_t replace
);
[skip]
Since: 0.9.2
hb_buffer_get_user_data ()
void * hb_buffer_get_user_data (hb_buffer_t *buffer
,hb_user_data_key_t *key
);
[skip]
Since: 0.9.2
hb_buffer_get_glyph_infos ()
hb_glyph_info_t * hb_buffer_get_glyph_infos (hb_buffer_t *buffer
,unsigned int *length
);
Returns buffer
glyph information array. Returned pointer
is valid as long as buffer
contents are not modified.
Returns
The buffer
glyph information array.
The value valid as long as buffer has not been modified.
[transfer none][array length=length]
Since: 0.9.2
hb_buffer_get_glyph_positions ()
hb_glyph_position_t * hb_buffer_get_glyph_positions (hb_buffer_t *buffer
,unsigned int *length
);
Returns buffer
glyph position array. Returned pointer
is valid as long as buffer
contents are not modified.
Returns
The buffer
glyph position array.
The value valid as long as buffer has not been modified.
[transfer none][array length=length]
Since: 0.9.2
hb_buffer_set_replacement_codepoint ()
void hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer
,hb_codepoint_t replacement
);
Sets the hb_codepoint_t that replaces invalid entries for a given encoding
when adding text to buffer
.
Default is HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT
.
Since: 0.9.31
hb_buffer_get_replacement_codepoint ()
hb_codepoint_t
hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer
);
See hb_buffer_set_replacement_codepoint()
.
Since: 0.9.31
hb_buffer_normalize_glyphs ()
void
hb_buffer_normalize_glyphs (hb_buffer_t *buffer
);
Reorders a glyph buffer to have canonical in-cluster glyph order / position. The resulting clusters should behave identical to pre-reordering clusters.
Since: 0.9.2
hb_buffer_reverse ()
void
hb_buffer_reverse (hb_buffer_t *buffer
);
Reverses buffer contents.
Since: 0.9.2
hb_buffer_reverse_range ()
void hb_buffer_reverse_range (hb_buffer_t *buffer
,unsigned int start
,unsigned int end
);
Reverses buffer contents between start to end.
Since: 0.9.41
hb_buffer_reverse_clusters ()
void
hb_buffer_reverse_clusters (hb_buffer_t *buffer
);
Reverses buffer clusters. That is, the buffer contents are reversed, then each cluster (consecutive items having the same cluster number) are reversed again.
Since: 0.9.2
hb_buffer_serialize_glyphs ()
unsigned int hb_buffer_serialize_glyphs (hb_buffer_t *buffer
,unsigned int start
,unsigned int end
,char *buf
,unsigned int buf_size
,unsigned int *buf_consumed
,hb_font_t *font
,hb_buffer_serialize_format_t format
,hb_buffer_serialize_flags_t flags
);
Serializes buffer
into a textual representation of its glyph content,
useful for showing the contents of the buffer, for example during debugging.
There are currently two supported serialization formats:
text
A human-readable, plain text format. The serialized glyphs will look something like:
[uni0651=0@518,0+0|uni0628=0+1897]
The serialized glyphs are delimited with
[
and]
.Glyphs are separated with
|
-
Each glyph starts with glyph name, or glyph index if HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES flag is set. Then,
If HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set,
=
then hb_glyph_info_t.cluster.-
If HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS is not set, the hb_glyph_position_t in the format:
If both hb_glyph_position_t.x_offset and hb_glyph_position_t.y_offset are not 0,
@x_offset,y_offset
. Then,+x_advance
, then,y_advance
if hb_glyph_position_t.y_advance is not 0. Then,
If HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS is set, the hb_glyph_extents_t in the format
<x_bearing,y_bearing,width,height>
Parameters
buffer |
an hb_buffer_t buffer. |
|
start |
the first item in |
|
end |
the last item in |
|
buf |
output string to write serialized buffer into. |
[out][array length=buf_size][element-type uint8_t] |
buf_size |
the size of |
|
buf_consumed |
if not |
[out][allow-none] |
font |
the hb_font_t used to shape this buffer, needed to
read glyph names and extents. If |
[allow-none] |
format |
the hb_buffer_serialize_format_t to use for formatting the output. |
|
flags |
the hb_buffer_serialize_flags_t that control what glyph properties to serialize. |
Since: 0.9.7
hb_buffer_deserialize_glyphs ()
hb_bool_t hb_buffer_deserialize_glyphs (hb_buffer_t *buffer
,const char *buf
,int buf_len
,const char **end_ptr
,hb_font_t *font
,hb_buffer_serialize_format_t format
);
Since: 0.9.7
hb_buffer_serialize_format_from_string ()
hb_buffer_serialize_format_t hb_buffer_serialize_format_from_string (const char *str
,int len
);
Parses a string into an hb_buffer_serialize_format_t. Does not check if
str
is a valid buffer serialization format, use
hb_buffer_serialize_list_formats()
to get the list of supported formats.
Parameters
str |
a string to parse. |
[array length=len][element-type uint8_t] |
len |
length of |
Since: 0.9.7
hb_buffer_serialize_format_to_string ()
const char *
hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format
);
Converts format
to the string corresponding it, or NULL
if it is not a valid
hb_buffer_serialize_format_t.
Since: 0.9.7
hb_buffer_serialize_list_formats ()
const char **
hb_buffer_serialize_list_formats (void
);
Returns a list of supported buffer serialization formats.
Since: 0.9.7
hb_segment_properties_equal ()
hb_bool_t hb_segment_properties_equal (const hb_segment_properties_t *a
,const hb_segment_properties_t *b
);
Checks the equality of two hb_segment_properties_t's.
Since: 0.9.7
hb_segment_properties_hash ()
unsigned int
hb_segment_properties_hash (const hb_segment_properties_t *p
);
Creates a hash representing p
.
Since: 0.9.7
hb_buffer_set_message_func ()
void hb_buffer_set_message_func (hb_buffer_t *buffer
,hb_buffer_message_func_t func
,void *user_data
,hb_destroy_func_t destroy
);
Since: 1.1.3
hb_buffer_message_func_t ()
hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer
,hb_font_t *font
,const char *message
,void *user_data
);
Types and Values
HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT
#define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu
The default code point for replacing invalid characters in a given encoding. Set to U+FFFD REPLACEMENT CHARACTER.
Since: 0.9.31
hb_buffer_t
typedef struct hb_buffer_t hb_buffer_t;
The main structure holding the input text and its properties before shaping, and output glyphs and their information after shaping.
hb_glyph_info_t
typedef struct { hb_codepoint_t codepoint; hb_mask_t mask; uint32_t cluster; } hb_glyph_info_t;
The hb_glyph_info_t is the structure that holds information about the glyphs and their relation to input text.
Members
hb_codepoint_t |
either a Unicode code point (before shaping) or a glyph index (after shaping). |
|
hb_mask_t |
||
the index of the character in the original text that corresponds
to this hb_glyph_info_t, or whatever the client passes to
|
hb_glyph_position_t
typedef struct { hb_position_t x_advance; hb_position_t y_advance; hb_position_t x_offset; hb_position_t y_offset; } hb_glyph_position_t;
The hb_glyph_position_t is the structure that holds the positions of the glyph in both horizontal and vertical directions. All positions in hb_glyph_position_t are relative to the current point.
Members
hb_position_t |
how much the line advances after drawing this glyph when setting text in horizontal direction. |
|
hb_position_t |
how much the line advances after drawing this glyph when setting text in vertical direction. |
|
hb_position_t |
how much the glyph moves on the X-axis before drawing it, this should not affect how much the line advances. |
|
hb_position_t |
how much the glyph moves on the Y-axis before drawing it, this should not affect how much the line advances. |
enum hb_buffer_flags_t
Members
the default buffer flag. |
||
flag indicating that special handling of the beginning of text paragraph can be applied to this buffer. Should usually be set, unless you are passing to the buffer only part of the text without the full context. |
||
flag indicating that special handling of the end of text
paragraph can be applied to this buffer, similar to
|
||
flag indication that character with Default_Ignorable Unicode property should use the corresponding glyph from the font, instead of hiding them (currently done by replacing them with the space glyph and zeroing the advance width.) |
Since: 0.9.20
hb_segment_properties_t
typedef struct { hb_direction_t direction; hb_script_t script; hb_language_t language; } hb_segment_properties_t;
The structure that holds various text properties of an hb_buffer_t. Can be
set and retrieved using hb_buffer_set_segment_properties()
and
hb_buffer_get_segment_properties()
, respectively.
Members
hb_direction_t |
the hb_direction_t of the buffer, see |
|
hb_script_t |
the hb_script_t of the buffer, see |
|
hb_language_t |
the hb_language_t of the buffer, see |
enum hb_buffer_serialize_format_t
The buffer serialization and de-serialization format used in
hb_buffer_serialize_glyphs()
and hb_buffer_deserialize_glyphs()
.
Since: 0.9.2
enum hb_buffer_serialize_flags_t
Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs()
.
Members
serialize glyph names, clusters and positions. |
||
do not serialize glyph cluster. |
||
do not serialize glyph position information. |
||
do no serialize glyph name. |
||
serialize glyph extents. |
Since: 0.9.20