Functions
hb_buffer_create ()
hb_buffer_t *
hb_buffer_create (void
);
Creates a new hb_buffer_t with all properties to defaults.
[Xconstructor]
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_get_empty ()
hb_buffer_t *
hb_buffer_get_empty (void
);
Fetches an empty hb_buffer_t.
Returns
The empty buffer.
[transfer full]
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.
Returns
true
if buffer
memory allocation succeeded, false
otherwise
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.
Returns
true
if buffer
memory allocation succeeded, false
otherwise.
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.
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.
Since: 0.9.31
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.
Has nothing to do with non-Unicode Latin-1 encoding.
Since: 0.9.39
hb_buffer_append ()
void
hb_buffer_append (hb_buffer_t *buffer
,
hb_buffer_t *source
,
unsigned int start
,
unsigned int end
);
Append (part of) contents of another buffer to this buffer.
Since: 1.5.0
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 contain 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
);
Fetches the type of buffer
contents. Buffers are either empty, contain
characters (before shaping), or contain glyphs (the result of shaping).
Returns
The type of buffer
contents
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_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 BCP 47 language tags to
hb_language_t.
Since: 0.9.2
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.
Returns
true
if buffer
memory allocation succeeded, false
otherwise.
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.
Returns
The buffer
length.
The value valid as long as buffer has not been modified.
Since: 0.9.2
hb_buffer_set_unicode_funcs ()
void
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer
,
hb_unicode_funcs_t *unicode_funcs
);
Sets the Unicode-functions structure of a buffer to
unicode_funcs
.
Since: 0.9.2
hb_buffer_get_unicode_funcs ()
hb_unicode_funcs_t *
hb_buffer_get_unicode_funcs (hb_buffer_t *buffer
);
Fetches the Unicode-functions structure of a buffer.
Returns
The Unicode-functions structure
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
);
Fetches the user data associated with the specified key,
attached to the specified buffer.
[skip]
Returns
A pointer to the user data.
[transfer-none]
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_invisible_glyph ()
void
hb_buffer_set_invisible_glyph (hb_buffer_t *buffer
,
hb_codepoint_t invisible
);
Sets the hb_codepoint_t that replaces invisible characters in
the shaping result. If set to zero (default), the glyph for the
U+0020 SPACE character is used. Otherwise, this value is used
verbatim.
Since: 2.0.0
hb_buffer_get_replacement_codepoint ()
hb_codepoint_t
hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer
);
Fetches the hb_codepoint_t that replaces invalid entries for a given encoding
when adding text to buffer
.
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.
This has nothing to do with Unicode normalization.
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
and 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 ()
unsigned int
hb_buffer_serialize (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 content, whether
Unicode codepoints or glyph identifiers and positioning information. This is
useful for showing the contents of the buffer, for example during debugging.
See the documentation of hb_buffer_serialize_unicode()
and
hb_buffer_serialize_glyphs()
for a description of the output format.
Returns
The number of serialized items.
Since: 2.7.3
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]
json
A machine-readable, structured format.
The serialized glyphs will look something like:
[{"g":"uni0651","cl":0,"dx":518,"dy":0,"ax":0,"ay":0},
{"g":"uni0628","cl":0,"dx":0,"dy":0,"ax":1897,"ay":0}]
Each glyph is a JSON object, with the following properties:
g
: the glyph name or glyph index if
HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES flag is set.
cl
: hb_glyph_info_t.cluster if
HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS is not set.
dx
,dy
,ax
,ay
: hb_glyph_position_t.x_offset, hb_glyph_position_t.y_offset,
hb_glyph_position_t.x_advance and hb_glyph_position_t.y_advance
respectively, if HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS is not set.
xb
,yb
,w
,h
: hb_glyph_extents_t.x_bearing, hb_glyph_extents_t.y_bearing,
hb_glyph_extents_t.width and hb_glyph_extents_t.height respectively if
HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS is set.
Returns
The number of serialized items.
Since: 0.9.7
hb_buffer_serialize_unicode ()
unsigned int
hb_buffer_serialize_unicode (hb_buffer_t *buffer
,
unsigned int start
,
unsigned int end
,
char *buf
,
unsigned int buf_size
,
unsigned int *buf_consumed
,
hb_buffer_serialize_format_t format
,
hb_buffer_serialize_flags_t flags
);
Serializes buffer
into a textual representation of its content,
when the buffer contains Unicode codepoints (i.e., before shaping). This is
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 codepoints will look something like:
<U+0651=0|U+0628=1>
json
A machine-readable, structured format.
The serialized codepoints will be a list of objects with the following
properties:
For example:
[{u:1617,cl:0},{u:1576,cl:1}]
Returns
The number of serialized items.
Since: 2.7.3
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.
Returns
A NULL
terminated string corresponding to format
. Should not be freed.
[transfer none]
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.
Returns
A string array of buffer serialization formats. Should not be freed.
[transfer none]
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