Functions#
- aat_layout_feature_type_get_name_id(face: face_t, feature_type: aat_layout_feature_type_t) int#
Fetches the name identifier of the specified feature type in the face’s
nametable.Added in version 2.2.0.
- Parameters:
face –
face_tto work uponfeature_type – The
aat_layout_feature_type_tof the requested feature type
- Returns:
Name identifier of the requested feature type
- aat_layout_feature_type_get_selector_infos(face: face_t, feature_type: aat_layout_feature_type_t, start_offset: int) tuple[int, list[aat_layout_feature_selector_info_t], int]#
Fetches a list of the selectors available for the specified feature in the given face.
If upon return,
default_indexis set toHB_AAT_LAYOUT_NO_SELECTOR_INDEX, then the feature type is non-exclusive. Otherwise,default_indexis the index of the selector that is selected by default.Added in version 2.2.0.
- Parameters:
face –
face_tto work uponfeature_type – The
aat_layout_feature_type_tof the requested feature typestart_offset – offset of the first feature type to retrieve
- Returns:
Number of all available feature selectors
- aat_layout_get_feature_types(face: face_t, start_offset: int) tuple[int, list[aat_layout_feature_type_t]]#
Fetches a list of the AAT feature types included in the specified face.
Added in version 2.2.0.
- Parameters:
face –
face_tto work uponstart_offset – offset of the first feature type to retrieve
- Returns:
Number of all available feature types.
- aat_layout_has_positioning(face: face_t) int#
Tests whether the specified face includes any positioning information in the
kerxtable.<note>Note: does not examine the
GPOStable.</note>Added in version 2.3.0.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- aat_layout_has_substitution(face: face_t) int#
Tests whether the specified face includes any substitutions in the
morxormorttables.<note>Note: does not examine the
GSUBtable.</note>Added in version 2.3.0.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- aat_layout_has_tracking(face: face_t) int#
Tests whether the specified face includes any tracking information in the
traktable.Added in version 2.3.0.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- blob_create_from_file(file_name: str) blob_t#
Creates a new blob containing the data from the specified binary font file.
The filename is passed directly to the system on all platforms, except on Windows, where the filename is interpreted as UTF-8. Only if the filename is not valid UTF-8, it will be interpreted according to the system codepage.
Added in version 1.7.7.
- Parameters:
file_name – A font filename
- Returns:
An
blob_tpointer with the content of the file, orblob_get_empty()if failed.
- blob_create_from_file_or_fail(file_name: str) blob_t#
Creates a new blob containing the data from the specified binary font file.
The filename is passed directly to the system on all platforms, except on Windows, where the filename is interpreted as UTF-8. Only if the filename is not valid UTF-8, it will be interpreted according to the system codepage.
Added in version 2.8.2.
- Parameters:
file_name – A font filename
- Returns:
An
blob_tpointer with the content of the file, orNULLif failed.
- blob_create_sub_blob(parent: blob_t, offset: int, length: int) blob_t#
Returns a blob that represents a range of bytes in
parent. The new blob is always created withHB_MEMORY_MODE_READONLY, meaning that it will never modify data in the parent blob. The parent data is not expected to be modified, and will result in undefined behavior if it is.Makes
parentimmutable.Added in version 0.9.2.
- Parameters:
parent – Parent blob.
offset – Start offset of sub-blob within
parent, in bytes.length – Length of sub-blob.
- Returns:
New blob, or the empty blob if something failed or if
lengthis zero oroffsetis beyond the end ofparent's data. Destroy withblob_destroy().
- blob_get_data(blob: blob_t) list[str] | None#
Fetches the data from a blob.
Added in version 0.9.2.
- Parameters:
blob – a blob.
- Returns:
the byte data of
blob.
- blob_get_data_writable(blob: blob_t) list[str]#
Tries to make blob data writable (possibly copying it) and return pointer to data.
Fails if blob has been made immutable, or if memory allocation fails.
Added in version 0.9.2.
- Parameters:
blob – a blob.
- Returns:
Writable blob data, or
NULLif failed.
- blob_get_empty() blob_t#
Returns the singleton empty blob.
See TODO:link object types for more information.
Added in version 0.9.2.
- Returns:
The empty blob.
- blob_get_length(blob: blob_t) int#
Fetches the length of a blob’s data.
Added in version 0.9.2.
- Parameters:
blob – a blob.
- Returns:
the length of
blobdata in bytes.
- blob_is_immutable(blob: blob_t) int#
Tests whether a blob is immutable.
Added in version 0.9.2.
- Parameters:
blob – a blob.
- Returns:
trueifblobis immutable,falseotherwise
- blob_make_immutable(blob: blob_t) None#
Makes a blob immutable.
Added in version 0.9.2.
- Parameters:
blob – a blob
- buffer_add(buffer: buffer_t, codepoint: int, cluster: int) None#
Appends a character with the Unicode value of
codepointtobuffer, and gives it the initial cluster value ofcluster. 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 inglyph_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.Added in version 0.9.7.
- Parameters:
buffer – An
buffer_tcodepoint – A Unicode code point.
cluster – The cluster value of
codepoint.
- buffer_add_codepoints(buffer: buffer_t, text: list[int], item_offset: int, item_length: int) None#
Appends characters from
textarray tobuffer. Theitem_offsetis the position of the first character fromtextthat will be appended, anditem_lengthis 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 asitem_offsetanditem_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 scalar values. In contrast,buffer_add_utf32()can be used that takes similar input but performs sanity-check on the input.Added in version 0.9.31.
- Parameters:
buffer – a
buffer_tto append characters to.text – an array of Unicode code points to append.
item_offset – the offset of the first code point to add to the
buffer.item_length – the number of code points to add to the
buffer, or -1 for the end oftext(assuming it isNULLterminated).
- buffer_add_latin1(buffer: buffer_t, text: list[int], item_offset: int, item_length: int) None#
Similar to
buffer_add_codepoints(), but allows only access to first 256 Unicode code points that can fit in 8-bit strings.<note>Has nothing to do with non-Unicode Latin-1 encoding.</note>
Added in version 0.9.39.
- Parameters:
buffer – An
buffer_ttext – an array of UTF-8 characters to append
item_offset – the offset of the first character to add to the
bufferitem_length – the number of characters to add to the
buffer, or -1 for the end oftext(assuming it isNULLterminated)
- buffer_add_utf16(buffer: buffer_t, text: list[int], item_offset: int, item_length: int) None#
-
Replaces invalid UTF-16 characters with the
bufferreplacement code point, seebuffer_set_replacement_codepoint().Added in version 0.9.2.
- Parameters:
buffer – An
buffer_ttext – An array of UTF-16 characters to append
item_offset – The offset of the first character to add to the
bufferitem_length – The number of characters to add to the
buffer, or -1 for the end oftext(assuming it isNULLterminated)
- buffer_add_utf32(buffer: buffer_t, text: list[int], item_offset: int, item_length: int) None#
-
Replaces invalid UTF-32 characters with the
bufferreplacement code point, seebuffer_set_replacement_codepoint().Added in version 0.9.2.
- Parameters:
buffer – An
buffer_ttext – An array of UTF-32 characters to append
item_offset – The offset of the first character to add to the
bufferitem_length – The number of characters to add to the
buffer, or -1 for the end oftext(assuming it isNULLterminated)
- buffer_add_utf8(buffer: buffer_t, text: list[int], item_offset: int, item_length: int) None#
-
Replaces invalid UTF-8 characters with the
bufferreplacement code point, seebuffer_set_replacement_codepoint().Added in version 0.9.2.
- Parameters:
buffer – An
buffer_ttext – An array of UTF-8 characters to append.
item_offset – The offset of the first character to add to the
buffer.item_length – The number of characters to add to the
buffer, or -1 for the end oftext(assuming it isNULLterminated).
- buffer_allocation_successful(buffer: buffer_t) int#
Check if allocating memory for the buffer succeeded.
Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t- Returns:
trueifbuffermemory allocation succeeded,falseotherwise.
- buffer_append(buffer: buffer_t, source: buffer_t, start: int, end: int) None#
Append (part of) contents of another buffer to this buffer.
Added in version 1.5.0.
- buffer_clear_contents(buffer: buffer_t) None#
Similar to
buffer_reset(), but does not clear the Unicode functions and the replacement code point.Added in version 0.9.11.
- Parameters:
buffer – An
buffer_t
- buffer_create() buffer_t#
Creates a new
buffer_twith all properties to defaults.Added in version 0.9.2.
- Returns:
A newly allocated
buffer_twith a reference count of 1. The initial reference count should be released withbuffer_destroy()when you are done using thebuffer_t. This function never returnsNULL. If memory cannot be allocated, a specialbuffer_tobject will be returned on whichbuffer_allocation_successful()returnsfalse.
- buffer_create_similar(src: buffer_t) buffer_t#
Creates a new
buffer_t, similar tobuffer_create(). The only difference is that the buffer is configured similarly tosrc.Added in version 3.3.0.
- Parameters:
src – An
buffer_t- Returns:
A newly allocated
buffer_t, similar tobuffer_create().
- buffer_deserialize_glyphs(buffer: buffer_t, buf: list[str], font: font_t | None, format: buffer_serialize_format_t) tuple[int, str]#
Deserializes glyphs
bufferfrom textual representation in the format produced bybuffer_serialize_glyphs().Added in version 0.9.7.
- Parameters:
buffer – an
buffer_tbuffer.buf – string to deserialize
font – font for getting glyph IDs
format – the
buffer_serialize_format_tof the inputbuf
- Returns:
trueif parse was successful,falseif an error occurred.
- buffer_deserialize_unicode(buffer: buffer_t, buf: list[str], format: buffer_serialize_format_t) tuple[int, str]#
Deserializes Unicode
bufferfrom textual representation in the format produced bybuffer_serialize_unicode().Added in version 2.7.3.
- Parameters:
buffer – an
buffer_tbuffer.buf – string to deserialize
format – the
buffer_serialize_format_tof the inputbuf
- Returns:
trueif parse was successful,falseif an error occurred.
- buffer_diff(buffer: buffer_t, reference: buffer_t, dottedcircle_glyph: int, position_fuzz: int) buffer_diff_flags_t#
If dottedcircle_glyph is (hb_codepoint_t) -1 then
HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENTandHB_BUFFER_DIFF_FLAG_NOTDEF_PRESENTare never returned. This should be used by most callers if just comparing two buffers is needed.Added in version 1.5.0.
- Parameters:
buffer – a buffer.
reference – other buffer to compare to.
dottedcircle_glyph – glyph id of U+25CC DOTTED CIRCLE, or (hb_codepoint_t) -1.
position_fuzz – allowed absolute difference in position values.
- buffer_get_cluster_level(buffer: buffer_t) buffer_cluster_level_t#
Fetches the cluster level of a buffer. The
buffer_cluster_level_tdictates one aspect of how HarfBuzz will treat non-base characters during shaping.Added in version 0.9.42.
- Parameters:
buffer – An
buffer_t- Returns:
The cluster level of
buffer
- buffer_get_content_type(buffer: buffer_t) buffer_content_type_t#
Fetches the type of
buffercontents. Buffers are either empty, contain characters (before shaping), or contain glyphs (the result of shaping).Added in version 0.9.5.
- Parameters:
buffer – An
buffer_t- Returns:
The type of
buffercontents
- buffer_get_direction(buffer: buffer_t) direction_t#
-
Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t- Returns:
The direction of the
buffer.
- buffer_get_empty() buffer_t#
Fetches an empty
buffer_t.Added in version 0.9.2.
- Returns:
The empty buffer
- buffer_get_flags(buffer: buffer_t) buffer_flags_t#
Fetches the
buffer_flags_tofbuffer.Added in version 0.9.7.
- Parameters:
buffer – An
buffer_t- Returns:
The
bufferflags
- buffer_get_glyph_infos(buffer: buffer_t) list[glyph_info_t]#
Returns
bufferglyph information array. Returned pointer is valid as long asbuffercontents are not modified.Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t- Returns:
The
bufferglyph information array. The value valid as long as buffer has not been modified.
- buffer_get_glyph_positions(buffer: buffer_t) list[glyph_position_t]#
Returns
bufferglyph position array. Returned pointer is valid as long asbuffercontents are not modified.If buffer did not have positions before, the positions will be initialized to zeros, unless this function is called from within a buffer message callback (see
buffer_set_message_func()), in which caseNULLis returned.Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t- Returns:
The
bufferglyph position array. The value valid as long as buffer has not been modified.
- buffer_get_invisible_glyph(buffer: buffer_t) int#
See
buffer_set_invisible_glyph().Added in version 2.0.0.
- Parameters:
buffer – An
buffer_t- Returns:
The
bufferinvisiblecodepoint_t
- buffer_get_language(buffer: buffer_t) language_t#
-
Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t- Returns:
The
language_tof the buffer. Must not be freed by the caller.
- buffer_get_length(buffer: buffer_t) int#
Returns the number of items in the buffer.
Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t- Returns:
The
bufferlength. The value valid as long as buffer has not been modified.
- buffer_get_not_found_glyph(buffer: buffer_t) int#
See
buffer_set_not_found_glyph().Added in version 3.1.0.
- Parameters:
buffer – An
buffer_t- Returns:
The
buffernot-foundcodepoint_t
- buffer_get_random_state(buffer: buffer_t) int#
See
buffer_set_random_state().Added in version 8.4.0.
- Parameters:
buffer – An
buffer_t- Returns:
The
bufferrandom state
- buffer_get_replacement_codepoint(buffer: buffer_t) int#
Fetches the
codepoint_tthat replaces invalid entries for a given encoding when adding text tobuffer.Added in version 0.9.31.
- Parameters:
buffer – An
buffer_t- Returns:
The
bufferreplacementcodepoint_t
- buffer_get_segment_properties(buffer: buffer_t) segment_properties_t#
Sets
propsto thesegment_properties_tofbuffer.Added in version 0.9.7.
- Parameters:
buffer – An
buffer_t
- buffer_get_unicode_funcs(buffer: buffer_t) unicode_funcs_t#
Fetches the Unicode-functions structure of a buffer.
Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t- Returns:
The Unicode-functions structure
- buffer_guess_segment_properties(buffer: buffer_t) None#
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 thanHB_SCRIPT_COMMON,HB_SCRIPT_INHERITED, andHB_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 byscript_get_horizontal_direction(). Ifscript_get_horizontal_direction()returnsHB_DIRECTION_INVALID, thenHB_DIRECTION_LTRis used.Finally, if buffer language is not set (ie. is
HB_LANGUAGE_INVALID), it will be set to the process’s default language as returned bylanguage_get_default(). This may change in the future by taking buffer script into consideration when choosing a language. Note thatlanguage_get_default()is NOT threadsafe the first time it is called. See documentation for that function for details.Added in version 0.9.7.
- Parameters:
buffer – An
buffer_t
- buffer_has_positions(buffer: buffer_t) int#
Returns whether
bufferhas glyph position data. A buffer gains position data whenbuffer_get_glyph_positions()is called on it, and cleared of position data whenbuffer_clear_contents()is called.Added in version 2.7.3.
- Parameters:
buffer – an
buffer_t.- Returns:
trueif thebufferhas position array,falseotherwise.
- buffer_normalize_glyphs(buffer: buffer_t) None#
Reorders a glyph buffer to have canonical in-cluster glyph order / position. The resulting clusters should behave identical to pre-reordering clusters.
<note>This has nothing to do with Unicode normalization.</note>
Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t
- buffer_pre_allocate(buffer: buffer_t, size: int) int#
Pre allocates memory for
bufferto fit at leastsizenumber of items.Added in version 0.9.2.
- Parameters:
buffer – An
buffer_tsize – Number of items to pre allocate.
- Returns:
trueifbuffermemory allocation succeeded,falseotherwise
- buffer_reset(buffer: buffer_t) None#
Resets the buffer to its initial status, as if it was just newly created with
buffer_create().Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t
- buffer_reverse(buffer: buffer_t) None#
Reverses buffer contents.
Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t
- buffer_reverse_clusters(buffer: buffer_t) None#
Reverses buffer clusters. That is, the buffer contents are reversed, then each cluster (consecutive items having the same cluster number) are reversed again.
Added in version 0.9.2.
- Parameters:
buffer – An
buffer_t
- buffer_reverse_range(buffer: buffer_t, start: int, end: int) None#
Reverses buffer contents between
startandend.Added in version 0.9.41.
- Parameters:
buffer – An
buffer_tstart – start index
end – end index
- buffer_serialize(buffer: buffer_t, start: int, end: int, font: font_t | None, format: buffer_serialize_format_t, flags: buffer_serialize_flags_t) tuple[int, list[int], int]#
Serializes
bufferinto 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 ofbuffer_serialize_unicode()andbuffer_serialize_glyphs()for a description of the output format.Added in version 2.7.3.
- Parameters:
buffer – an
buffer_tbuffer.start – the first item in
bufferto serialize.end – the last item in
bufferto serialize.font – the
font_tused to shape this buffer, needed to read glyph names and extents. IfNULL, an empty font will be used.format – the
buffer_serialize_format_tto use for formatting the output.flags – the
buffer_serialize_flags_tthat control what glyph properties to serialize.
- Returns:
The number of serialized items.
- buffer_serialize_format_from_string(str: list[int]) buffer_serialize_format_t#
Parses a string into an
buffer_serialize_format_t. Does not check ifstris a valid buffer serialization format, usebuffer_serialize_list_formats()to get the list of supported formats.Added in version 0.9.7.
- Parameters:
str – a string to parse
- Returns:
The parsed
buffer_serialize_format_t.
- buffer_serialize_format_to_string(format: buffer_serialize_format_t) str#
Converts
formatto the string corresponding it, orNULLif it is not a validbuffer_serialize_format_t.Added in version 0.9.7.
- Parameters:
format – an
buffer_serialize_format_tto convert.- Returns:
A
NULLterminated string corresponding toformat. Should not be freed.
- buffer_serialize_glyphs(buffer: buffer_t, start: int, end: int, font: font_t | None, format: buffer_serialize_format_t, flags: buffer_serialize_flags_t) tuple[int, list[int], int]#
Serializes
bufferinto 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_NAMESflag is set. Then,If
HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERSis not set,=thenglyph_info_t.cluster.If is not set, the
glyph_position_tin the format:- If bothglyph_position_t.x_offset andglyph_position_t.y_offset are not 0,@x_offset,y_offset. Then,+x_advance, then,y_advanceifglyph_position_t.y_advance is not 0. Then,If
HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTSis set, theglyph_extents_tin the format<x_bearing,y_bearing,width,height>
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 ifHB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMESflag is set.cl:glyph_info_t.cluster ifHB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERSis not set.dx,``dy``,``ax``,``ay``:glyph_position_t.x_offset,glyph_position_t.y_offset,glyph_position_t.x_advance andglyph_position_t.y_advance respectively, ifHB_BUFFER_SERIALIZE_FLAG_NO_POSITIONSis not set.
xb,``yb``,``w``,``h``:glyph_extents_t.x_bearing,glyph_extents_t.y_bearing,glyph_extents_t.width andglyph_extents_t.height respectively ifHB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTSis set.
Added in version 0.9.7.
- param buffer:
an
buffer_tbuffer.- param start:
the first item in
bufferto serialize.- param end:
the last item in
bufferto serialize.- param font:
the
font_tused to shape this buffer, needed to read glyph names and extents. IfNULL, an empty font will be used.- param format:
the
buffer_serialize_format_tto use for formatting the output.- param flags:
the
buffer_serialize_flags_tthat control what glyph properties to serialize.- return:
The number of serialized items.
- buffer_serialize_list_formats() list[str]#
Returns a list of supported buffer serialization formats.
Added in version 0.9.7.
- Returns:
A string array of buffer serialization formats. Should not be freed.
- buffer_serialize_unicode(buffer: buffer_t, start: int, end: int, format: buffer_serialize_format_t, flags: buffer_serialize_flags_t) tuple[int, list[int], int]#
Serializes
bufferinto 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>
Glyphs are separated with
|Unicode codepoints are expressed as zero-padded four (or more) digit hexadecimal numbers preceded by
U+If
HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERSis not set, the cluster will be indicated with a=thenglyph_info_t.cluster.
json#
A machine-readable, structured format. The serialized codepoints will be a list of objects with the following properties: -
u: the Unicode codepoint as a decimal integer -cl:glyph_info_t.cluster ifHB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERSis not set.For example:
[{u:1617,cl:0},{u:1576,cl:1}]
Added in version 2.7.3.
- param buffer:
an
buffer_tbuffer.- param start:
the first item in
bufferto serialize.- param end:
the last item in
bufferto serialize.- param format:
the
buffer_serialize_format_tto use for formatting the output.- param flags:
the
buffer_serialize_flags_tthat control what glyph properties to serialize.- return:
The number of serialized items.
- buffer_set_cluster_level(buffer: buffer_t, cluster_level: buffer_cluster_level_t) None#
Sets the cluster level of a buffer. The
buffer_cluster_level_tdictates one aspect of how HarfBuzz will treat non-base characters during shaping.Added in version 0.9.42.
- Parameters:
buffer – An
buffer_tcluster_level – The cluster level to set on the buffer
- buffer_set_content_type(buffer: buffer_t, content_type: buffer_content_type_t) None#
Sets the type of
buffercontents. Buffers are either empty, contain characters (before shaping), or contain glyphs (the result of shaping).You rarely need to call this function, since a number of other functions transition the content type for you. Namely:
A newly created buffer starts with content type
INVALID. Callingbuffer_reset(),buffer_clear_contents(), as well as callingbuffer_set_length()with an argument of zero all set the buffer content type to invalid as well.Calling
buffer_add_utf8(),buffer_add_utf16(),buffer_add_utf32(),buffer_add_codepoints()andbuffer_add_latin1()expect that buffer is either empty and have a content type of invalid, or that buffer content type isUNICODE, and they also set the content type to Unicode if they added anything to an empty buffer.Finally
shape()andshape_full()expect that the buffer is either empty and have content type of invalid, or that buffer content type isUNICODE, and upon success they set the buffer content type toGLYPHS.
The above transitions are designed such that one can use a buffer in a loop of “reset : add-text : shape” without needing to ever modify the content type manually.
Added in version 0.9.5.
- Parameters:
buffer – An
buffer_tcontent_type – The type of buffer contents to set
- buffer_set_direction(buffer: buffer_t, direction: direction_t) None#
Set the text flow direction of the buffer. No shaping can happen without setting
bufferdirection, 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.Added in version 0.9.2.
- Parameters:
buffer – An
buffer_tdirection – the
direction_tof thebuffer
- buffer_set_flags(buffer: buffer_t, flags: buffer_flags_t) None#
Sets
bufferflags toflags. Seebuffer_flags_t.Added in version 0.9.7.
- Parameters:
buffer – An
buffer_tflags – The buffer flags to set
- buffer_set_invisible_glyph(buffer: buffer_t, invisible: int) None#
Sets the
codepoint_tthat 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.Added in version 2.0.0.
- Parameters:
buffer – An
buffer_tinvisible – the invisible
codepoint_t
- buffer_set_language(buffer: buffer_t, language: language_t) None#
Sets the language of
buffertolanguage.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
language_from_string()to convert from BCP 47 language tags tolanguage_t.Added in version 0.9.2.
- Parameters:
buffer – An
buffer_tlanguage – An hb_language_t to set
- buffer_set_length(buffer: buffer_t, length: int) int#
Similar to
buffer_pre_allocate(), but clears any new items added at the end.Added in version 0.9.2.
- Parameters:
buffer – An
buffer_tlength – The new length of
buffer
- Returns:
trueifbuffermemory allocation succeeded,falseotherwise.
- buffer_set_message_func(buffer: buffer_t, func: Callable[[buffer_t, font_t, str, Any], int], user_data: Any = None) None#
Sets the implementation function for
buffer_message_func_t.Added in version 1.1.3.
- Parameters:
buffer – An
buffer_tfunc – Callback function
user_data – Data to pass to
func
- buffer_set_not_found_glyph(buffer: buffer_t, not_found: int) None#
Sets the
codepoint_tthat replaces characters not found in the font during shaping.The not-found glyph defaults to zero, sometimes known as the “.notdef” glyph. This API allows for differentiating the two.
Added in version 3.1.0.
- Parameters:
buffer – An
buffer_tnot_found – the not-found
codepoint_t
- buffer_set_random_state(buffer: buffer_t, state: int) None#
Sets the random state of the buffer. The state changes every time a glyph uses randomness (eg. the
randOpenType feature). This function together withbuffer_get_random_state()allow for transferring the current random state to a subsequent buffer, to get better randomness distribution.Defaults to 1 and when buffer contents are cleared. A value of 0 disables randomness during shaping.
Added in version 8.4.0.
- Parameters:
buffer – An
buffer_tstate – the new random state
- buffer_set_replacement_codepoint(buffer: buffer_t, replacement: int) None#
Sets the
codepoint_tthat replaces invalid entries for a given encoding when adding text tobuffer.Default is
HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT.Added in version 0.9.31.
- Parameters:
buffer – An
buffer_treplacement – the replacement
codepoint_t
- buffer_set_script(buffer: buffer_t, script: script_t) None#
Sets the script of
buffertoscript.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
script_tvalues, or usescript_from_string()orscript_from_iso15924_tag()to get the corresponding script from an ISO 15924 script tag.Added in version 0.9.2.
- buffer_set_segment_properties(buffer: buffer_t, props: segment_properties_t) None#
Sets the segment properties of the buffer, a shortcut for calling
buffer_set_direction(),buffer_set_script()andbuffer_set_language()individually.Added in version 0.9.7.
- Parameters:
buffer – An
buffer_tprops – An
segment_properties_tto use
- buffer_set_unicode_funcs(buffer: buffer_t, unicode_funcs: unicode_funcs_t) None#
Sets the Unicode-functions structure of a buffer to
unicode_funcs.Added in version 0.9.2.
- Parameters:
buffer – An
buffer_tunicode_funcs – The Unicode-functions structure
- color_get_alpha(color: int) int#
Fetches the alpha channel of the given
color.Added in version 2.1.0.
- Parameters:
color – an
color_twe are interested in its channels.- Returns:
Alpha channel value
- color_get_blue(color: int) int#
Fetches the blue channel of the given
color.Added in version 2.1.0.
- Parameters:
color – an
color_twe are interested in its channels.- Returns:
Blue channel value
- color_get_green(color: int) int#
Fetches the green channel of the given
color.Added in version 2.1.0.
- Parameters:
color – an
color_twe are interested in its channels.- Returns:
Green channel value
- color_get_red(color: int) int#
Fetches the red channel of the given
color.Added in version 2.1.0.
- Parameters:
color – an
color_twe are interested in its channels.- Returns:
Red channel value
- color_line_get_color_stops(color_line: color_line_t, start: int) tuple[int, list[color_stop_t]]#
Fetches a list of color stops from the given color line object.
Note that due to variations being applied, the returned color stops may be out of order. It is the callers responsibility to ensure that color stops are sorted by their offset before they are used.
Added in version 7.0.0.
- Parameters:
color_line – a
color_line_tobjectstart – the index of the first color stop to return
- Returns:
the total number of color stops in
color_line
- color_line_get_extend(color_line: color_line_t) paint_extend_t#
Fetches the extend mode of the color line object.
Added in version 7.0.0.
- Parameters:
color_line – a
color_line_tobject- Returns:
the extend mode of
color_line
- direction_from_string(str: list[int]) direction_t#
Converts a string to an
direction_t.Matching is loose and applies only to the first letter. For examples, “LTR” and “left-to-right” will both return
HB_DIRECTION_LTR.Unmatched strings will return
HB_DIRECTION_INVALID.Added in version 0.9.2.
- Parameters:
str – String to convert
- Returns:
The
direction_tmatchingstr
- direction_to_string(direction: direction_t) str#
Converts an
direction_tto a string.Added in version 0.9.2.
- Parameters:
direction – The
direction_tto convert- Returns:
The string corresponding to
direction
- draw_close_path(dfuncs: draw_funcs_t, draw_data: Any, st: draw_state_t) None#
Perform a “close-path” draw operation.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions
draw_data – associated draw data passed by the caller
st – current draw state
- draw_cubic_to(dfuncs: draw_funcs_t, draw_data: Any, st: draw_state_t, control1_x: float, control1_y: float, control2_x: float, control2_y: float, to_x: float, to_y: float) None#
Perform a “cubic-to” draw operation.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions
draw_data – associated draw data passed by the caller
st – current draw state
control1_x – X component of first control point
control1_y – Y component of first control point
control2_x – X component of second control point
control2_y – Y component of second control point
to_x – X component of target point
to_y – Y component of target point
- draw_funcs_create() draw_funcs_t#
Creates a new draw callbacks object.
Added in version 4.0.0.
- Returns:
A newly allocated
draw_funcs_twith a reference count of 1. The initial reference count should be released with hb_draw_funcs_destroy when you are done using thedraw_funcs_t. This function never returnsNULL. If memory cannot be allocated, a special singletondraw_funcs_tobject will be returned.
- draw_funcs_get_empty() draw_funcs_t#
Fetches the singleton empty draw-functions structure.
Added in version 7.0.0.
- Returns:
The empty draw-functions structure
- draw_funcs_is_immutable(dfuncs: draw_funcs_t) int#
Checks whether
dfuncsis immutable.Added in version 4.0.0.
- Parameters:
dfuncs – draw functions
- Returns:
trueifdfuncsis immutable,falseotherwise
- draw_funcs_make_immutable(dfuncs: draw_funcs_t) None#
Makes
dfuncsobject immutable.Added in version 4.0.0.
- Parameters:
dfuncs – draw functions
- draw_funcs_set_close_path_func(dfuncs: draw_funcs_t, func: Callable[[draw_funcs_t, Any, draw_state_t, Any], None], user_data: Any = None) None#
Sets close-path callback to the draw functions object.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions object
func – close-path callback
user_data – Data to pass to
func
- draw_funcs_set_cubic_to_func(dfuncs: draw_funcs_t, func: Callable[[draw_funcs_t, Any, draw_state_t, float, float, float, float, float, float, Any], None], user_data: Any = None) None#
Sets cubic-to callback to the draw functions object.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions
func – cubic-to callback
user_data – Data to pass to
func
- draw_funcs_set_line_to_func(dfuncs: draw_funcs_t, func: Callable[[draw_funcs_t, Any, draw_state_t, float, float, Any], None], user_data: Any = None) None#
Sets line-to callback to the draw functions object.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions object
func – line-to callback
user_data – Data to pass to
func
- draw_funcs_set_move_to_func(dfuncs: draw_funcs_t, func: Callable[[draw_funcs_t, Any, draw_state_t, float, float, Any], None], user_data: Any = None) None#
Sets move-to callback to the draw functions object.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions object
func – move-to callback
user_data – Data to pass to
func
- draw_funcs_set_quadratic_to_func(dfuncs: draw_funcs_t, func: Callable[[draw_funcs_t, Any, draw_state_t, float, float, float, float, Any], None], user_data: Any = None) None#
Sets quadratic-to callback to the draw functions object.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions object
func – quadratic-to callback
user_data – Data to pass to
func
- draw_line_to(dfuncs: draw_funcs_t, draw_data: Any, st: draw_state_t, to_x: float, to_y: float) None#
Perform a “line-to” draw operation.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions
draw_data – associated draw data passed by the caller
st – current draw state
to_x – X component of target point
to_y – Y component of target point
- draw_move_to(dfuncs: draw_funcs_t, draw_data: Any, st: draw_state_t, to_x: float, to_y: float) None#
Perform a “move-to” draw operation.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions
draw_data – associated draw data passed by the caller
st – current draw state
to_x – X component of target point
to_y – Y component of target point
- draw_quadratic_to(dfuncs: draw_funcs_t, draw_data: Any, st: draw_state_t, control_x: float, control_y: float, to_x: float, to_y: float) None#
Perform a “quadratic-to” draw operation.
Added in version 4.0.0.
- Parameters:
dfuncs – draw functions
draw_data – associated draw data passed by the caller
st – current draw state
control_x – X component of control point
control_y – Y component of control point
to_x – X component of target point
to_y – Y component of target point
- face_builder_add_table(face: face_t, tag: int, blob: blob_t) int#
Add table for
tagwith data provided byblobto the face.facemust be created usingface_builder_create().Added in version 1.9.0.
- Parameters:
face – A face object created with
face_builder_create()tag – The
tag_tof the table to addblob – The blob containing the table data to add
- face_builder_create() face_t#
Creates a
face_tthat can be used withface_builder_add_table(). After tables are added to the face, it can be compiled to a binary font file by callingface_reference_blob().Added in version 1.9.0.
- Returns:
New face.
- face_builder_sort_tables(face: face_t, tags: list[int]) None#
Set the ordering of tables for serialization. Any tables not specified in the tags list will be ordered after the tables in tags, ordered by the default sort ordering.
Added in version 5.3.0.
- Parameters:
face – A face object created with
face_builder_create()tags – ordered list of table tags terminated by %HB_TAG_NONE
- face_collect_nominal_glyph_mapping(face: face_t) tuple[map_t, set_t | None]#
Collects the mapping from Unicode characters to nominal glyphs of the
face, and optionally all of the Unicode characters covered byface.Added in version 7.0.0.
- Parameters:
face – A face object
- face_collect_unicodes(face: face_t) set_t#
Collects all of the Unicode characters covered by
faceand adds them to theset_tsetout.Added in version 1.9.0.
- Parameters:
face – A face object
- face_collect_variation_selectors(face: face_t) set_t#
Collects all Unicode “Variation Selector” characters covered by
faceand adds them to theset_tsetout.Added in version 1.9.0.
- Parameters:
face – A face object
- face_collect_variation_unicodes(face: face_t, variation_selector: int) set_t#
Collects all Unicode characters for
variation_selectorcovered byfaceand adds them to theset_tsetout.Added in version 1.9.0.
- Parameters:
face – A face object
variation_selector – The Variation Selector to query
- face_count(blob: blob_t) int#
Fetches the number of faces in a blob.
Added in version 1.7.7.
- Parameters:
blob – a blob.
- Returns:
Number of faces in
blob
- face_create(blob: blob_t, index: int) face_t#
Constructs a new face object from the specified blob and a face index into that blob.
The face index is used for blobs of file formats such as TTC and DFont that can contain more than one face. Face indices within such collections are zero-based.
<note>Note: If the blob font format is not a collection,
indexis ignored. Otherwise, only the lower 16-bits ofindexare used. The unmodifiedindexcan be accessed viaface_get_index().</note><note>Note: The high 16-bits of
index, if non-zero, are used byfont_create()to load named-instances in variable fonts. Seefont_create()for details.</note>Added in version 0.9.2.
- Parameters:
blob –
blob_tto work uponindex – The index of the face within
blob
- Returns:
The new face object
- face_create_for_tables(reference_table_func: Callable[[face_t, int, Any], blob_t], user_data: Any = None) face_t#
Variant of
face_create(), built for those cases where it is more convenient to provide data for individual tables instead of the whole font data. With the caveat thatface_get_table_tags()does not currently work with faces created this way.Creates a new face object from the specified
user_dataandreference_table_func, with thedestroycallback.Added in version 0.9.2.
- Parameters:
reference_table_func – Table-referencing function
user_data – A pointer to the user data
- Returns:
The new face object
- face_get_empty() face_t#
Fetches the singleton empty face object.
Added in version 0.9.2.
- Returns:
The empty face object
- face_get_glyph_count(face: face_t) int#
Fetches the glyph-count value of the specified face object.
Added in version 0.9.7.
- Parameters:
face – A face object
- Returns:
The glyph-count value of
face
- face_get_index(face: face_t) int#
Fetches the face-index corresponding to the given face.
<note>Note: face indices within a collection are zero-based.</note>
Added in version 0.9.2.
- Parameters:
face – A face object
- Returns:
The index of
face.
- face_get_table_tags(face: face_t, start_offset: int) tuple[int, list[int]]#
Fetches a list of all table tags for a face, if possible. The list returned will begin at the offset provided
Added in version 1.6.0.
- Parameters:
face – A face object
start_offset – The index of first table tag to retrieve
- Returns:
Total number of tables, or zero if it is not possible to list
- face_get_upem(face: face_t) int#
Fetches the units-per-em (UPEM) value of the specified face object.
Typical UPEM values for fonts are 1000, or 2048, but any value in between 16 and 16,384 is allowed for OpenType fonts.
Added in version 0.9.2.
- Parameters:
face – A face object
- Returns:
The upem value of
face
- face_is_immutable(face: face_t) int#
Tests whether the given face object is immutable.
Added in version 0.9.2.
- Parameters:
face – A face object
- Returns:
trueisfaceis immutable,falseotherwise
- face_make_immutable(face: face_t) None#
Makes the given face object immutable.
Added in version 0.9.2.
- Parameters:
face – A face object
- face_reference_blob(face: face_t) blob_t#
Fetches a pointer to the binary blob that contains the specified face. Returns an empty blob if referencing face data is not possible.
Added in version 0.9.2.
- Parameters:
face – A face object
- Returns:
A pointer to the blob for
face
- face_reference_table(face: face_t, tag: int) blob_t#
Fetches a reference to the specified table within the specified face.
Added in version 0.9.2.
- Parameters:
face – A face object
tag – The
tag_tof the table to query
- Returns:
A pointer to the
tagtable withinface
- face_set_glyph_count(face: face_t, glyph_count: int) None#
Sets the glyph count for a face object to the specified value.
This API is used in rare circumstances.
Added in version 0.9.7.
- Parameters:
face – A face object
glyph_count – The glyph-count value to assign
- face_set_index(face: face_t, index: int) None#
Assigns the specified face-index to
face. Fails if the face is immutable.<note>Note: changing the index has no effect on the face itself This only changes the value returned by
face_get_index().</note>Added in version 0.9.2.
- Parameters:
face – A face object
index – The index to assign
- face_set_upem(face: face_t, upem: int) None#
Sets the units-per-em (upem) for a face object to the specified value.
This API is used in rare circumstances.
Added in version 0.9.2.
- Parameters:
face – A face object
upem – The units-per-em value to assign
- feature_from_string(str: list[int]) tuple[int, feature_t]#
Parses a string into a
feature_t.The format for specifying feature strings follows. All valid CSS font-feature-settings values other than ‘normal’ and the global values are also accepted, though not documented below. CSS string escapes are not supported.
The range indices refer to the positions between Unicode characters. The position before the first character is always 0.
The format is Python-esque. Here is how it all works:
<informaltable pgwide=’1’ align=’left’ frame=’none’> <tgroup cols=’5’> <thead> <row><entry>Syntax</entry> <entry>Value</entry> <entry>Start</entry> <entry>End</entry></row> </thead> <tbody> <row><entry>Setting value:</entry></row> <row><entry>kern</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row> <row><entry>+kern</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row> <row><entry>-kern</entry> <entry>0</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature off</entry></row> <row><entry>kern=0</entry> <entry>0</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature off</entry></row> <row><entry>kern=1</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row> <row><entry>aalt=2</entry> <entry>2</entry> <entry>0</entry> <entry>∞</entry> <entry>Choose 2nd alternate</entry></row> <row><entry>Setting index:</entry></row> <row><entry>kern[]</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row> <row><entry>kern[:]</entry> <entry>1</entry> <entry>0</entry> <entry>∞</entry> <entry>Turn feature on</entry></row> <row><entry>kern[5:]</entry> <entry>1</entry> <entry>5</entry> <entry>∞</entry> <entry>Turn feature on, partial</entry></row> <row><entry>kern[:5]</entry> <entry>1</entry> <entry>0</entry> <entry>5</entry> <entry>Turn feature on, partial</entry></row> <row><entry>kern[3:5]</entry> <entry>1</entry> <entry>3</entry> <entry>5</entry> <entry>Turn feature on, range</entry></row> <row><entry>kern[3]</entry> <entry>1</entry> <entry>3</entry> <entry>3+1</entry> <entry>Turn feature on, single char</entry></row> <row><entry>Mixing it all:</entry></row> <row><entry>aalt[3:5]=2</entry> <entry>2</entry> <entry>3</entry> <entry>5</entry> <entry>Turn 2nd alternate on for range</entry></row> </tbody> </tgroup> </informaltable>
Added in version 0.9.5.
- Parameters:
str – a string to parse
- Returns:
trueifstris successfully parsed,falseotherwise
- feature_to_string(feature: feature_t) list[str]#
Converts a
feature_tinto aNULL-terminated string in the format understood byfeature_from_string(). The client in responsible for allocating big enough size forbuf, 128 bytes is more than enough.Added in version 0.9.5.
- Parameters:
feature – an
feature_tto convert
- font_add_glyph_origin_for_direction(font: font_t, glyph: int, direction: direction_t, x: int, y: int) tuple[int, int]#
Adds the origin coordinates to an (X,Y) point coordinate, in the specified glyph ID in the specified font.
Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
direction – The direction of the text segment
x – Input = The original X coordinate Output = The X coordinate plus the X-coordinate of the origin
y – Input = The original Y coordinate Output = The Y coordinate plus the Y-coordinate of the origin
- font_changed(font: font_t) None#
Notifies the
fontthat underlying font data has changed. This has the effect of increasing the serial as returned byfont_get_serial(), which invalidates internal caches.Added in version 4.4.0.
- Parameters:
font –
font_tto work upon
- font_create(face: face_t) font_t#
Constructs a new font object from the specified face.
<note>Note: If
face's index value (as passed toface_create()has non-zero top 16-bits, those bits minus one are passed tofont_set_var_named_instance(), effectively loading a named-instance of a variable font, instead of the default-instance. This allows specifying which named-instance to load by default when creating the face.</note>Added in version 0.9.2.
- Parameters:
face – a face.
- Returns:
The new font object
- font_create_sub_font(parent: font_t) font_t#
Constructs a sub-font font object from the specified
parentfont, replicating the parent’s properties.Added in version 0.9.2.
- Parameters:
parent – The parent font object
- Returns:
The new sub-font font object
- font_draw_glyph(font: font_t, glyph: int, dfuncs: draw_funcs_t, draw_data: Any = None) None#
Draws the outline that corresponds to a glyph in the specified
font.The outline is returned by way of calls to the callbacks of the
dfuncsobjects, withdraw_datapassed to them.Added in version 7.0.0.
- Parameters:
font –
font_tto work uponglyph – The glyph ID
dfuncs –
draw_funcs_tto draw todraw_data – User data to pass to draw callbacks
- font_funcs_create() font_funcs_t#
Creates a new
font_funcs_tstructure of font functions.Added in version 0.9.2.
- Returns:
The font-functions structure
- font_funcs_get_empty() font_funcs_t#
Fetches an empty font-functions structure.
Added in version 0.9.2.
- Returns:
The font-functions structure
- font_funcs_is_immutable(ffuncs: font_funcs_t) int#
Tests whether a font-functions structure is immutable.
Added in version 0.9.2.
- Parameters:
ffuncs – The font-functions structure
- Returns:
trueifffuncsis immutable,falseotherwise
- font_funcs_make_immutable(ffuncs: font_funcs_t) None#
Makes a font-functions structure immutable.
Added in version 0.9.2.
- Parameters:
ffuncs – The font-functions structure
- font_funcs_set_draw_glyph_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, draw_funcs_t, Any, Any], None], user_data: Any = None) None#
Sets the implementation function for
font_draw_glyph_func_t.Added in version 7.0.0.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_font_h_extents_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, Any], tuple[int, font_extents_t]], user_data: Any = None) None#
Sets the implementation function for
font_get_font_h_extents_func_t.Added in version 1.1.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_font_v_extents_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, Any], tuple[int, font_extents_t]], user_data: Any = None) None#
Sets the implementation function for
font_get_font_v_extents_func_t.Added in version 1.1.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_contour_point_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, int, Any], tuple[int, int, int]], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_contour_point_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_extents_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, Any], tuple[int, glyph_extents_t]], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_extents_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_from_name_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, list[str], Any], tuple[int, int]], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_from_name_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, int, Any], tuple[int, int]], user_data: Any = None) None#
Deprecated. Use
font_funcs_set_nominal_glyph_func()andfont_funcs_set_variation_glyph_func()instead.Added in version 0.9.2.
Deprecated since version 1.2.3: Please do not use it in newly written code
- Parameters:
ffuncs – The font-functions structure
func – callback function
user_data – data to pass to
func
- font_funcs_set_glyph_h_advance_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_h_advance_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_h_advances_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, int, int, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_h_advances_func_t.Added in version 1.8.6.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_h_kerning_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_h_kerning_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_h_origin_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, Any], tuple[int, int, int]], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_h_origin_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_name_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, Any], tuple[int, list[str]]], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_name_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_shape_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, draw_funcs_t, Any, Any], None], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_shape_func_t, which is the same asfont_draw_glyph_func_t.Added in version 4.0.0.
Deprecated since version 7.0.0: Use
font_funcs_set_draw_glyph_func()instead- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_v_advance_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_v_advance_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_v_advances_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, int, int, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_v_advances_func_t.Added in version 1.8.6.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_v_kerning_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_v_kerning_func_t.Added in version 0.9.2.
Deprecated since version 2.0.0: Please do not use it in newly written code
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_glyph_v_origin_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, Any], tuple[int, int, int]], user_data: Any = None) None#
Sets the implementation function for
font_get_glyph_v_origin_func_t.Added in version 0.9.2.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_nominal_glyph_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, Any], tuple[int, int]], user_data: Any = None) None#
Sets the implementation function for
font_get_nominal_glyph_func_t.Added in version 1.2.3.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_nominal_glyphs_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, int, int, int, Any], tuple[int, int]], user_data: Any = None) None#
Sets the implementation function for
font_get_nominal_glyphs_func_t.Added in version 2.0.0.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_paint_glyph_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, paint_funcs_t, Any, int, int, Any], None], user_data: Any = None) None#
Sets the implementation function for
font_paint_glyph_func_t.Added in version 7.0.0.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_funcs_set_variation_glyph_func(ffuncs: font_funcs_t, func: Callable[[font_t, Any, int, int, Any], tuple[int, int]], user_data: Any = None) None#
Sets the implementation function for
font_get_variation_glyph_func_t.Added in version 1.2.3.
- Parameters:
ffuncs – A font-function structure
func – The callback function to assign
user_data – Data to pass to
func
- font_get_empty() font_t#
Fetches the empty font object.
Added in version 0.9.2.
- Returns:
The empty font object
- font_get_extents_for_direction(font: font_t, direction: direction_t) font_extents_t#
Fetches the extents for a font in a text segment of the specified direction.
Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 1.1.3.
- Parameters:
font –
font_tto work upondirection – The direction of the text segment
- font_get_face(font: font_t) face_t#
Fetches the face associated with the specified font object.
Added in version 0.9.2.
- font_get_glyph(font: font_t, unicode: int, variation_selector: int) tuple[int, int]#
Fetches the glyph ID for a Unicode code point in the specified font, with an optional variation selector.
If
variation_selectoris 0, callsfont_get_nominal_glyph(); otherwise callsfont_get_variation_glyph().Added in version 0.9.2.
- Parameters:
font –
font_tto work uponunicode – The Unicode code point to query
variation_selector – A variation-selector code point
- Returns:
trueif data found,falseotherwise
- font_get_glyph_advance_for_direction(font: font_t, glyph: int, direction: direction_t) tuple[int, int]#
Fetches the advance for a glyph ID from the specified font, in a text segment of the specified direction.
Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
direction – The direction of the text segment
- font_get_glyph_advances_for_direction(font: font_t, direction: direction_t, count: int, first_glyph: int, glyph_stride: int) tuple[int, int]#
Fetches the advances for a sequence of glyph IDs in the specified font, in a text segment of the specified direction.
Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 1.8.6.
- Parameters:
font –
font_tto work upondirection – The direction of the text segment
count – The number of glyph IDs in the sequence queried
first_glyph – The first glyph ID to query
glyph_stride – The stride between successive glyph IDs
- font_get_glyph_contour_point(font: font_t, glyph: int, point_index: int) tuple[int, int, int]#
Fetches the (x,y) coordinates of a specified contour-point index in the specified glyph, within the specified font.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
point_index – The contour-point index to query
- Returns:
trueif data found,falseotherwise
- font_get_glyph_contour_point_for_origin(font: font_t, glyph: int, point_index: int, direction: direction_t) tuple[int, int, int]#
Fetches the (X,Y) coordinates of a specified contour-point index in the specified glyph ID in the specified font, with respect to the origin in a text segment in the specified direction.
Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
point_index – The contour-point index to query
direction – The direction of the text segment
- Returns:
trueif data found,falseotherwise
- font_get_glyph_extents(font: font_t, glyph: int) tuple[int, glyph_extents_t]#
Fetches the
glyph_extents_tdata for a glyph ID in the specified font.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
- Returns:
trueif data found,falseotherwise
- font_get_glyph_extents_for_origin(font: font_t, glyph: int, direction: direction_t) tuple[int, glyph_extents_t]#
Fetches the
glyph_extents_tdata for a glyph ID in the specified font, with respect to the origin in a text segment in the specified direction.Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
direction – The direction of the text segment
- Returns:
trueif data found,falseotherwise
- font_get_glyph_from_name(font: font_t, name: list[str]) tuple[int, int]#
Fetches the glyph ID that corresponds to a name string in the specified
font.<note>Note:
len== -1 means the name string is null-terminated.</note>Added in version 0.9.2.
- Parameters:
font –
font_tto work uponname – The name string to query
- Returns:
trueif data found,falseotherwise
- font_get_glyph_h_advance(font: font_t, glyph: int) int#
Fetches the advance for a glyph ID in the specified font, for horizontal text segments.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
- Returns:
The advance of
glyphwithinfont
- font_get_glyph_h_advances(font: font_t, count: int, first_glyph: int, glyph_stride: int, advance_stride: int) int#
Fetches the advances for a sequence of glyph IDs in the specified font, for horizontal text segments.
Added in version 1.8.6.
- Parameters:
font –
font_tto work uponcount – The number of glyph IDs in the sequence queried
first_glyph – The first glyph ID to query
glyph_stride – The stride between successive glyph IDs
advance_stride – The stride between successive advances
- font_get_glyph_h_kerning(font: font_t, left_glyph: int, right_glyph: int) int#
Fetches the kerning-adjustment value for a glyph-pair in the specified font, for horizontal text segments.
<note>It handles legacy kerning only (as returned by the corresponding
font_funcs_tfunction).</note>Added in version 0.9.2.
- Parameters:
font –
font_tto work uponleft_glyph – The glyph ID of the left glyph in the glyph pair
right_glyph – The glyph ID of the right glyph in the glyph pair
- Returns:
The kerning adjustment value
- font_get_glyph_h_origin(font: font_t, glyph: int) tuple[int, int, int]#
Fetches the (X,Y) coordinates of the origin for a glyph ID in the specified font, for horizontal text segments.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
- Returns:
trueif data found,falseotherwise
- font_get_glyph_kerning_for_direction(font: font_t, first_glyph: int, second_glyph: int, direction: direction_t) tuple[int, int]#
Fetches the kerning-adjustment value for a glyph-pair in the specified font.
Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponfirst_glyph – The glyph ID of the first glyph in the glyph pair to query
second_glyph – The glyph ID of the second glyph in the glyph pair to query
direction – The direction of the text segment
- font_get_glyph_name(font: font_t, glyph: int) tuple[int, list[str]]#
Fetches the glyph-name string for a glyph ID in the specified
font.According to the OpenType specification, glyph names are limited to 63 characters and can only contain (a subset of) ASCII.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
- Returns:
trueif data found,falseotherwise
- font_get_glyph_origin_for_direction(font: font_t, glyph: int, direction: direction_t) tuple[int, int]#
Fetches the (X,Y) coordinates of the origin for a glyph in the specified font.
Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
direction – The direction of the text segment
- font_get_glyph_shape(font: font_t, glyph: int, dfuncs: draw_funcs_t, draw_data: Any = None) None#
Fetches the glyph shape that corresponds to a glyph in the specified
font. The shape is returned by way of calls to the callbacks of thedfuncsobjects, withdraw_datapassed to them.Added in version 4.0.0.
Deprecated since version 7.0.0: Use
font_draw_glyph()instead- Parameters:
font –
font_tto work uponglyph – The glyph ID
dfuncs –
draw_funcs_tto draw todraw_data – User data to pass to draw callbacks
- font_get_glyph_v_advance(font: font_t, glyph: int) int#
Fetches the advance for a glyph ID in the specified font, for vertical text segments.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
- Returns:
The advance of
glyphwithinfont
- font_get_glyph_v_advances(font: font_t, count: int, first_glyph: int, glyph_stride: int) tuple[int, int]#
Fetches the advances for a sequence of glyph IDs in the specified font, for vertical text segments.
Added in version 1.8.6.
- Parameters:
font –
font_tto work uponcount – The number of glyph IDs in the sequence queried
first_glyph – The first glyph ID to query
glyph_stride – The stride between successive glyph IDs
- font_get_glyph_v_kerning(font: font_t, top_glyph: int, bottom_glyph: int) int#
Fetches the kerning-adjustment value for a glyph-pair in the specified font, for vertical text segments.
<note>It handles legacy kerning only (as returned by the corresponding
font_funcs_tfunction).</note>Added in version 0.9.2.
Deprecated since version 2.0.0: Please do not use it in newly written code
- Parameters:
font –
font_tto work upontop_glyph – The glyph ID of the top glyph in the glyph pair
bottom_glyph – The glyph ID of the bottom glyph in the glyph pair
- Returns:
The kerning adjustment value
- font_get_glyph_v_origin(font: font_t, glyph: int) tuple[int, int, int]#
Fetches the (X,Y) coordinates of the origin for a glyph ID in the specified font, for vertical text segments.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
- Returns:
trueif data found,falseotherwise
- font_get_h_extents(font: font_t) tuple[int, font_extents_t]#
Fetches the extents for a specified font, for horizontal text segments.
Added in version 1.1.3.
- Parameters:
font –
font_tto work upon- Returns:
trueif data found,falseotherwise
- font_get_nominal_glyph(font: font_t, unicode: int) tuple[int, int]#
Fetches the nominal glyph ID for a Unicode code point in the specified font.
This version of the function should not be used to fetch glyph IDs for code points modified by variation selectors. For variation-selector support, user
font_get_variation_glyph()or usefont_get_glyph().Added in version 1.2.3.
- Parameters:
font –
font_tto work uponunicode – The Unicode code point to query
- Returns:
trueif data found,falseotherwise
- font_get_nominal_glyphs(font: font_t, count: int, first_unicode: int, unicode_stride: int, glyph_stride: int) tuple[int, int]#
Fetches the nominal glyph IDs for a sequence of Unicode code points. Glyph IDs must be returned in a
codepoint_toutput parameter. Stops at the first unsupported glyph ID.Added in version 2.6.3.
- Parameters:
font –
font_tto work uponcount – number of code points to query
first_unicode – The first Unicode code point to query
unicode_stride – The stride between successive code points
glyph_stride – The stride between successive glyph IDs
- Returns:
the number of code points processed
- font_get_parent(font: font_t) font_t#
Fetches the parent font of
font.Added in version 0.9.2.
- Parameters:
font –
font_tto work upon- Returns:
The parent font object
- font_get_ppem(font: font_t) tuple[int, int]#
Fetches the horizontal and vertical points-per-em (ppem) of a font.
Added in version 0.9.2.
- Parameters:
font –
font_tto work upon
- font_get_ptem(font: font_t) float#
Fetches the “point size” of a font. Used in CoreText to implement optical sizing.
Added in version 1.6.0.
- Parameters:
font –
font_tto work upon- Returns:
Point size. A value of zero means “not set.”
- font_get_scale(font: font_t) tuple[int, int]#
Fetches the horizontal and vertical scale of a font.
Added in version 0.9.2.
- Parameters:
font –
font_tto work upon
- font_get_serial(font: font_t) int#
Returns the internal serial number of the font. The serial number is increased every time a setting on the font is changed, using a setter function.
Added in version 4.4.0.
- Parameters:
font –
font_tto work upon- Returns:
serial number
- font_get_synthetic_bold(font: font_t) tuple[float, float, int]#
Fetches the “synthetic boldness” parameters of a font.
Added in version 7.0.0.
- Parameters:
font –
font_tto work upon
- font_get_synthetic_slant(font: font_t) float#
Fetches the “synthetic slant” of a font.
Added in version 3.3.0.
- Parameters:
font –
font_tto work upon- Returns:
Synthetic slant. By default is zero.
- font_get_v_extents(font: font_t) tuple[int, font_extents_t]#
Fetches the extents for a specified font, for vertical text segments.
Added in version 1.1.3.
- Parameters:
font –
font_tto work upon- Returns:
trueif data found,falseotherwise
- font_get_var_coords_design(font: font_t) tuple[float, int]#
Fetches the list of variation coordinates (in design-space units) currently set on a font.
Note that this returned array may only contain values for some (or none) of the axes; omitted axes effectively have their default values.
Return value is valid as long as variation coordinates of the font are not modified.
Added in version 3.3.0.
- Parameters:
font –
font_tto work upon- Returns:
coordinates array
- font_get_var_coords_normalized(font: font_t) tuple[int, int]#
Fetches the list of normalized variation coordinates currently set on a font.
Note that this returned array may only contain values for some (or none) of the axes; omitted axes effectively have zero values.
Return value is valid as long as variation coordinates of the font are not modified.
Added in version 1.4.2.
- Parameters:
font –
font_tto work upon- Returns:
coordinates array
- font_get_var_named_instance(font: font_t) int#
Returns the currently-set named-instance index of the font.
Added in version 7.0.0.
- Parameters:
font – a font.
- Returns:
Named-instance index or
FONT_NO_VAR_NAMED_INSTANCE.
- font_get_variation_glyph(font: font_t, unicode: int, variation_selector: int) tuple[int, int]#
Fetches the glyph ID for a Unicode code point when followed by by the specified variation-selector code point, in the specified font.
Added in version 1.2.3.
- Parameters:
font –
font_tto work uponunicode – The Unicode code point to query
variation_selector – The variation-selector code point to query
- Returns:
trueif data found,falseotherwise
- font_glyph_from_string(font: font_t, s: list[int]) tuple[int, int]#
Fetches the glyph ID from
fontthat matches the specified string. Strings of the formatgidDDDoruniUUUUare parsed automatically.<note>Note:
len== -1 means the string is null-terminated.</note>Added in version 0.9.2.
- Parameters:
font –
font_tto work upons – string to query
- Returns:
trueif data found,falseotherwise
- font_glyph_to_string(font: font_t, glyph: int) list[str]#
Fetches the name of the specified glyph ID in
fontand returns it in strings.If the glyph ID has no name in
font, a string of the formgidDDDis generated, withDDDbeing the glyph ID.According to the OpenType specification, glyph names are limited to 63 characters and can only contain (a subset of) ASCII.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
- font_is_immutable(font: font_t) int#
Tests whether a font object is immutable.
Added in version 0.9.2.
- Parameters:
font –
font_tto work upon- Returns:
trueiffontis immutable,falseotherwise
- font_make_immutable(font: font_t) None#
Makes
fontimmutable.Added in version 0.9.2.
- Parameters:
font –
font_tto work upon
- font_paint_glyph(font: font_t, glyph: int, pfuncs: paint_funcs_t, paint_data: Any, palette_index: int, foreground: int) None#
Paints the glyph.
The painting instructions are returned by way of calls to the callbacks of the
funcsobject, withpaint_datapassed to them.If the font has color palettes (see
ot_color_has_palettes()), thenpalette_indexselects the palette to use. If the font only has one palette, this will be 0.Added in version 7.0.0.
- Parameters:
font –
font_tto work uponglyph – The glyph ID
pfuncs –
paint_funcs_tto paint withpaint_data – User data to pass to paint callbacks
palette_index – The index of the font’s color palette to use
foreground – The foreground color, unpremultipled
- font_set_face(font: font_t, face: face_t) None#
Sets
faceas the font-face value offont.Added in version 1.4.3.
- font_set_funcs(font: font_t, klass: font_funcs_t, font_data: Any = None) None#
Replaces the font-functions structure attached to a font, updating the font’s user-data with
font-data and thedestroycallback.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponklass – The font-functions structure.
font_data – Data to attach to
font
- font_set_funcs_data(font: font_t, font_data: Any = None) None#
Replaces the user data attached to a font, updating the font’s
destroycallback.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponfont_data – Data to attach to
font
- font_set_parent(font: font_t, parent: font_t) None#
Sets the parent font of
font.Added in version 1.0.5.
- Parameters:
font –
font_tto work uponparent – The parent font object to assign
- font_set_ppem(font: font_t, x_ppem: int, y_ppem: int) None#
Sets the horizontal and vertical pixels-per-em (PPEM) of a font.
These values are used for pixel-size-specific adjustment to shaping and draw results, though for the most part they are unused and can be left unset.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponx_ppem – Horizontal ppem value to assign
y_ppem – Vertical ppem value to assign
- font_set_ptem(font: font_t, ptem: float) None#
Sets the “point size” of a font. Set to zero to unset. Used in CoreText to implement optical sizing.
<note>Note: There are 72 points in an inch.</note>
Added in version 1.6.0.
- Parameters:
font –
font_tto work uponptem – font size in points.
- font_set_scale(font: font_t, x_scale: int, y_scale: int) None#
Sets the horizontal and vertical scale of a font.
The font scale is a number related to, but not the same as, font size. Typically the client establishes a scale factor to be used between the two. For example, 64, or 256, which would be the fractional-precision part of the font scale. This is necessary because
position_tvalues are integer types and you need to leave room for fractional values in there.For example, to set the font size to 20, with 64 levels of fractional precision you would call
hb_font_set_scale(font, 20 * 64, 20 * 64).In the example above, even what font size 20 means is up to you. It might be 20 pixels, or 20 points, or 20 millimeters. HarfBuzz does not care about that. You can set the point size of the font using
font_set_ptem(), and the pixel size usingfont_set_ppem().The choice of scale is yours but needs to be consistent between what you set here, and what you expect out of
position_tas well has draw / paint API output values.Fonts default to a scale equal to the UPEM value of their face. A font with this setting is sometimes called an “unscaled” font.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponx_scale – Horizontal scale value to assign
y_scale – Vertical scale value to assign
- font_set_synthetic_bold(font: font_t, x_embolden: float, y_embolden: float, in_place: int) None#
Sets the “synthetic boldness” of a font.
Positive values for
x_embolden/y_emboldenmake a font bolder, negative values thinner. Typical values are in the 0.01 to 0.05 range. The default value is zero.Synthetic boldness is applied by offsetting the contour points of the glyph shape.
Synthetic boldness is applied when rendering a glyph via
font_draw_glyph().If
in_placeisfalse, then glyph advance-widths are also adjusted, otherwise they are not. The in-place mode is useful for simulating font grading.Added in version 7.0.0.
- Parameters:
font –
font_tto work uponx_embolden – the amount to embolden horizontally
y_embolden – the amount to embolden vertically
in_place – whether to embolden glyphs in-place
- font_set_synthetic_slant(font: font_t, slant: float) None#
Sets the “synthetic slant” of a font. By default is zero. Synthetic slant is the graphical skew applied to the font at rendering time.
HarfBuzz needs to know this value to adjust shaping results, metrics, and style values to match the slanted rendering.
<note>Note: The glyph shape fetched via the
font_draw_glyph()function is slanted to reflect this value as well.</note><note>Note: The slant value is a ratio. For example, a 20% slant would be represented as a 0.2 value.</note>
Added in version 3.3.0.
- Parameters:
font –
font_tto work uponslant – synthetic slant value.
- font_set_var_coords_design(font: font_t, coords: list[float]) None#
Applies a list of variation coordinates (in design-space units) to a font.
Note that this overrides all existing variations set on
font. Axes not included incoordswill be effectively set to their default values.Added in version 1.4.2.
- Parameters:
font –
font_tto work uponcoords – Array of variation coordinates to apply
- font_set_var_coords_normalized(font: font_t, coords: list[int]) None#
Applies a list of variation coordinates (in normalized units) to a font.
Note that this overrides all existing variations set on
font. Axes not included incoordswill be effectively set to their default values.<note>Note: Coordinates should be normalized to 2.14.</note>
Added in version 1.4.2.
- Parameters:
font –
font_tto work uponcoords – Array of variation coordinates to apply
- font_set_var_named_instance(font: font_t, instance_index: int) None#
Sets design coords of a font from a named-instance index.
Added in version 2.6.0.
- Parameters:
font – a font.
instance_index – named instance index.
- font_set_variation(font: font_t, tag: int, value: float) None#
Change the value of one variation axis on the font.
- Note: This function is expensive to be called repeatedly.
If you want to set multiple variation axes at the same time, use
font_set_variations()instead.
Added in version 7.1.0.
- Parameters:
font –
font_tto work upontag – The
tag_ttag of the variation-axis namevalue – The value of the variation axis
- font_set_variations(font: font_t, variations: list[variation_t]) None#
Applies a list of font-variation settings to a font.
Note that this overrides all existing variations set on
font. Axes not included invariationswill be effectively set to their default values.Added in version 1.4.2.
- Parameters:
font –
font_tto work uponvariations – Array of variation settings to apply
- font_subtract_glyph_origin_for_direction(font: font_t, glyph: int, direction: direction_t, x: int, y: int) tuple[int, int]#
Subtracts the origin coordinates from an (X,Y) point coordinate, in the specified glyph ID in the specified font.
Calls the appropriate direction-specific variant (horizontal or vertical) depending on the value of
direction.Added in version 0.9.2.
- Parameters:
font –
font_tto work uponglyph – The glyph ID to query
direction – The direction of the text segment
x – Input = The original X coordinate Output = The X coordinate minus the X-coordinate of the origin
y – Input = The original Y coordinate Output = The Y coordinate minus the Y-coordinate of the origin
- ft_face_create(ft_face: Face) face_t#
Creates an
face_tface object from the specified FT_Face.Note that this is using the FT_Face object just to get at the underlying font data, and fonts created from the returned
face_twill use the native HarfBuzz font implementation, unless you callft_font_set_funcs()on them.This variant of the function does not provide any life-cycle management.
Most client programs should use
ft_face_create_referenced()(or, perhaps,ft_face_create_cached()) instead.If you know you have valid reasons not to use
ft_face_create_referenced(), then it is the client program’s responsibility to destroyft_faceafter theface_tface object has been destroyed.Added in version 0.9.2.
- Parameters:
ft_face – FT_Face to work upon
- Returns:
the new
face_tface object
- ft_face_create_cached(ft_face: Face) face_t#
Creates an
face_tface object from the specified FT_Face.Note that this is using the FT_Face object just to get at the underlying font data, and fonts created from the returned
face_twill use the native HarfBuzz font implementation, unless you callft_font_set_funcs()on them.This variant of the function caches the newly created
face_tface object, using thegenericpointer offt_face. Subsequent function calls that are passed the sameft_faceparameter will have the sameface_treturned to them, and thatface_twill be correctly reference counted.However, client programs are still responsible for destroying
ft_faceafter the lastface_tface object has been destroyed.Added in version 0.9.2.
- Parameters:
ft_face – FT_Face to work upon
- Returns:
the new
face_tface object
- ft_face_create_referenced(ft_face: Face) face_t#
Creates an
face_tface object from the specified FT_Face.Note that this is using the FT_Face object just to get at the underlying font data, and fonts created from the returned
face_twill use the native HarfBuzz font implementation, unless you callft_font_set_funcs()on them.This is the preferred variant of the hb_ft_face_create* function family, because it calls FT_Reference_Face() on
ft_face, ensuring thatft_faceremains alive as long as the resultingface_tface object remains alive. Also calls FT_Done_Face() when theface_tface object is destroyed.Use this version unless you know you have good reasons not to.
Added in version 0.9.38.
- Parameters:
ft_face – FT_Face to work upon
- Returns:
the new
face_tface object
- ft_font_changed(font: font_t) None#
Refreshes the state of
fontwhen the underlying FT_Face has changed. This function should be called after changing the size or variation-axis settings on the FT_Face.Added in version 1.0.5.
- Parameters:
font –
font_tto work upon
- ft_font_create(ft_face: Face) font_t#
Creates an
font_tfont object from the specified FT_Face.<note>Note: You must set the face size on
ft_facebefore callingft_font_create()on it. HarfBuzz assumes size is always set and will accesssizemember of FT_Face unconditionally.</note>This variant of the function does not provide any life-cycle management.
Most client programs should use
ft_font_create_referenced()instead.If you know you have valid reasons not to use
ft_font_create_referenced(), then it is the client program’s responsibility to destroyft_faceafter thefont_tfont object has been destroyed.HarfBuzz will use the
destroycallback on thefont_tfont object if it is supplied when you use this function. However, even ifdestroyis provided, it is the client program’s responsibility to destroyft_face, and it is the client program’s responsibility to ensure thatft_faceis destroyed only after thefont_tfont object has been destroyed.Added in version 0.9.2.
- Parameters:
ft_face – FT_Face to work upon
- Returns:
the new
font_tfont object
- ft_font_create_referenced(ft_face: Face) font_t#
Creates an
font_tfont object from the specified FT_Face.<note>Note: You must set the face size on
ft_facebefore callingft_font_create_referenced()on it. HarfBuzz assumes size is always set and will accesssizemember of FT_Face unconditionally.</note>This is the preferred variant of the hb_ft_font_create* function family, because it calls FT_Reference_Face() on
ft_face, ensuring thatft_faceremains alive as long as the resultingfont_tfont object remains alive.Use this version unless you know you have good reasons not to.
Added in version 0.9.38.
- Parameters:
ft_face – FT_Face to work upon
- Returns:
the new
font_tfont object
- ft_font_get_load_flags(font: font_t) int#
Fetches the FT_Load_Glyph load flags of the specified
font_t.For more information, see https://freetype.org/freetype2/docs/reference/ft2-glyph_retrieval.html#ft_load_xxx
This function works with
font_tobjects created byft_font_create()orft_font_create_referenced().Added in version 1.0.5.
- Parameters:
font –
font_tto work upon- Returns:
FT_Load_Glyph flags found, or 0
- ft_font_set_funcs(font: font_t) None#
Configures the font-functions structure of the specified
font_tfont object to use FreeType font functions.In particular, you can use this function to configure an existing
face_tface object for use with FreeType font functions even if thatface_tface object was initially created withface_create(), and therefore was not initially configured to use FreeType font functions.An
font_tobject created withft_font_create()is preconfigured for FreeType font functions and does not require this function to be used.Note that if you modify the underlying
font_tafter calling this function, you need to callft_hb_font_changed()to update the underlying FT_Face.<note>Note: Internally, this function creates an FT_Face. </note>
Added in version 1.0.5.
- Parameters:
font –
font_tto work upon
- ft_font_set_load_flags(font: font_t, load_flags: int) None#
Sets the FT_Load_Glyph load flags for the specified
font_t.For more information, see https://freetype.org/freetype2/docs/reference/ft2-glyph_retrieval.html#ft_load_xxx
This function works with
font_tobjects created byft_font_create()orft_font_create_referenced().Added in version 1.0.5.
- Parameters:
font –
font_tto work uponload_flags – The FreeType load flags to set
- ft_hb_font_changed(font: font_t) int#
Refreshes the state of the underlying FT_Face of
fontwhen the hb_font_tfonthas changed. This function should be called after changing the size or variation-axis settings on thefont. This call is fast if nothing has changed onfont.Added in version 4.4.0.
- Parameters:
font –
font_tto work upon- Returns:
true if changed, false otherwise
- glib_blob_create(gbytes: Bytes) blob_t#
Creates an
blob_tblob from the specified GBytes data structure.Added in version 0.9.38.
- Parameters:
gbytes – the GBytes structure to work upon
- Returns:
the new
blob_tblob object
- glib_get_unicode_funcs() unicode_funcs_t#
Fetches a Unicode-functions structure that is populated with the appropriate GLib function for each method.
Added in version 0.9.38.
- Returns:
a pointer to the
unicode_funcs_tUnicode-functions structure
- glib_script_from_script(script: script_t) UnicodeScript#
Fetches the GUnicodeScript identifier that corresponds to the specified
script_tscript.Added in version 0.9.38.
- Parameters:
script – The
script_tto query- Returns:
the GUnicodeScript identifier found
- glib_script_to_script(script: UnicodeScript) script_t#
Fetches the
script_tscript that corresponds to the specified GUnicodeScript identifier.Added in version 0.9.38.
- Parameters:
script – The GUnicodeScript identifier to query
- Returns:
the
script_tscript found
- glyph_info_get_glyph_flags(info: glyph_info_t) glyph_flags_t#
Returns glyph flags encoded within a
glyph_info_t.Added in version 1.5.0.
- Parameters:
info – a
glyph_info_t- Returns:
The
glyph_flags_tencoded withininfo
- language_from_string(str: list[int]) language_t#
Converts
strrepresenting a BCP 47 language tag to the correspondinglanguage_t.Added in version 0.9.2.
- Parameters:
str – a string representing a BCP 47 language tag
- Returns:
The
language_tcorresponding to the BCP 47 language tag.
- language_get_default() language_t#
Fetch the default language from current locale.
<note>Note that the first time this function is called, it calls “setlocale (LC_CTYPE, nullptr)” to fetch current locale. The underlying setlocale function is, in many implementations, NOT threadsafe. To avoid problems, call this function once before multiple threads can call it. This function is only used from
buffer_guess_segment_properties()by HarfBuzz itself.</note>Added in version 0.9.2.
- Returns:
The default language of the locale as an
language_t
- language_matches(language: language_t, specific: language_t) int#
Check whether a second language tag is the same or a more specific version of the provided language tag. For example, “fa_IR.utf8” is a more specific tag for “fa” or for “fa_IR”.
Added in version 5.0.0.
- Parameters:
language – The
language_tto work onspecific – Another
language_t
- Returns:
trueif languages match,falseotherwise.
- language_to_string(language: language_t) str#
Converts an
language_tto a string.Added in version 0.9.2.
- Parameters:
language – The
language_tto convert- Returns:
A
NULL-terminated string representing thelanguage. Must not be freed by the caller.
- map_allocation_successful(map: map_t) int#
Tests whether memory allocation for a set was successful.
Added in version 1.7.7.
- Parameters:
map – A map
- Returns:
trueif allocation succeeded,falseotherwise
- map_clear(map: map_t) None#
Clears out the contents of
map.Added in version 1.7.7.
- Parameters:
map – A map
- map_create() map_t#
Creates a new, initially empty map.
Added in version 1.7.7.
- Returns:
The new
map_t
- map_del(map: map_t, key: int) None#
Removes
keyand its stored value frommap.Added in version 1.7.7.
- Parameters:
map – A map
key – The key to delete
- map_get(map: map_t, key: int) int#
Fetches the value stored for
keyinmap.Added in version 1.7.7.
- Parameters:
map – A map
key – The key to query
- map_get_empty() map_t#
Fetches the singleton empty
map_t.Added in version 1.7.7.
- Returns:
The empty
map_t
- map_get_population(map: map_t) int#
Returns the number of key-value pairs in the map.
Added in version 1.7.7.
- Parameters:
map – A map
- Returns:
The population of
map
- map_has(map: map_t, key: int) int#
Tests whether
keyis an element ofmap.Added in version 1.7.7.
- Parameters:
map – A map
key – The key to query
- Returns:
trueifkeyis found inmap,falseotherwise
- map_hash(map: map_t) int#
Creates a hash representing
map.Added in version 4.4.0.
- Parameters:
map – A map
- Returns:
A hash of
map.
- map_is_empty(map: map_t) int#
Tests whether
mapis empty (contains no elements).Added in version 1.7.7.
- Parameters:
map – A map
- Returns:
trueifmapis empty
- map_is_equal(map: map_t, other: map_t) int#
Tests whether
mapandotherare equal (contain the same elements).Added in version 4.3.0.
- Parameters:
map – A map
other – Another map
- Returns:
trueif the two maps are equal,falseotherwise.
- map_keys(map: map_t, keys: set_t) None#
Add the keys of
maptokeys.Added in version 7.0.0.
- Parameters:
map – A map
keys – A set
- map_next(map: map_t, idx: int) tuple[int, int, int, int]#
Fetches the next key/value pair in
map.Set
idxto -1 to get started.If the map is modified during iteration, the behavior is undefined.
The order in which the key/values are returned is undefined.
Added in version 7.0.0.
- Parameters:
map – A map
idx – Iterator internal state
- Returns:
trueif there was a next value,falseotherwise
- map_set(map: map_t, key: int, value: int) None#
Stores
key:valuein the map.Added in version 1.7.7.
- Parameters:
map – A map
key – The key to store in the map
value – The value to store for
key
- map_update(map: map_t, other: map_t) None#
Add the contents of
othertomap.Added in version 7.0.0.
- Parameters:
map – A map
other – Another map
- map_values(map: map_t, values: set_t) None#
Add the values of
maptovalues.Added in version 7.0.0.
- Parameters:
map – A map
values – A set
- ot_color_glyph_get_layers(face: face_t, glyph: int, start_offset: int) tuple[int, list[ot_color_layer_t] | None]#
Fetches a list of all color layers for the specified glyph index in the specified face. The list returned will begin at the offset provided.
Added in version 2.1.0.
- Parameters:
face –
face_tto work uponglyph – The glyph index to query
start_offset – offset of the first layer to retrieve
- Returns:
Total number of layers available for the glyph index queried
- ot_color_glyph_has_paint(face: face_t, glyph: int) int#
Tests where a face includes COLRv1 paint data for
glyph.Added in version 7.0.0.
- Parameters:
face –
face_tto work uponglyph – The glyph index to query
- Returns:
trueif data found,falseotherwise
- ot_color_glyph_reference_png(font: font_t, glyph: int) blob_t#
Fetches the PNG image for a glyph. This function takes a font object, not a face object, as input. To get an optimally sized PNG blob, the PPEM values must be set on the
fontobject. If PPEM is unset, the blob returned will be the largest PNG available.If the glyph has no PNG image, the singleton empty blob is returned.
Added in version 2.1.0.
- ot_color_glyph_reference_svg(face: face_t, glyph: int) blob_t#
Fetches the SVG document for a glyph. The blob may be either plain text or gzip-encoded.
If the glyph has no SVG document, the singleton empty blob is returned.
Added in version 2.1.0.
- ot_color_has_layers(face: face_t) int#
Tests whether a face includes a
COLRtable with data according to COLRv0.Added in version 2.1.0.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- ot_color_has_paint(face: face_t) int#
Tests where a face includes a
COLRtable with data according to COLRv1.Added in version 7.0.0.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- ot_color_has_palettes(face: face_t) int#
Tests whether a face includes a
CPALcolor-palette table.Added in version 2.1.0.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- ot_color_has_png(face: face_t) int#
Tests whether a face has PNG glyph images (either in
CBDTorsbixtables).Added in version 2.1.0.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- ot_color_has_svg(face: face_t) int#
Tests whether a face includes any
SVGglyph images.Added in version 2.1.0.
- Parameters:
face –
face_tto work upon.- Returns:
trueif data found,falseotherwise.
- ot_color_palette_color_get_name_id(face: face_t, color_index: int) int#
Fetches the
nametable Name ID that provides display names for the specified color in a face’sCPALcolor palette.Display names can be generic (e.g., “Background”) or specific (e.g., “Eye color”).
Added in version 2.1.0.
- Parameters:
face –
face_tto work uponcolor_index – The index of the color
- Returns:
the Name ID found for the color.
- ot_color_palette_get_colors(face: face_t, palette_index: int, start_offset: int) tuple[int, list[int] | None]#
Fetches a list of the colors in a color palette.
After calling this function,
colorswill be filled with the palette colors. Ifcolorsis NULL, the function will just return the number of total colors without storing any actual colors; this can be used for allocating a buffer of suitable size before callingot_color_palette_get_colors()a second time.The RGBA values in the palette are unpremultiplied. See the OpenType spec CPAL section for details.
Added in version 2.1.0.
- Parameters:
face –
face_tto work uponpalette_index – the index of the color palette to query
start_offset – offset of the first color to retrieve
- Returns:
the total number of colors in the palette
- ot_color_palette_get_count(face: face_t) int#
Fetches the number of color palettes in a face.
Added in version 2.1.0.
- Parameters:
face –
face_tto work upon- Returns:
the number of palettes found
- ot_color_palette_get_flags(face: face_t, palette_index: int) ot_color_palette_flags_t#
Fetches the flags defined for a color palette.
Added in version 2.1.0.
- Parameters:
face –
face_tto work uponpalette_index – The index of the color palette
- Returns:
the
ot_color_palette_flags_tof the requested color palette
- ot_color_palette_get_name_id(face: face_t, palette_index: int) int#
Fetches the
nametable Name ID that provides display names for aCPALcolor palette.Palette display names can be generic (e.g., “Default”) or provide specific, themed names (e.g., “Spring”, “Summer”, “Fall”, and “Winter”).
Added in version 2.1.0.
- Parameters:
face –
face_tto work uponpalette_index – The index of the color palette
- Returns:
the Named ID found for the palette. If the requested palette has no name the result is
HB_OT_NAME_ID_INVALID.
- ot_font_set_funcs(font: font_t) None#
Sets the font functions to use when working with
font.Added in version 0.9.28.
- Parameters:
font –
font_tto work upon
- ot_layout_collect_features(face: face_t, table_tag: int, scripts: list[int] | None = None, languages: list[int] | None = None, features: list[int] | None = None) set_t#
Fetches a list of all feature indexes in the specified face’s GSUB table or GPOS table, underneath the specified scripts, languages, and features. If no list of scripts is provided, all scripts will be queried. If no list of languages is provided, all languages will be queried. If no list of features is provided, all features will be queried.
Added in version 1.8.5.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscripts – The array of scripts to collect features for, terminated by %HB_TAG_NONE
languages – The array of languages to collect features for, terminated by %HB_TAG_NONE
features – The array of features to collect, terminated by %HB_TAG_NONE
- ot_layout_collect_features_map(face: face_t, table_tag: int, script_index: int, language_index: int) map_t#
Fetches the mapping from feature tags to feature indexes for the specified script and language.
Added in version 8.1.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_index – The index of the requested language tag
- ot_layout_collect_lookups(face: face_t, table_tag: int, scripts: list[int] | None = None, languages: list[int] | None = None, features: list[int] | None = None) set_t#
Fetches a list of all feature-lookup indexes in the specified face’s GSUB table or GPOS table, underneath the specified scripts, languages, and features. If no list of scripts is provided, all scripts will be queried. If no list of languages is provided, all languages will be queried. If no list of features is provided, all features will be queried.
Added in version 0.9.8.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscripts – The array of scripts to collect lookups for, terminated by %HB_TAG_NONE
languages – The array of languages to collect lookups for, terminated by %HB_TAG_NONE
features – The array of features to collect lookups for, terminated by %HB_TAG_NONE
- ot_layout_feature_get_characters(face: face_t, table_tag: int, feature_index: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of the characters defined as having a variant under the specified “Character Variant” (“cvXX”) feature tag.
Added in version 2.0.0.
- Parameters:
face –
face_tto work upontable_tag – table tag to query, “GSUB” or “GPOS”.
feature_index – index of feature to query.
start_offset – offset of the first character to retrieve
- Returns:
Number of total sample characters in the cvXX feature.
- ot_layout_feature_get_lookups(face: face_t, table_tag: int, feature_index: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of all lookups enumerated for the specified feature, in the specified face’s GSUB table or GPOS table. The list returned will begin at the offset provided.
Added in version 0.9.7.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSfeature_index – The index of the requested feature
start_offset – offset of the first lookup to retrieve
- Returns:
Total number of lookups.
- ot_layout_feature_get_name_ids(face: face_t, table_tag: int, feature_index: int) tuple[int, int, int, int, int, int]#
Fetches name indices from feature parameters for “Stylistic Set” (‘ssXX’) or “Character Variant” (‘cvXX’) features.
Added in version 2.0.0.
- Parameters:
face –
face_tto work upontable_tag – table tag to query, “GSUB” or “GPOS”.
feature_index – index of feature to query.
- Returns:
trueif data found,falseotherwise
- ot_layout_feature_with_variations_get_lookups(face: face_t, table_tag: int, feature_index: int, variations_index: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of all lookups enumerated for the specified feature, in the specified face’s GSUB table or GPOS table, enabled at the specified variations index. The list returned will begin at the offset provided.
Added in version 1.4.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSfeature_index – The index of the feature to query
variations_index – The index of the feature variation to query
start_offset – offset of the first lookup to retrieve
- Returns:
Total number of lookups.
- ot_layout_get_attach_points(face: face_t, glyph: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of all attachment points for the specified glyph in the GDEF table of the face. The list returned will begin at the offset provided.
Useful if the client program wishes to cache the list.
- Parameters:
face – The
face_tto work onglyph – The
codepoint_tcode point to querystart_offset – offset of the first attachment point to retrieve
- Returns:
Total number of attachment points for
glyph.
- ot_layout_get_baseline(font: font_t, baseline_tag: ot_layout_baseline_tag_t, direction: direction_t, script_tag: int, language_tag: int) tuple[int, int | None]#
Fetches a baseline value from the face.
Added in version 2.6.0.
- Parameters:
font – a font
baseline_tag – a baseline tag
direction – text direction.
script_tag – script tag.
language_tag – language tag, currently unused.
- Returns:
trueif found baseline value in the font.
- ot_layout_get_baseline2(font: font_t, baseline_tag: ot_layout_baseline_tag_t, direction: direction_t, script: script_t, language: language_t | None = None) tuple[int, int | None]#
Fetches a baseline value from the face.
This function is like
ot_layout_get_baseline()but takesscript_tandlanguage_tinstead of OpenTypetag_t.Added in version 8.0.0.
- Parameters:
font – a font
baseline_tag – a baseline tag
direction – text direction.
script – script.
language – language, currently unused.
- Returns:
trueif found baseline value in the font.
- ot_layout_get_baseline_with_fallback(font: font_t, baseline_tag: ot_layout_baseline_tag_t, direction: direction_t, script_tag: int, language_tag: int) int#
Fetches a baseline value from the face, and synthesizes it if the font does not have it.
Added in version 4.0.0.
- Parameters:
font – a font
baseline_tag – a baseline tag
direction – text direction.
script_tag – script tag.
language_tag – language tag, currently unused.
- ot_layout_get_baseline_with_fallback2(font: font_t, baseline_tag: ot_layout_baseline_tag_t, direction: direction_t, script: script_t, language: language_t | None = None) int#
Fetches a baseline value from the face, and synthesizes it if the font does not have it.
This function is like
ot_layout_get_baseline_with_fallback()but takesscript_tandlanguage_tinstead of OpenTypetag_t.Added in version 8.0.0.
- Parameters:
font – a font
baseline_tag – a baseline tag
direction – text direction.
script – script.
language – language, currently unused.
- ot_layout_get_font_extents(font: font_t, direction: direction_t, script_tag: int, language_tag: int) tuple[int, font_extents_t | None]#
Fetches script/language-specific font extents. These values are looked up in the
BASEtable’sMinMaxrecords.If no such extents are found, the default extents for the font are fetched. As such, the return value of this function can for the most part be ignored. Note that the per-script/language extents do not have a line-gap value, and the line-gap is set to zero in that case.
Added in version 8.0.0.
- Parameters:
font – a font
direction – text direction.
script_tag – script tag.
language_tag – language tag.
- Returns:
trueif found script/language-specific font extents.
- ot_layout_get_font_extents2(font: font_t, direction: direction_t, script: script_t, language: language_t | None = None) tuple[int, font_extents_t | None]#
Fetches script/language-specific font extents. These values are looked up in the
BASEtable’sMinMaxrecords.If no such extents are found, the default extents for the font are fetched. As such, the return value of this function can for the most part be ignored. Note that the per-script/language extents do not have a line-gap value, and the line-gap is set to zero in that case.
This function is like
ot_layout_get_font_extents()but takesscript_tandlanguage_tinstead of OpenTypetag_t.Added in version 8.0.0.
- Parameters:
font – a font
direction – text direction.
script – script.
language – language.
- Returns:
trueif found script/language-specific font extents.
- ot_layout_get_glyph_class(face: face_t, glyph: int) ot_layout_glyph_class_t#
Fetches the GDEF class of the requested glyph in the specified face.
Added in version 0.9.7.
- Parameters:
face – The
face_tto work onglyph – The
codepoint_tcode point to query
- Returns:
The
ot_layout_glyph_class_tglyph class of the given code point in the GDEF table of the face.
- ot_layout_get_glyphs_in_class(face: face_t, klass: ot_layout_glyph_class_t) set_t#
Retrieves the set of all glyphs from the face that belong to the requested glyph class in the face’s GDEF table.
Added in version 0.9.7.
- Parameters:
face – The
face_tto work onklass – The
ot_layout_glyph_class_tGDEF class to retrieve
- ot_layout_get_horizontal_baseline_tag_for_script(script: script_t) ot_layout_baseline_tag_t#
Fetches the dominant horizontal baseline tag used by
script.Added in version 4.0.0.
- Parameters:
script – a script tag.
- Returns:
dominant baseline tag for the
script.
- ot_layout_get_ligature_carets(font: font_t, direction: direction_t, glyph: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of the caret positions defined for a ligature glyph in the GDEF table of the font. The list returned will begin at the offset provided.
Note that a ligature that is formed from n characters will have n-1 caret positions. The first character is not represented in the array, since its caret position is the glyph position.
The positions returned by this function are ‘unshaped’, and will have to be fixed up for kerning that may be applied to the ligature glyph.
- Parameters:
font – The
font_tto work ondirection – The
direction_ttext direction to useglyph – The
codepoint_tcode point to querystart_offset – offset of the first caret position to retrieve
- Returns:
Total number of ligature caret positions for
glyph.
- ot_layout_get_size_params(face: face_t) tuple[int, int, int, int, int, int]#
Fetches optical-size feature data (i.e., the
sizefeature from GPOS). Note that the subfamily_id and the subfamily name string (accessible via the subfamily_name_id) as used here are defined as pertaining only to fonts within a font family that differ specifically in their respective size ranges; other ways to differentiate fonts within a subfamily are not covered by thesizefeature.For more information on this distinction, see the
`sizefeature documentation <https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#tag-size>`__.Added in version 0.9.10.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- ot_layout_has_glyph_classes(face: face_t) int#
Tests whether a face has any glyph classes defined in its GDEF table.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- ot_layout_has_positioning(face: face_t) int#
Tests whether the specified face includes any GPOS positioning.
- Parameters:
face –
face_tto work upon- Returns:
trueif the face has GPOS data,falseotherwise
- ot_layout_has_substitution(face: face_t) int#
Tests whether the specified face includes any GSUB substitutions.
Added in version 0.6.0.
- Parameters:
face –
face_tto work upon- Returns:
trueif data found,falseotherwise
- ot_layout_language_find_feature(face: face_t, table_tag: int, script_index: int, language_index: int, feature_tag: int) tuple[int, int]#
Fetches the index of a given feature tag in the specified face’s GSUB table or GPOS table, underneath the specified script and language.
Added in version 0.6.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_index – The index of the requested language tag
feature_tag –
tag_tof the feature tag requested
- Returns:
trueif the feature is found,falseotherwise
- ot_layout_language_get_feature_indexes(face: face_t, table_tag: int, script_index: int, language_index: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of all features in the specified face’s GSUB table or GPOS table, underneath the specified script and language. The list returned will begin at the offset provided.
Added in version 0.6.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_index – The index of the requested language tag
start_offset – offset of the first feature tag to retrieve
- Returns:
Total number of features.
- ot_layout_language_get_feature_tags(face: face_t, table_tag: int, script_index: int, language_index: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of all features in the specified face’s GSUB table or GPOS table, underneath the specified script and language. The list returned will begin at the offset provided.
Added in version 0.6.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_index – The index of the requested language tag
start_offset – offset of the first feature tag to retrieve
- Returns:
Total number of feature tags.
- ot_layout_language_get_required_feature(face: face_t, table_tag: int, script_index: int, language_index: int) tuple[int, int, int]#
Fetches the tag of a requested feature index in the given face’s GSUB or GPOS table, underneath the specified script and language.
Added in version 0.9.30.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_index – The index of the requested language tag
- Returns:
trueif the feature is found,falseotherwise
- ot_layout_language_get_required_feature_index(face: face_t, table_tag: int, script_index: int, language_index: int) tuple[int, int]#
Fetches the index of a requested feature in the given face’s GSUB or GPOS table, underneath the specified script and language.
Added in version 0.6.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_index – The index of the requested language tag
- Returns:
trueif the feature is found,falseotherwise
- ot_layout_lookup_collect_glyphs(face: face_t, table_tag: int, lookup_index: int) tuple[set_t, set_t, set_t, set_t]#
Fetches a list of all glyphs affected by the specified lookup in the specified face’s GSUB table or GPOS table.
Added in version 0.9.7.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSlookup_index – The index of the feature lookup to query
- ot_layout_lookup_get_glyph_alternates(face: face_t, lookup_index: int, glyph: int, start_offset: int) tuple[int, list[int]]#
Fetches alternates of a glyph from a given GSUB lookup index.
Added in version 2.6.8.
- Parameters:
face – a face.
lookup_index – index of the feature lookup to query.
glyph – a glyph id.
start_offset – starting offset.
- Returns:
Total number of alternates found in the specific lookup index for the given glyph id.
- ot_layout_lookup_get_optical_bound(font: font_t, lookup_index: int, direction: direction_t, glyph: int) int#
Fetches the optical bound of a glyph positioned at the margin of text. The direction identifies which edge of the glyph to query.
Added in version 5.3.0.
- Parameters:
font – a font.
lookup_index – index of the feature lookup to query.
direction – edge of the glyph to query.
glyph – a glyph id.
- Returns:
Adjustment value. Negative values mean the glyph will stick out of the margin.
- ot_layout_lookup_substitute_closure(face: face_t, lookup_index: int) set_t#
Compute the transitive closure of glyphs needed for a specified lookup.
Added in version 0.9.7.
- Parameters:
face –
face_tto work uponlookup_index – index of the feature lookup to query
- ot_layout_lookup_would_substitute(face: face_t, lookup_index: int, glyphs: int, glyphs_length: int, zero_context: int) int#
Tests whether a specified lookup in the specified face would trigger a substitution on the given glyph sequence.
Added in version 0.9.7.
- Parameters:
face –
face_tto work uponlookup_index – The index of the lookup to query
glyphs – The sequence of glyphs to query for substitution
glyphs_length – The length of the glyph sequence
zero_context –
bool_tindicating whether pre-/post-context are disallowed in substitutions
- Returns:
trueif a substitution would be triggered,falseotherwise
- ot_layout_lookups_substitute_closure(face: face_t, lookups: set_t) set_t#
Compute the transitive closure of glyphs needed for all of the provided lookups.
Added in version 1.8.1.
- Parameters:
face –
face_tto work uponlookups – The set of lookups to query
- ot_layout_script_find_language(face: face_t, table_tag: int, script_index: int, language_tag: int, language_index: int) int#
Fetches the index of a given language tag in the specified face’s GSUB table or GPOS table, underneath the specified script tag.
Added in version 0.6.0.
Deprecated since version 2.0.0: Please do not use it in newly written code
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_tag – The
tag_tof the requested languagelanguage_index – The index of the requested language
- Returns:
trueif the language tag is found,falseotherwise
- ot_layout_script_get_language_tags(face: face_t, table_tag: int, script_index: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of language tags in the given face’s GSUB or GPOS table, underneath the specified script index. The list returned will begin at the offset provided.
Added in version 0.6.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
start_offset – offset of the first language tag to retrieve
- Returns:
Total number of language tags.
- ot_layout_script_select_language(face: face_t, table_tag: int, script_index: int, language_count: int, language_tags: int) tuple[int, int]#
Fetches the index of the first language tag fom
language_tagsthat is present in the specified face’s GSUB or GPOS table, underneath the specified script index.If none of the given language tags is found,
falseis returned andlanguage_indexis set to the default language index.Added in version 2.0.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_count – The number of languages in the specified script
language_tags – The array of language tags
- Returns:
trueif one of the given language tags is found,falseotherwise
- ot_layout_script_select_language2(face: face_t, table_tag: int, script_index: int, language_count: int, language_tags: int) tuple[int, int, int]#
Fetches the index of the first language tag fom
language_tagsthat is present in the specified face’s GSUB or GPOS table, underneath the specified script index.If none of the given language tags is found,
falseis returned andlanguage_indexis set toHB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEXandchosen_languageis set toHB_TAG_NONE.Added in version 7.0.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_index – The index of the requested script tag
language_count – The number of languages in the specified script
language_tags – The array of language tags
- Returns:
trueif one of the given language tags is found,falseotherwise
- ot_layout_table_choose_script(face: face_t, table_tag: int, script_tags: int) tuple[int, int, int]#
Deprecated since 2.0.0
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_tags – Array of
tag_tscript tags
- ot_layout_table_find_feature_variations(face: face_t, table_tag: int, coords: int, num_coords: int) tuple[int, int]#
Fetches a list of feature variations in the specified face’s GSUB table or GPOS table, at the specified variation coordinates.
Added in version 1.4.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOScoords – The variation coordinates to query
num_coords – The number of variation coordinates
- Returns:
trueif feature variations were found,falseotherwise.
- ot_layout_table_find_script(face: face_t, table_tag: int, script_tag: int) tuple[int, int]#
Fetches the index if a given script tag in the specified face’s GSUB table or GPOS table.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_tag –
tag_tof the script tag requested
- Returns:
trueif the script is found,falseotherwise
- ot_layout_table_get_feature_tags(face: face_t, table_tag: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of all feature tags in the given face’s GSUB or GPOS table. Note that there might be duplicate feature tags, belonging to different script/language-system pairs of the table.
Added in version 0.6.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSstart_offset – offset of the first feature tag to retrieve
- Returns:
Total number of feature tags.
- ot_layout_table_get_lookup_count(face: face_t, table_tag: int) int#
Fetches the total number of lookups enumerated in the specified face’s GSUB table or GPOS table.
Added in version 0.9.22.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOS
- Returns:
Total number of lookups.
- ot_layout_table_get_script_tags(face: face_t, table_tag: int, start_offset: int) tuple[int, list[int]]#
Fetches a list of all scripts enumerated in the specified face’s GSUB table or GPOS table. The list returned will begin at the offset provided.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSstart_offset – offset of the first script tag to retrieve
- Returns:
Total number of script tags.
- ot_layout_table_select_script(face: face_t, table_tag: int, script_count: int, script_tags: int) tuple[int, int, int]#
Selects an OpenType script for
table_tagfrom thescript_tagsarray.If the table does not have any of the requested scripts, then
DFLT,dflt, andlatntags are tried in that order. If the table still does not have any of these scripts,script_indexis set toHB_OT_LAYOUT_NO_SCRIPT_INDEXandchosen_scriptis set toHB_TAG_NONE.Added in version 2.0.0.
- Parameters:
face –
face_tto work upontable_tag –
HB_OT_TAG_GSUBorHB_OT_TAG_GPOSscript_count – Number of script tags in the array
script_tags – Array of
tag_tscript tags
- Returns:
trueif one of the requested scripts is selected,falseif a fallback script is selected or if no scripts are selected.
- ot_math_get_constant(font: font_t, constant: ot_math_constant_t) int#
Fetches the specified math constant. For most constants, the value returned is an
position_t.However, if the requested constant is
HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN,HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWNorHB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT, then the return value is an integer between 0 and 100 representing that percentage.Added in version 1.3.3.
- Parameters:
font –
font_tto work uponconstant –
ot_math_constant_tthe constant to retrieve
- Returns:
the requested constant or zero
- ot_math_get_glyph_assembly(font: font_t, glyph: int, direction: direction_t, start_offset: int) tuple[int, list[ot_math_glyph_part_t], int]#
Fetches the GlyphAssembly for the specified font, glyph index, and direction. Returned are a list of
ot_math_glyph_part_tglyph parts that can be used to draw the glyph and an italics-correction value (if one is defined in the font).<note>The
directionparameter is only used to select between horizontal or vertical directions for the construction. Even though alldirection_tvalues are accepted, only the result ofHB_DIRECTION_IS_HORIZONTALis considered.</note>Added in version 1.3.3.
- Parameters:
font –
font_tto work uponglyph – The index of the glyph to stretch
direction – direction of the stretching (horizontal or vertical)
start_offset – offset of the first glyph part to retrieve
- Returns:
the total number of parts in the glyph assembly
- ot_math_get_glyph_italics_correction(font: font_t, glyph: int) int#
Fetches an italics-correction value (if one exists) for the specified glyph index.
Added in version 1.3.3.
- Parameters:
font –
font_tto work uponglyph – The glyph index from which to retrieve the value
- Returns:
the italics correction of the glyph or zero
- ot_math_get_glyph_kerning(font: font_t, glyph: int, kern: ot_math_kern_t, correction_height: int) int#
Fetches the math kerning (cut-ins) value for the specified font, glyph index, and
kern.If the MathKern table is found, the function examines it to find a height value that is greater or equal to
correction_height. If such a height value is found, corresponding kerning value from the table is returned. If no such height value is found, the last kerning value is returned.Added in version 1.3.3.
- Parameters:
font –
font_tto work uponglyph – The glyph index from which to retrieve the value
kern – The
ot_math_kern_tfrom which to retrieve the valuecorrection_height – the correction height to use to determine the kerning.
- Returns:
requested kerning value or zero
- ot_math_get_glyph_kernings(font: font_t, glyph: int, kern: ot_math_kern_t, start_offset: int) tuple[int, list[ot_math_kern_entry_t]]#
Fetches the raw MathKern (cut-in) data for the specified font, glyph index, and
kern. The corresponding list of kern values and correction heights is returned as a list ofot_math_kern_entry_tstructs.See also
hb_ot_math_get_glyph_kerning, which handles selecting the appropriate kern value for a given correction height.<note>For a glyph with
ndefined kern values (wheren> 0), there are onlyn−1 defined correction heights, as each correction height defines a boundary past which the next kern value should be selected. Therefore, only theot_math_kern_entry_t.kern_value of the uppermostot_math_kern_entry_tactually comes from the font; its correspondingot_math_kern_entry_t.max_correction_height is always set to <code>INT32_MAX</code>.</note>Added in version 3.4.0.
- Parameters:
font –
font_tto work uponglyph – The glyph index from which to retrieve the kernings
kern – The
ot_math_kern_tfrom which to retrieve the kerningsstart_offset – offset of the first kern entry to retrieve
- Returns:
the total number of kern values available or zero
- ot_math_get_glyph_top_accent_attachment(font: font_t, glyph: int) int#
Fetches a top-accent-attachment value (if one exists) for the specified glyph index.
For any glyph that does not have a top-accent-attachment value - that is, a glyph not covered by the
MathTopAccentAttachmenttable (or, whenfonthas noMathTopAccentAttachmenttable or noMATHtable, any glyph) - the function synthesizes a value, returning the position at one-half the glyph’s advance width.Added in version 1.3.3.
- Parameters:
font –
font_tto work uponglyph – The glyph index from which to retrieve the value
- Returns:
the top accent attachment of the glyph or 0.5 * the advance width of
glyph
- ot_math_get_glyph_variants(font: font_t, glyph: int, direction: direction_t, start_offset: int) tuple[int, list[ot_math_glyph_variant_t]]#
Fetches the MathGlyphConstruction for the specified font, glyph index, and direction. The corresponding list of size variants is returned as a list of
ot_math_glyph_variant_tstructs.<note>The
directionparameter is only used to select between horizontal or vertical directions for the construction. Even though alldirection_tvalues are accepted, only the result ofHB_DIRECTION_IS_HORIZONTALis considered.</note>Added in version 1.3.3.
- Parameters:
font –
font_tto work uponglyph – The index of the glyph to stretch
direction – The direction of the stretching (horizontal or vertical)
start_offset – offset of the first variant to retrieve
- Returns:
the total number of size variants available or zero
- ot_math_get_min_connector_overlap(font: font_t, direction: direction_t) int#
Fetches the MathVariants table for the specified font and returns the minimum overlap of connecting glyphs that are required to draw a glyph assembly in the specified direction.
<note>The
directionparameter is only used to select between horizontal or vertical directions for the construction. Even though alldirection_tvalues are accepted, only the result ofHB_DIRECTION_IS_HORIZONTALis considered.</note>Added in version 1.3.3.
- Parameters:
font –
font_tto work upondirection – direction of the stretching (horizontal or vertical)
- Returns:
requested minimum connector overlap or zero
- ot_math_has_data(face: face_t) int#
Tests whether a face has a
MATHtable.Added in version 1.3.3.
- Parameters:
face –
face_tto test- Returns:
trueif the table is found,falseotherwise
- ot_math_is_glyph_extended_shape(face: face_t, glyph: int) int#
Tests whether the given glyph index is an extended shape in the face.
Added in version 1.3.3.
- Parameters:
face –
face_tto work uponglyph – The glyph index to test
- Returns:
trueif the glyph is an extended shape,falseotherwise
- ot_meta_get_entry_tags(face: face_t, start_offset: int) tuple[int, list[ot_meta_tag_t]]#
Fetches all available feature types.
Added in version 2.6.0.
- Parameters:
face – a face object
start_offset – iteration’s start offset
- Returns:
Number of all available feature types.
- ot_meta_reference_entry(face: face_t, meta_tag: ot_meta_tag_t) blob_t#
It fetches metadata entry of a given tag from a font.
Added in version 2.6.0.
- Parameters:
face – a
face_tobject.meta_tag – tag of metadata you like to have.
- Returns:
A blob containing the blob.
- ot_metrics_get_position(font: font_t, metrics_tag: ot_metrics_tag_t) tuple[int, int]#
Fetches metrics value corresponding to
metrics_tagfromfont.Added in version 2.6.0.
- Parameters:
font – an
font_tobject.metrics_tag – tag of metrics value you like to fetch.
- Returns:
Whether found the requested metrics in the font.
- ot_metrics_get_position_with_fallback(font: font_t, metrics_tag: ot_metrics_tag_t) int#
Fetches metrics value corresponding to
metrics_tagfromfont, and synthesizes a value if it the value is missing in the font.Added in version 4.0.0.
- Parameters:
font – an
font_tobject.metrics_tag – tag of metrics value you like to fetch.
- ot_metrics_get_variation(font: font_t, metrics_tag: ot_metrics_tag_t) float#
Fetches metrics value corresponding to
metrics_tagfromfontwith the current font variation settings applied.Added in version 2.6.0.
- Parameters:
font – an
font_tobject.metrics_tag – tag of metrics value you like to fetch.
- Returns:
The requested metric value.
- ot_metrics_get_x_variation(font: font_t, metrics_tag: ot_metrics_tag_t) int#
Fetches horizontal metrics value corresponding to
metrics_tagfromfontwith the current font variation settings applied.Added in version 2.6.0.
- Parameters:
font – an
font_tobject.metrics_tag – tag of metrics value you like to fetch.
- Returns:
The requested metric value.
- ot_metrics_get_y_variation(font: font_t, metrics_tag: ot_metrics_tag_t) int#
Fetches vertical metrics value corresponding to
metrics_tagfromfontwith the current font variation settings applied.Added in version 2.6.0.
- Parameters:
font – an
font_tobject.metrics_tag – tag of metrics value you like to fetch.
- Returns:
The requested metric value.
- ot_name_get_utf16(face: face_t, name_id: int, language: language_t) tuple[int, list[int]]#
Fetches a font name from the OpenType ‘name’ table. If
languageisHB_LANGUAGE_INVALID, English (“en”) is assumed. Returns string in UTF-16 encoding. A NUL terminator is always written for convenience, and isn’t included in the outputtext_size.Added in version 2.1.0.
- Parameters:
face – font face.
name_id – OpenType name identifier to fetch.
language – language to fetch the name for.
- Returns:
full length of the requested string, or 0 if not found.
- ot_name_get_utf32(face: face_t, name_id: int, language: language_t) tuple[int, list[int]]#
Fetches a font name from the OpenType ‘name’ table. If
languageisHB_LANGUAGE_INVALID, English (“en”) is assumed. Returns string in UTF-32 encoding. A NUL terminator is always written for convenience, and isn’t included in the outputtext_size.Added in version 2.1.0.
- Parameters:
face – font face.
name_id – OpenType name identifier to fetch.
language – language to fetch the name for.
- Returns:
full length of the requested string, or 0 if not found.
- ot_name_get_utf8(face: face_t, name_id: int, language: language_t) tuple[int, list[str]]#
Fetches a font name from the OpenType ‘name’ table. If
languageisHB_LANGUAGE_INVALID, English (“en”) is assumed. Returns string in UTF-8 encoding. A NUL terminator is always written for convenience, and isn’t included in the outputtext_size.Added in version 2.1.0.
- Parameters:
face – font face.
name_id – OpenType name identifier to fetch.
language – language to fetch the name for.
- Returns:
full length of the requested string, or 0 if not found.
- ot_name_list_names(face: face_t) list[ot_name_entry_t]#
Enumerates all available name IDs and language combinations. Returned array is owned by the
faceand should not be modified. It can be used as long asfaceis alive.Added in version 2.1.0.
- Parameters:
face – font face.
- Returns:
Array of available name entries.
- ot_shape_glyphs_closure(font: font_t, buffer: buffer_t, features: list[feature_t]) set_t#
Computes the transitive closure of glyphs needed for a specified input buffer under the given font and feature list. The closure is computed as a set, not as a list.
Added in version 0.9.2.
- Parameters:
font –
font_tto work uponbuffer – The input buffer to compute from
features – The features enabled on the buffer
- ot_shape_plan_collect_lookups(shape_plan: shape_plan_t, table_tag: int) set_t#
Computes the complete set of GSUB or GPOS lookups that are applicable under a given
shape_plan.Added in version 0.9.7.
- Parameters:
shape_plan –
shape_plan_tto querytable_tag – GSUB or GPOS
- ot_tag_from_language(language: language_t) int#
Converts an
language_tto antag_t.Added in version 0.6.0.
Deprecated since version 2.0.0: use
ot_tags_from_script_and_language()instead- Parameters:
language – an
language_tto convert.
- ot_tag_to_language(tag: int) language_t | None#
Converts a language tag to an
language_t.Added in version 0.9.2.
- Parameters:
tag – an language tag
- Returns:
The
language_tcorresponding totag.
- ot_tag_to_script(tag: int) script_t#
Converts a script tag to an
script_t.- Parameters:
tag – a script tag
- Returns:
The
script_tcorresponding totag.
- ot_tags_from_script(script: script_t) tuple[int, int]#
Converts an
script_tto script tags.Added in version 0.6.0.
Deprecated since version 2.0.0: use
ot_tags_from_script_and_language()instead- Parameters:
script – an
script_tto convert.
- ot_tags_from_script_and_language(script: script_t, language: language_t | None = None, script_count: int = Ellipsis, language_count: int = Ellipsis) tuple[int, int, int, int]#
Converts an
script_tand anlanguage_tto script and language tags.Added in version 2.0.0.
- Parameters:
script – an
script_tto convert.language – an
language_tto convert.script_count – maximum number of script tags to retrieve (IN) and actual number of script tags retrieved (OUT)
language_count – maximum number of language tags to retrieve (IN) and actual number of language tags retrieved (OUT)
- ot_tags_to_script_and_language(script_tag: int, language_tag: int) tuple[script_t, language_t]#
Converts a script tag and a language tag to an
script_tand anlanguage_t.Added in version 2.0.0.
- Parameters:
script_tag – a script tag
language_tag – a language tag
- ot_var_find_axis(face: face_t, axis_tag: int, axis_index: int) tuple[int, ot_var_axis_t]#
Fetches the variation-axis information corresponding to the specified axis tag in the specified face.
Added in version 1.4.2.
Deprecated since version 2.2.0: - use
ot_var_find_axis_info()instead- Parameters:
face –
face_tto work uponaxis_tag – The
tag_tof the variation axis to queryaxis_index – The index of the variation axis
- ot_var_find_axis_info(face: face_t, axis_tag: int) tuple[int, ot_var_axis_info_t]#
Fetches the variation-axis information corresponding to the specified axis tag in the specified face.
Added in version 2.2.0.
- Parameters:
face –
face_tto work uponaxis_tag – The
tag_tof the variation axis to query
- Returns:
trueif data found,falseotherwise
- ot_var_get_axes(face: face_t, start_offset: int) tuple[int, list[ot_var_axis_t]]#
Fetches a list of all variation axes in the specified face. The list returned will begin at the offset provided.
Added in version 1.4.2.
Deprecated since version 2.2.0: use
ot_var_get_axis_infos()instead- Parameters:
face –
face_tto work uponstart_offset – offset of the first lookup to retrieve
- ot_var_get_axis_count(face: face_t) int#
Fetches the number of OpenType variation axes included in the face.
Added in version 1.4.2.
- Parameters:
face – The
face_tto work on- Returns:
the number of variation axes defined
- ot_var_get_axis_infos(face: face_t, start_offset: int) tuple[int, list[ot_var_axis_info_t]]#
Fetches a list of all variation axes in the specified face. The list returned will begin at the offset provided.
Added in version 2.2.0.
- Parameters:
face –
face_tto work uponstart_offset – offset of the first lookup to retrieve
- Returns:
the number of variation axes in the face
- ot_var_get_named_instance_count(face: face_t) int#
Fetches the number of named instances included in the face.
Added in version 2.2.0.
- Parameters:
face – The
face_tto work on- Returns:
the number of named instances defined
- ot_var_has_data(face: face_t) int#
Tests whether a face includes any OpenType variation data in the
fvartable.Added in version 1.4.2.
- Parameters:
face – The
face_tto work on- Returns:
trueif data found,falseotherwise
- ot_var_named_instance_get_design_coords(face: face_t, instance_index: int) tuple[int, list[float]]#
Fetches the design-space coordinates corresponding to the given named instance in the face.
Added in version 2.2.0.
- Parameters:
face – The
face_tto work oninstance_index – The index of the named instance to query
- Returns:
the number of variation axes in the face
- ot_var_named_instance_get_postscript_name_id(face: face_t, instance_index: int) int#
Fetches the
nametable Name ID that provides display names for the “PostScript name” defined for the given named instance in the face.Added in version 2.2.0.
- Parameters:
face – The
face_tto work oninstance_index – The index of the named instance to query
- Returns:
the Name ID found for the PostScript name
- ot_var_named_instance_get_subfamily_name_id(face: face_t, instance_index: int) int#
Fetches the
nametable Name ID that provides display names for the “Subfamily name” defined for the given named instance in the face.Added in version 2.2.0.
- Parameters:
face – The
face_tto work oninstance_index – The index of the named instance to query
- Returns:
the Name ID found for the Subfamily name
- ot_var_normalize_coords(face: face_t, coords_length: int, design_coords: float) int#
Normalizes the given design-space coordinates. The minimum and maximum values for the axis are mapped to the interval [-1,1], with the default axis value mapped to 0.
The normalized values have 14 bits of fixed-point sub-integer precision as per OpenType specification.
Any additional scaling defined in the face’s
avartable is also applied, as described at https://docs.microsoft.com/en-us/typography/opentype/spec/avarAdded in version 1.4.2.
- Parameters:
face – The
face_tto work oncoords_length – The length of the coordinate array
design_coords – The design-space coordinates to normalize
- ot_var_normalize_variations(face: face_t, variations: variation_t, variations_length: int) list[int]#
Normalizes all of the coordinates in the given list of variation axes.
Added in version 1.4.2.
- Parameters:
face – The
face_tto work onvariations – The array of variations to normalize
variations_length – The number of variations to normalize
- paint_color(funcs: paint_funcs_t, paint_data: Any, is_foreground: int, color: int) None#
Perform a “color” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
is_foreground – whether the color is the foreground
color – The color to use
- paint_color_glyph(funcs: paint_funcs_t, paint_data: Any, glyph: int, font: font_t) int#
Perform a “color-glyph” paint operation.
Added in version 8.2.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
glyph – the glyph ID
font – the font
- paint_custom_palette_color(funcs: paint_funcs_t, paint_data: Any, color_index: int) tuple[int, int]#
Gets the custom palette color for
color_index.Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
color_index – color index
- Returns:
trueif found,falseotherwise
- paint_funcs_create() paint_funcs_t#
Creates a new
paint_funcs_tstructure of paint functions.The initial reference count of 1 should be released with
paint_funcs_destroy()when you are done using thepaint_funcs_t. This function never returnsNULL. If memory cannot be allocated, a special singletonpaint_funcs_tobject will be returned.Added in version 7.0.0.
- Returns:
the paint-functions structure
- paint_funcs_get_empty() paint_funcs_t#
Fetches the singleton empty paint-functions structure.
Added in version 7.0.0.
- Returns:
The empty paint-functions structure
- paint_funcs_is_immutable(funcs: paint_funcs_t) int#
Tests whether a paint-functions structure is immutable.
Added in version 7.0.0.
- Parameters:
funcs – The paint-functions structure
- Returns:
trueiffuncsis immutable,falseotherwise
- paint_funcs_make_immutable(funcs: paint_funcs_t) None#
Makes a paint-functions structure immutable.
After this call, all attempts to set one of the callbacks on
funcswill fail.Added in version 7.0.0.
- Parameters:
funcs – The paint-functions structure
- paint_funcs_set_color_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, int, int, Any], None], user_data: Any = None) None#
Sets the paint-color callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The paint-color callback
user_data – Data to pass to
func
- paint_funcs_set_color_glyph_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, int, font_t, Any], int], user_data: Any = None) None#
Sets the color-glyph callback on the paint functions struct.
Added in version 8.2.0.
- Parameters:
funcs – A paint functions struct
func – The color-glyph callback
user_data – Data to pass to
func
- paint_funcs_set_custom_palette_color_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, int, Any], tuple[int, int]], user_data: Any = None) None#
Sets the custom-palette-color callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The custom-palette-color callback
user_data – Data to pass to
func
- paint_funcs_set_image_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, blob_t, int, int, int, float, glyph_extents_t | None, Any], int], user_data: Any = None) None#
Sets the paint-image callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The paint-image callback
user_data – Data to pass to
func
- paint_funcs_set_linear_gradient_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, color_line_t, float, float, float, float, float, float, Any], None], user_data: Any = None) None#
Sets the linear-gradient callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The linear-gradient callback
user_data – Data to pass to
func
- paint_funcs_set_pop_clip_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, Any], None], user_data: Any = None) None#
Sets the pop-clip callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The pop-clip callback
user_data – Data to pass to
func
- paint_funcs_set_pop_group_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, paint_composite_mode_t, Any], None], user_data: Any = None) None#
Sets the pop-group callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The pop-group callback
user_data – Data to pass to
func
- paint_funcs_set_pop_transform_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, Any], None], user_data: Any = None) None#
Sets the pop-transform callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The pop-transform callback
user_data – Data to pass to
func
- paint_funcs_set_push_clip_glyph_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, int, font_t, Any], None], user_data: Any = None) None#
Sets the push-clip-glyph callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The push-clip-glyph callback
user_data – Data to pass to
func
- paint_funcs_set_push_clip_rectangle_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, float, float, float, float, Any], None], user_data: Any = None) None#
Sets the push-clip-rect callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The push-clip-rectangle callback
user_data – Data to pass to
func
- paint_funcs_set_push_group_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, Any], None], user_data: Any = None) None#
Sets the push-group callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The push-group callback
user_data – Data to pass to
func
- paint_funcs_set_push_transform_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, float, float, float, float, float, float, Any], None], user_data: Any = None) None#
Sets the push-transform callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The push-transform callback
user_data – Data to pass to
func
- paint_funcs_set_radial_gradient_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, color_line_t, float, float, float, float, float, float, Any], None], user_data: Any = None) None#
Sets the radial-gradient callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The radial-gradient callback
user_data – Data to pass to
func
- paint_funcs_set_sweep_gradient_func(funcs: paint_funcs_t, func: Callable[[paint_funcs_t, Any, color_line_t, float, float, float, float, Any], None], user_data: Any = None) None#
Sets the sweep-gradient callback on the paint functions struct.
Added in version 7.0.0.
- Parameters:
funcs – A paint functions struct
func – The sweep-gradient callback
user_data – Data to pass to
func
- paint_image(funcs: paint_funcs_t, paint_data: Any, image: blob_t, width: int, height: int, format: int, slant: float, extents: glyph_extents_t | None = None) None#
Perform a “image” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
image – image data
width – width of the raster image in pixels, or 0
height – height of the raster image in pixels, or 0
format – the image format as a tag
slant – the synthetic slant ratio to be applied to the image during rendering
extents – the extents of the glyph
- paint_linear_gradient(funcs: paint_funcs_t, paint_data: Any, color_line: color_line_t, x0: float, y0: float, x1: float, y1: float, x2: float, y2: float) None#
Perform a “linear-gradient” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
color_line – Color information for the gradient
x0 – X coordinate of the first point
y0 – Y coordinate of the first point
x1 – X coordinate of the second point
y1 – Y coordinate of the second point
x2 – X coordinate of the third point
y2 – Y coordinate of the third point
- paint_pop_clip(funcs: paint_funcs_t, paint_data: Any = None) None#
Perform a “pop-clip” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
- paint_pop_group(funcs: paint_funcs_t, paint_data: Any, mode: paint_composite_mode_t) None#
Perform a “pop-group” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
mode – the compositing mode to use
- paint_pop_transform(funcs: paint_funcs_t, paint_data: Any = None) None#
Perform a “pop-transform” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
- paint_push_clip_glyph(funcs: paint_funcs_t, paint_data: Any, glyph: int, font: font_t) None#
Perform a “push-clip-glyph” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
glyph – the glyph ID
font – the font
- paint_push_clip_rectangle(funcs: paint_funcs_t, paint_data: Any, xmin: float, ymin: float, xmax: float, ymax: float) None#
Perform a “push-clip-rect” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
xmin – min X for the rectangle
ymin – min Y for the rectangle
xmax – max X for the rectangle
ymax – max Y for the rectangle
- paint_push_group(funcs: paint_funcs_t, paint_data: Any = None) None#
Perform a “push-group” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
- paint_push_transform(funcs: paint_funcs_t, paint_data: Any, xx: float, yx: float, xy: float, yy: float, dx: float, dy: float) None#
Perform a “push-transform” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
xx – xx component of the transform matrix
yx – yx component of the transform matrix
xy – xy component of the transform matrix
yy – yy component of the transform matrix
dx – dx component of the transform matrix
dy – dy component of the transform matrix
- paint_radial_gradient(funcs: paint_funcs_t, paint_data: Any, color_line: color_line_t, x0: float, y0: float, r0: float, x1: float, y1: float, r1: float) None#
Perform a “radial-gradient” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
color_line – Color information for the gradient
x0 – X coordinate of the first circle’s center
y0 – Y coordinate of the first circle’s center
r0 – radius of the first circle
x1 – X coordinate of the second circle’s center
y1 – Y coordinate of the second circle’s center
r1 – radius of the second circle
- paint_sweep_gradient(funcs: paint_funcs_t, paint_data: Any, color_line: color_line_t, x0: float, y0: float, start_angle: float, end_angle: float) None#
Perform a “sweep-gradient” paint operation.
Added in version 7.0.0.
- Parameters:
funcs – paint functions
paint_data – associated data passed by the caller
color_line – Color information for the gradient
x0 – X coordinate of the circle’s center
y0 – Y coordinate of the circle’s center
start_angle – the start angle
end_angle – the end angle
- script_from_iso15924_tag(tag: int) script_t#
Converts an ISO 15924 script tag to a corresponding
script_t.Added in version 0.9.2.
- Parameters:
tag – an
tag_trepresenting an ISO 15924 tag.- Returns:
An
script_tcorresponding to the ISO 15924 tag.
- script_from_string(str: list[int]) script_t#
Converts a string
strrepresenting an ISO 15924 script tag to a correspondingscript_t. Shorthand fortag_from_string()thenscript_from_iso15924_tag().Added in version 0.9.2.
- Parameters:
str – a string representing an ISO 15924 tag.
- Returns:
An
script_tcorresponding to the ISO 15924 tag.
- script_get_horizontal_direction(script: script_t) direction_t#
Fetches the
direction_tof a script when it is set horizontally. All right-to-left scripts will returnHB_DIRECTION_RTL. All left-to-right scripts will returnHB_DIRECTION_LTR. Scripts that can be written either horizontally or vertically will returnHB_DIRECTION_INVALID. Unknown scripts will returnHB_DIRECTION_LTR.Added in version 0.9.2.
- Parameters:
script – The
script_tto query- Returns:
The horizontal
direction_tofscript
- script_to_iso15924_tag(script: script_t) int#
Converts an
script_tto a corresponding ISO 15924 script tag.Added in version 0.9.2.
- Parameters:
script – an
script_tto convert.- Returns:
An
tag_trepresenting an ISO 15924 script tag.
- segment_properties_equal(a: segment_properties_t, b: segment_properties_t) int#
Checks the equality of two
segment_properties_t's.Added in version 0.9.7.
- Parameters:
a – first
segment_properties_tto compare.b – second
segment_properties_tto compare.
- Returns:
trueif all properties ofaequal those ofb,falseotherwise.
- segment_properties_hash(p: segment_properties_t) int#
Creates a hash representing
p.Added in version 0.9.7.
- Parameters:
p –
segment_properties_tto hash.- Returns:
A hash of
p.
- segment_properties_overlay(p: segment_properties_t, src: segment_properties_t) None#
Fills in missing fields of
pfromsrcin a considered manner.First, if
pdoes not have direction set, direction is copied fromsrc.Next, if
pandsrchave the same direction (which can be unset), ifpdoes not have script set, script is copied fromsrc.Finally, if
pandsrchave the same direction and script (which either can be unset), ifpdoes not have language set, language is copied fromsrc.Added in version 3.3.0.
- Parameters:
p –
segment_properties_tto fill in.src –
segment_properties_tto fill in from.
- set_add(set: set_t, codepoint: int) None#
Adds
codepointtoset.Added in version 0.9.2.
- Parameters:
set – A set
codepoint – The element to add to
set
- set_add_range(set: set_t, first: int, last: int) None#
Adds all of the elements from
firsttolast(inclusive) toset.Added in version 0.9.7.
- Parameters:
set – A set
first – The first element to add to
setlast – The final element to add to
set
- set_add_sorted_array(set: set_t, sorted_codepoints: list[int]) None#
Adds
num_codepointscodepoints to a set at once. The codepoints array must be in increasing order, with size at leastnum_codepoints.Added in version 4.1.0.
- Parameters:
set – A set
sorted_codepoints – Array of codepoints to add
- set_allocation_successful(set: set_t) int#
Tests whether memory allocation for a set was successful.
Added in version 0.9.2.
- Parameters:
set – A set
- Returns:
trueif allocation succeeded,falseotherwise
- set_clear(set: set_t) None#
Clears out the contents of a set.
Added in version 0.9.2.
- Parameters:
set – A set
- set_create() set_t#
Creates a new, initially empty set.
Added in version 0.9.2.
- Returns:
The new
set_t
- set_del(set: set_t, codepoint: int) None#
Removes
codepointfromset.Added in version 0.9.2.
- Parameters:
set – A set
codepoint – Removes
codepointfromset
- set_del_range(set: set_t, first: int, last: int) None#
Removes all of the elements from
firsttolast(inclusive) fromset.If
lastisHB_SET_VALUE_INVALID, then all values greater than or equal tofirstare removed.Added in version 0.9.7.
- Parameters:
set – A set
first – The first element to remove from
setlast – The final element to remove from
set
- set_get_empty() set_t#
Fetches the singleton empty
set_t.Added in version 0.9.2.
- Returns:
The empty
set_t
- set_get_max(set: set_t) int#
Finds the largest element in the set.
Added in version 0.9.7.
- Parameters:
set – A set
- Returns:
maximum of
set, orHB_SET_VALUE_INVALIDifsetis empty.
- set_get_min(set: set_t) int#
Finds the smallest element in the set.
Added in version 0.9.7.
- Parameters:
set – A set
- Returns:
minimum of
set, orHB_SET_VALUE_INVALIDifsetis empty.
- set_get_population(set: set_t) int#
Returns the number of elements in the set.
Added in version 0.9.7.
- Parameters:
set – A set
- Returns:
The population of
set
- set_has(set: set_t, codepoint: int) int#
Tests whether
codepointbelongs toset.Added in version 0.9.2.
- Parameters:
set – A set
codepoint – The element to query
- Returns:
trueifcodepointis inset,falseotherwise
- set_hash(set: set_t) int#
Creates a hash representing
set.Added in version 4.4.0.
- Parameters:
set – A set
- Returns:
A hash of
set.
- set_intersect(set: set_t, other: set_t) None#
Makes
setthe intersection ofsetandother.Added in version 0.9.2.
- Parameters:
set – A set
other – Another set
- set_invert(set: set_t) None#
Inverts the contents of
set.Added in version 3.0.0.
- Parameters:
set – A set
- set_is_empty(set: set_t) int#
Tests whether a set is empty (contains no elements).
Added in version 0.9.7.
- Parameters:
set – a set.
- Returns:
trueifsetis empty
- set_is_equal(set: set_t, other: set_t) int#
Tests whether
setandotherare equal (contain the same elements).Added in version 0.9.7.
- Parameters:
set – A set
other – Another set
- Returns:
trueif the two sets are equal,falseotherwise.
- set_is_inverted(set: set_t) int#
Returns whether the set is inverted.
Added in version 7.0.0.
- Parameters:
set – A set
- Returns:
trueif the set is inverted,falseotherwise
- set_is_subset(set: set_t, larger_set: set_t) int#
Tests whether
setis a subset oflarger_set.Added in version 1.8.1.
- Parameters:
set – A set
larger_set – Another set
- Returns:
trueif thesetis a subset of (or equal to)larger_set,falseotherwise.
- set_next(set: set_t, codepoint: int) tuple[int, int]#
Fetches the next element in
setthat is greater than current value ofcodepoint.Set
codepointtoHB_SET_VALUE_INVALIDto get started.Added in version 0.9.2.
- Parameters:
set – A set
codepoint – Input = Code point to query Output = Code point retrieved
- Returns:
trueif there was a next value,falseotherwise
- set_next_many(set: set_t, codepoint: int, out: list[int]) int#
Finds the next element in
setthat is greater thancodepoint. Writes out codepoints toout, until either the set runs out of elements, orsizecodepoints are written, whichever comes first.Added in version 4.2.0.
- Parameters:
set – A set
codepoint – Outputting codepoints starting after this one. Use
HB_SET_VALUE_INVALIDto get started.out – An array of codepoints to write to.
- Returns:
the number of values written.
- set_next_range(set: set_t, last: int) tuple[int, int, int]#
Fetches the next consecutive range of elements in
setthat are greater than current value oflast.Set
lasttoHB_SET_VALUE_INVALIDto get started.Added in version 0.9.7.
- Parameters:
set – A set
last – Input = The current last code point in the range Output = The last code point in the range
- Returns:
trueif there was a next range,falseotherwise
- set_previous(set: set_t, codepoint: int) tuple[int, int]#
Fetches the previous element in
setthat is lower than current value ofcodepoint.Set
codepointtoHB_SET_VALUE_INVALIDto get started.Added in version 1.8.0.
- Parameters:
set – A set
codepoint – Input = Code point to query Output = Code point retrieved
- Returns:
trueif there was a previous value,falseotherwise
- set_previous_range(set: set_t, first: int) tuple[int, int, int]#
Fetches the previous consecutive range of elements in
setthat are greater than current value oflast.Set
firsttoHB_SET_VALUE_INVALIDto get started.Added in version 1.8.0.
- Parameters:
set – A set
first – Input = The current first code point in the range Output = The first code point in the range
- Returns:
trueif there was a previous range,falseotherwise
- set_set(set: set_t, other: set_t) None#
Makes the contents of
setequal to the contents ofother.Added in version 0.9.2.
- Parameters:
set – A set
other – Another set
- set_subtract(set: set_t, other: set_t) None#
Subtracts the contents of
otherfromset.Added in version 0.9.2.
- Parameters:
set – A set
other – Another set
- set_symmetric_difference(set: set_t, other: set_t) None#
Makes
setthe symmetric difference ofsetandother.Added in version 0.9.2.
- Parameters:
set – A set
other – Another set
- set_union(set: set_t, other: set_t) None#
Makes
setthe union ofsetandother.Added in version 0.9.2.
- Parameters:
set – A set
other – Another set
- shape(font: font_t, buffer: buffer_t, features: list[feature_t] | None = None) None#
Shapes
bufferusingfontturning its Unicode characters content to positioned glyphs. Iffeaturesis notNULL, it will be used to control the features applied during shaping. If twofeatureshave the same tag but overlapping ranges the value of the feature with the higher index takes precedence.Added in version 0.9.2.
- shape_full(font: font_t, buffer: buffer_t, features: list[feature_t] | None = None, shaper_list: list[str] | None = None) int#
See
shape()for details. Ifshaper_listis notNULL, the specified shapers will be used in the given order, otherwise the default shapers list will be used.Added in version 0.9.2.
- shape_justify(font: font_t, buffer: buffer_t, features: list[feature_t] | None, shaper_list: list[str] | None, min_target_advance: float, max_target_advance: float, advance: float) tuple[int, float, int, float]#
See
shape_full()for basic details. Ifshaper_listis notNULL, the specified shapers will be used in the given order, otherwise the default shapers list will be used.In addition, justify the shaping results such that the shaping results reach the target advance width/height, depending on the buffer direction.
If the advance of the buffer shaped with
shape_full()is already known, put that in *advance. Otherwise set *advance to zero.This API is currently experimental and will probably change in the future.
- Parameters:
font – a mutable
font_tto use for shapingbuffer – an
buffer_tto shapefeatures – an array of user specified
feature_torNULLshaper_list – a
NULL-terminated array of shapers to use orNULLmin_target_advance – Minimum advance width/height to aim for.
max_target_advance – Maximum advance width/height to aim for.
advance – Input/output advance width/height of the buffer.
- Returns:
false if all shapers failed, true otherwise
XSince: EXPERIMENTAL
- shape_list_shapers() list[str]#
Retrieves the list of shapers supported by HarfBuzz.
Added in version 0.9.2.
- Returns:
an array of constant strings
- shape_plan_create(face: face_t, props: segment_properties_t, user_features: list[feature_t], shaper_list: list[str]) shape_plan_t#
Constructs a shaping plan for a combination of
face,user_features,props, andshaper_list.Added in version 0.9.7.
- Parameters:
face –
face_tto useprops – The
segment_properties_tof the segmentuser_features – The list of user-selected features
shaper_list – List of shapers to try
- Returns:
The shaping plan
- shape_plan_create2(face: face_t, props: segment_properties_t, user_features: list[feature_t], coords: list[int], shaper_list: list[str]) shape_plan_t#
The variable-font version of
hb_shape_plan_create. Constructs a shaping plan for a combination offace,user_features,props, andshaper_list, plus the variation-space coordinatescoords.Added in version 1.4.0.
- Parameters:
face –
face_tto useprops – The
segment_properties_tof the segmentuser_features – The list of user-selected features
coords – The list of variation-space coordinates
shaper_list – List of shapers to try
- Returns:
The shaping plan
- shape_plan_create_cached(face: face_t, props: segment_properties_t, user_features: list[feature_t], shaper_list: list[str]) shape_plan_t#
Creates a cached shaping plan suitable for reuse, for a combination of
face,user_features,props, andshaper_list.Added in version 0.9.7.
- Parameters:
face –
face_tto useprops – The
segment_properties_tof the segmentuser_features – The list of user-selected features
shaper_list – List of shapers to try
- Returns:
The shaping plan
- shape_plan_create_cached2(face: face_t, props: segment_properties_t, user_features: list[feature_t], coords: list[int], shaper_list: list[str]) shape_plan_t#
The variable-font version of
hb_shape_plan_create_cached. Creates a cached shaping plan suitable for reuse, for a combination offace,user_features,props, andshaper_list, plus the variation-space coordinatescoords.Added in version 1.4.0.
- Parameters:
face –
face_tto useprops – The
segment_properties_tof the segmentuser_features – The list of user-selected features
coords – The list of variation-space coordinates
shaper_list – List of shapers to try
- Returns:
The shaping plan
- shape_plan_execute(shape_plan: shape_plan_t, font: font_t, buffer: buffer_t, features: list[feature_t]) int#
Executes the given shaping plan on the specified buffer, using the given
fontandfeatures.Added in version 0.9.7.
- shape_plan_get_empty() shape_plan_t#
Fetches the singleton empty shaping plan.
Added in version 0.9.7.
- Returns:
The empty shaping plan
- shape_plan_get_shaper(shape_plan: shape_plan_t) str#
Fetches the shaper from a given shaping plan.
Added in version 0.9.7.
- Parameters:
shape_plan – A shaping plan
- Returns:
The shaper
- style_get_value(font: font_t, style_tag: style_tag_t) float#
Searches variation axes of a
font_tobject for a specific axis first, if not set, then tries to get default style values from different tables of the font.Added in version 3.0.0.
- Parameters:
font – a
font_tobject.style_tag – a style tag.
- Returns:
Corresponding axis or default value to a style tag.
- tag_from_string(str: list[int]) int#
Converts a string into an
tag_t. Valid tags are four characters. Shorter input strings will be padded with spaces. Longer input strings will be truncated.Added in version 0.9.2.
- Parameters:
str – String to convert
- Returns:
The
tag_tcorresponding tostr
- tag_to_string(tag: int) list[int]#
Converts an
tag_tto a string and returns it inbuf. Strings will be four characters long.Added in version 0.9.5.
- Parameters:
tag –
tag_tto convert
- unicode_combining_class(ufuncs: unicode_funcs_t, unicode: int) unicode_combining_class_t#
Retrieves the Canonical Combining Class (ccc) property of code point
unicode.Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
unicode – The code point to query
- Returns:
The
unicode_combining_class_tofunicode
- unicode_compose(ufuncs: unicode_funcs_t, a: int, b: int) tuple[int, int]#
Fetches the composition of a sequence of two Unicode code points.
Calls the composition function of the specified Unicode-functions structure
ufuncs.Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
a – The first Unicode code point to compose
b – The second Unicode code point to compose
- Returns:
trueifaandbcomposed,falseotherwise
- unicode_decompose(ufuncs: unicode_funcs_t, ab: int) tuple[int, int, int]#
Fetches the decomposition of a Unicode code point.
Calls the decomposition function of the specified Unicode-functions structure
ufuncs.Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
ab – Unicode code point to decompose
- Returns:
trueifabwas decomposed,falseotherwise
- unicode_decompose_compatibility(ufuncs: unicode_funcs_t, u: int) tuple[int, int]#
Fetches the compatibility decomposition of a Unicode code point. Deprecated.
Added in version 0.9.2.
Deprecated since version 2.0.0: Please do not use it in newly written code
- Parameters:
ufuncs – The Unicode-functions structure
u – Code point to decompose
- Returns:
length of
decomposed.
- unicode_eastasian_width(ufuncs: unicode_funcs_t, unicode: int) int#
Don’t use. Not used by HarfBuzz.
Added in version 0.9.2.
Deprecated since version 2.0.0: Please do not use it in newly written code
- Parameters:
ufuncs – a Unicode-function structure
unicode – The code point to query
- unicode_funcs_create(parent: unicode_funcs_t | None = None) unicode_funcs_t#
Creates a new
unicode_funcs_tstructure of Unicode functions.Added in version 0.9.2.
- Parameters:
parent – Parent Unicode-functions structure
- Returns:
The Unicode-functions structure
- unicode_funcs_get_default() unicode_funcs_t#
Fetches a pointer to the default Unicode-functions structure that is used when no functions are explicitly set on
buffer_t.Added in version 0.9.2.
- Returns:
a pointer to the
unicode_funcs_tUnicode-functions structure
- unicode_funcs_get_empty() unicode_funcs_t#
Fetches the singleton empty Unicode-functions structure.
Added in version 0.9.2.
- Returns:
The empty Unicode-functions structure
- unicode_funcs_get_parent(ufuncs: unicode_funcs_t) unicode_funcs_t#
Fetches the parent of the Unicode-functions structure
ufuncs.Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
- Returns:
The parent Unicode-functions structure
- unicode_funcs_is_immutable(ufuncs: unicode_funcs_t) int#
Tests whether the specified Unicode-functions structure is immutable.
Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
- Returns:
trueifufuncsis immutable,falseotherwise
- unicode_funcs_make_immutable(ufuncs: unicode_funcs_t) None#
Makes the specified Unicode-functions structure immutable.
Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
- unicode_funcs_set_combining_class_func(ufuncs: unicode_funcs_t, func: Callable[[unicode_funcs_t, int, Any], unicode_combining_class_t], user_data: Any = None) None#
Sets the implementation function for
unicode_combining_class_func_t.Added in version 0.9.2.
- Parameters:
ufuncs – A Unicode-functions structure
func – The callback function to assign
user_data – Data to pass to
func
- unicode_funcs_set_compose_func(ufuncs: unicode_funcs_t, func: Callable[[unicode_funcs_t, int, int, Any], tuple[int, int]], user_data: Any = None) None#
Sets the implementation function for
unicode_compose_func_t.Added in version 0.9.2.
- Parameters:
ufuncs – A Unicode-functions structure
func – The callback function to assign
user_data – Data to pass to
func
- unicode_funcs_set_decompose_compatibility_func(ufuncs: unicode_funcs_t, func: Callable[[unicode_funcs_t, int, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
unicode_decompose_compatibility_func_t.Added in version 0.9.2.
Deprecated since version 2.0.0: Please do not use it in newly written code
- Parameters:
ufuncs – A Unicode-functions structure
func – The callback function to assign
user_data – Data to pass to
func
- unicode_funcs_set_decompose_func(ufuncs: unicode_funcs_t, func: Callable[[unicode_funcs_t, int, Any], tuple[int, int, int]], user_data: Any = None) None#
Sets the implementation function for
unicode_decompose_func_t.Added in version 0.9.2.
- Parameters:
ufuncs – A Unicode-functions structure
func – The callback function to assign
user_data – Data to pass to
func
- unicode_funcs_set_eastasian_width_func(ufuncs: unicode_funcs_t, func: Callable[[unicode_funcs_t, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
unicode_eastasian_width_func_t.Added in version 0.9.2.
Deprecated since version 2.0.0: Please do not use it in newly written code
- Parameters:
ufuncs – a Unicode-function structure
func – The callback function to assign
user_data – Data to pass to
func
- unicode_funcs_set_general_category_func(ufuncs: unicode_funcs_t, func: Callable[[unicode_funcs_t, int, Any], unicode_general_category_t], user_data: Any = None) None#
Sets the implementation function for
unicode_general_category_func_t.Added in version 0.9.2.
- Parameters:
ufuncs – A Unicode-functions structure
func – The callback function to assign
user_data – Data to pass to
func
- unicode_funcs_set_mirroring_func(ufuncs: unicode_funcs_t, func: Callable[[unicode_funcs_t, int, Any], int], user_data: Any = None) None#
Sets the implementation function for
unicode_mirroring_func_t.Added in version 0.9.2.
- Parameters:
ufuncs – A Unicode-functions structure
func – The callback function to assign
user_data – Data to pass to
func
- unicode_funcs_set_script_func(ufuncs: unicode_funcs_t, func: Callable[[unicode_funcs_t, int, Any], script_t], user_data: Any = None) None#
Sets the implementation function for
unicode_script_func_t.Added in version 0.9.2.
- Parameters:
ufuncs – A Unicode-functions structure
func – The callback function to assign
user_data – Data to pass to
func
- unicode_general_category(ufuncs: unicode_funcs_t, unicode: int) unicode_general_category_t#
Retrieves the General Category (gc) property of code point
unicode.Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
unicode – The code point to query
- Returns:
The
unicode_general_category_tofunicode
- unicode_mirroring(ufuncs: unicode_funcs_t, unicode: int) int#
Retrieves the Bi-directional Mirroring Glyph code point defined for code point
unicode.Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
unicode – The code point to query
- Returns:
The
codepoint_tof the Mirroring Glyph forunicode
- unicode_script(ufuncs: unicode_funcs_t, unicode: int) script_t#
Retrieves the
script_tscript to which code pointunicodebelongs.Added in version 0.9.2.
- Parameters:
ufuncs – The Unicode-functions structure
unicode – The code point to query
- Returns:
The
script_tofunicode
- variation_from_string(str: list[int]) tuple[int, variation_t]#
Parses a string into a
variation_t.The format for specifying variation settings follows. All valid CSS font-variation-settings values other than ‘normal’ and ‘inherited’ are also accepted, though, not documented below.
The format is a tag, optionally followed by an equals sign, followed by a number. For example
wght=500, orslnt=-7.5.Added in version 1.4.2.
- Parameters:
str – a string to parse
- Returns:
trueifstris successfully parsed,falseotherwise
- variation_to_string(variation: variation_t) list[str]#
Converts an
variation_tinto aNULL-terminated string in the format understood byvariation_from_string(). The client in responsible for allocating big enough size forbuf, 128 bytes is more than enough.Added in version 1.4.2.
- Parameters:
variation – an
variation_tto convert