Functions

aat_layout_feature_type_get_name_id (face, feature_type)

aat_layout_feature_type_get_selector_infos (face, feature_type, start_offset)

aat_layout_get_feature_types (face, start_offset)

aat_layout_has_positioning (face)

aat_layout_has_substitution (face)

aat_layout_has_tracking (face)

blob_copy_writable_or_fail (blob)

blob_create_from_file (file_name)

blob_create_from_file_or_fail (file_name)

blob_create_sub_blob (parent, offset, length)

blob_get_data (blob)

blob_get_data_writable (blob)

blob_get_empty ()

blob_get_length (blob)

blob_is_immutable (blob)

blob_make_immutable (blob)

buffer_add (buffer, codepoint, cluster)

buffer_add_codepoints (buffer, text, item_offset, item_length)

buffer_add_latin1 (buffer, text, item_offset, item_length)

buffer_add_utf16 (buffer, text, item_offset, item_length)

buffer_add_utf32 (buffer, text, item_offset, item_length)

buffer_add_utf8 (buffer, text, item_offset, item_length)

buffer_allocation_successful (buffer)

buffer_append (buffer, source, start, end)

buffer_clear_contents (buffer)

buffer_create ()

buffer_create_similar (src)

buffer_deserialize_glyphs (buffer, buf, font, format)

buffer_deserialize_unicode (buffer, buf, format)

buffer_diff (buffer, reference, dottedcircle_glyph, position_fuzz)

buffer_get_cluster_level (buffer)

buffer_get_content_type (buffer)

buffer_get_direction (buffer)

buffer_get_empty ()

buffer_get_flags (buffer)

buffer_get_glyph_infos (buffer)

buffer_get_glyph_positions (buffer)

buffer_get_invisible_glyph (buffer)

buffer_get_language (buffer)

buffer_get_length (buffer)

buffer_get_not_found_glyph (buffer)

buffer_get_replacement_codepoint (buffer)

buffer_get_script (buffer)

buffer_get_segment_properties (buffer)

buffer_get_unicode_funcs (buffer)

buffer_guess_segment_properties (buffer)

buffer_has_positions (buffer)

buffer_normalize_glyphs (buffer)

buffer_pre_allocate (buffer, size)

buffer_reset (buffer)

buffer_reverse (buffer)

buffer_reverse_clusters (buffer)

buffer_reverse_range (buffer, start, end)

buffer_serialize (buffer, start, end, font, format, flags)

buffer_serialize_format_from_string (str)

buffer_serialize_format_to_string (format)

buffer_serialize_glyphs (buffer, start, end, font, format, flags)

buffer_serialize_list_formats ()

buffer_serialize_unicode (buffer, start, end, format, flags)

buffer_set_cluster_level (buffer, cluster_level)

buffer_set_content_type (buffer, content_type)

buffer_set_direction (buffer, direction)

buffer_set_flags (buffer, flags)

buffer_set_invisible_glyph (buffer, invisible)

buffer_set_language (buffer, language)

buffer_set_length (buffer, length)

buffer_set_message_func (buffer, func, *user_data)

buffer_set_not_found_glyph (buffer, not_found)

buffer_set_replacement_codepoint (buffer, replacement)

buffer_set_script (buffer, script)

buffer_set_segment_properties (buffer, props)

buffer_set_unicode_funcs (buffer, unicode_funcs)

color_get_alpha (color)

color_get_blue (color)

color_get_green (color)

color_get_red (color)

color_line_get_color_stops (color_line, start)

color_line_get_extend (color_line)

direction_from_string (str)

direction_to_string (direction)

draw_close_path (dfuncs, draw_data, st)

draw_cubic_to (dfuncs, draw_data, st, control1_x, control1_y, control2_x, control2_y, to_x, to_y)

draw_funcs_create ()

draw_funcs_get_empty ()

draw_funcs_is_immutable (dfuncs)

draw_funcs_make_immutable (dfuncs)

draw_funcs_set_close_path_func (dfuncs, func, *user_data)

draw_funcs_set_cubic_to_func (dfuncs, func, *user_data)

draw_funcs_set_line_to_func (dfuncs, func, *user_data)

draw_funcs_set_move_to_func (dfuncs, func, *user_data)

draw_funcs_set_quadratic_to_func (dfuncs, func, *user_data)

draw_line_to (dfuncs, draw_data, st, to_x, to_y)

draw_move_to (dfuncs, draw_data, st, to_x, to_y)

draw_quadratic_to (dfuncs, draw_data, st, control_x, control_y, to_x, to_y)

face_builder_add_table (face, tag, blob)

face_builder_create ()

face_builder_sort_tables (face, tags)

face_collect_nominal_glyph_mapping (face)

face_collect_unicodes (face)

face_collect_variation_selectors (face)

face_collect_variation_unicodes (face, variation_selector)

face_count (blob)

face_create (blob, index)

face_create_for_tables (reference_table_func, *user_data)

face_get_empty ()

face_get_glyph_count (face)

face_get_index (face)

face_get_table_tags (face, start_offset)

face_get_upem (face)

face_is_immutable (face)

face_make_immutable (face)

face_reference_blob (face)

face_reference_table (face, tag)

face_set_glyph_count (face, glyph_count)

face_set_index (face, index)

face_set_upem (face, upem)

feature_from_string (str)

feature_to_string (feature)

font_add_glyph_origin_for_direction (font, glyph, direction, x, y)

font_changed (font)

font_create (face)

font_create_sub_font (parent)

font_draw_glyph (font, glyph, dfuncs, draw_data)

font_funcs_create ()

font_funcs_get_empty ()

font_funcs_is_immutable (ffuncs)

font_funcs_make_immutable (ffuncs)

font_funcs_set_draw_glyph_func (ffuncs, func, *user_data)

font_funcs_set_font_h_extents_func (ffuncs, func, *user_data)

font_funcs_set_font_v_extents_func (ffuncs, func, *user_data)

font_funcs_set_glyph_contour_point_func (ffuncs, func, *user_data)

font_funcs_set_glyph_extents_func (ffuncs, func, *user_data)

font_funcs_set_glyph_from_name_func (ffuncs, func, *user_data)

font_funcs_set_glyph_func (ffuncs, func, *user_data)

font_funcs_set_glyph_h_advance_func (ffuncs, func, *user_data)

font_funcs_set_glyph_h_advances_func (ffuncs, func, *user_data)

font_funcs_set_glyph_h_kerning_func (ffuncs, func, *user_data)

font_funcs_set_glyph_h_origin_func (ffuncs, func, *user_data)

font_funcs_set_glyph_name_func (ffuncs, func, *user_data)

font_funcs_set_glyph_shape_func (ffuncs, func, *user_data)

font_funcs_set_glyph_v_advance_func (ffuncs, func, *user_data)

font_funcs_set_glyph_v_advances_func (ffuncs, func, *user_data)

font_funcs_set_glyph_v_kerning_func (ffuncs, func, *user_data)

font_funcs_set_glyph_v_origin_func (ffuncs, func, *user_data)

font_funcs_set_nominal_glyph_func (ffuncs, func, *user_data)

font_funcs_set_nominal_glyphs_func (ffuncs, func, *user_data)

font_funcs_set_paint_glyph_func (ffuncs, func, *user_data)

font_funcs_set_variation_glyph_func (ffuncs, func, *user_data)

font_get_empty ()

font_get_extents_for_direction (font, direction)

font_get_face (font)

font_get_glyph (font, unicode, variation_selector)

font_get_glyph_advance_for_direction (font, glyph, direction)

font_get_glyph_advances_for_direction (font, direction, count, first_glyph, glyph_stride)

font_get_glyph_contour_point (font, glyph, point_index)

font_get_glyph_contour_point_for_origin (font, glyph, point_index, direction)

font_get_glyph_extents (font, glyph)

font_get_glyph_extents_for_origin (font, glyph, direction)

font_get_glyph_from_name (font, name)

font_get_glyph_h_advance (font, glyph)

font_get_glyph_h_advances (font, count, first_glyph, glyph_stride, advance_stride)

font_get_glyph_h_kerning (font, left_glyph, right_glyph)

font_get_glyph_h_origin (font, glyph)

font_get_glyph_kerning_for_direction (font, first_glyph, second_glyph, direction)

font_get_glyph_name (font, glyph)

font_get_glyph_origin_for_direction (font, glyph, direction)

font_get_glyph_shape (font, glyph, dfuncs, draw_data)

font_get_glyph_v_advance (font, glyph)

font_get_glyph_v_advances (font, count, first_glyph, glyph_stride)

font_get_glyph_v_kerning (font, top_glyph, bottom_glyph)

font_get_glyph_v_origin (font, glyph)

font_get_h_extents (font)

font_get_nominal_glyph (font, unicode)

font_get_nominal_glyphs (font, count, first_unicode, unicode_stride, glyph_stride)

font_get_parent (font)

font_get_ppem (font)

font_get_ptem (font)

font_get_scale (font)

font_get_serial (font)

font_get_synthetic_bold (font)

font_get_synthetic_slant (font)

font_get_v_extents (font)

font_get_var_coords_design (font)

font_get_var_coords_normalized (font)

font_get_var_named_instance (font)

font_get_variation_glyph (font, unicode, variation_selector)

font_glyph_from_string (font, s)

font_glyph_to_string (font, glyph)

font_is_immutable (font)

font_make_immutable (font)

font_paint_glyph (font, glyph, pfuncs, paint_data, palette_index, foreground)

font_set_face (font, face)

font_set_funcs (font, klass, font_data, destroy)

font_set_funcs_data (font, font_data, destroy)

font_set_parent (font, parent)

font_set_ppem (font, x_ppem, y_ppem)

font_set_ptem (font, ptem)

font_set_scale (font, x_scale, y_scale)

font_set_synthetic_bold (font, x_embolden, y_embolden, in_place)

font_set_synthetic_slant (font, slant)

font_set_var_coords_design (font, coords)

font_set_var_coords_normalized (font, coords)

font_set_var_named_instance (font, instance_index)

font_set_variation (font, tag, value)

font_set_variations (font, variations)

font_subtract_glyph_origin_for_direction (font, glyph, direction, x, y)

ft_face_create (ft_face, destroy)

ft_face_create_cached (ft_face)

ft_face_create_referenced (ft_face)

ft_font_changed (font)

ft_font_create (ft_face, destroy)

ft_font_create_referenced (ft_face)

ft_font_get_load_flags (font)

ft_font_set_funcs (font)

ft_font_set_load_flags (font, load_flags)

ft_hb_font_changed (font)

glib_blob_create (gbytes)

glib_get_unicode_funcs ()

glib_script_from_script (script)

glib_script_to_script (script)

glyph_info_get_glyph_flags (info)

language_from_string (str)

language_get_default ()

language_matches (language, specific)

language_to_string (language)

map_allocation_successful (map)

map_clear (map)

map_copy (map)

map_create ()

map_del (map, key)

map_get (map, key)

map_get_empty ()

map_get_population (map)

map_has (map, key)

map_hash (map)

map_is_empty (map)

map_is_equal (map, other)

map_keys (map, keys)

map_next (map, idx)

map_set (map, key, value)

map_update (map, other)

map_values (map, values)

ot_color_glyph_get_layers (face, glyph, start_offset)

ot_color_glyph_has_paint (face, glyph)

ot_color_glyph_reference_png (font, glyph)

ot_color_glyph_reference_svg (face, glyph)

ot_color_has_layers (face)

ot_color_has_paint (face)

ot_color_has_palettes (face)

ot_color_has_png (face)

ot_color_has_svg (face)

ot_color_palette_color_get_name_id (face, color_index)

ot_color_palette_get_colors (face, palette_index, start_offset)

ot_color_palette_get_count (face)

ot_color_palette_get_flags (face, palette_index)

ot_color_palette_get_name_id (face, palette_index)

ot_font_set_funcs (font)

ot_layout_collect_features (face, table_tag, scripts, languages, features)

ot_layout_collect_features_map (face, table_tag, script_index, language_index)

ot_layout_collect_lookups (face, table_tag, scripts, languages, features)

ot_layout_feature_get_characters (face, table_tag, feature_index, start_offset)

ot_layout_feature_get_lookups (face, table_tag, feature_index, start_offset)

ot_layout_feature_get_name_ids (face, table_tag, feature_index)

ot_layout_feature_with_variations_get_lookups (face, table_tag, feature_index, variations_index, start_offset)

ot_layout_get_attach_points (face, glyph, start_offset)

ot_layout_get_baseline (font, baseline_tag, direction, script_tag, language_tag)

ot_layout_get_baseline2 (font, baseline_tag, direction, script, language)

ot_layout_get_baseline_with_fallback (font, baseline_tag, direction, script_tag, language_tag)

ot_layout_get_baseline_with_fallback2 (font, baseline_tag, direction, script, language)

ot_layout_get_font_extents (font, direction, script_tag, language_tag)

ot_layout_get_font_extents2 (font, direction, script, language)

ot_layout_get_glyph_class (face, glyph)

ot_layout_get_glyphs_in_class (face, klass)

ot_layout_get_horizontal_baseline_tag_for_script (script)

ot_layout_get_ligature_carets (font, direction, glyph, start_offset)

ot_layout_get_size_params (face)

ot_layout_has_glyph_classes (face)

ot_layout_has_positioning (face)

ot_layout_has_substitution (face)

ot_layout_language_find_feature (face, table_tag, script_index, language_index, feature_tag)

ot_layout_language_get_feature_indexes (face, table_tag, script_index, language_index, start_offset)

ot_layout_language_get_feature_tags (face, table_tag, script_index, language_index, start_offset)

ot_layout_language_get_required_feature (face, table_tag, script_index, language_index)

ot_layout_language_get_required_feature_index (face, table_tag, script_index, language_index)

ot_layout_lookup_collect_glyphs (face, table_tag, lookup_index)

ot_layout_lookup_get_glyph_alternates (face, lookup_index, glyph, start_offset)

ot_layout_lookup_get_optical_bound (font, lookup_index, direction, glyph)

ot_layout_lookup_substitute_closure (face, lookup_index)

ot_layout_lookup_would_substitute (face, lookup_index, glyphs, glyphs_length, zero_context)

ot_layout_lookups_substitute_closure (face, lookups)

ot_layout_script_find_language (face, table_tag, script_index, language_tag, language_index)

ot_layout_script_get_language_tags (face, table_tag, script_index, start_offset)

ot_layout_script_select_language (face, table_tag, script_index, language_count, language_tags)

ot_layout_script_select_language2 (face, table_tag, script_index, language_count, language_tags)

ot_layout_table_choose_script (face, table_tag, script_tags)

ot_layout_table_find_feature_variations (face, table_tag, coords, num_coords)

ot_layout_table_find_script (face, table_tag, script_tag)

ot_layout_table_get_feature_tags (face, table_tag, start_offset)

ot_layout_table_get_lookup_count (face, table_tag)

ot_layout_table_get_script_tags (face, table_tag, start_offset)

ot_layout_table_select_script (face, table_tag, script_count, script_tags)

ot_math_get_constant (font, constant)

ot_math_get_glyph_assembly (font, glyph, direction, start_offset)

ot_math_get_glyph_italics_correction (font, glyph)

ot_math_get_glyph_kerning (font, glyph, kern, correction_height)

ot_math_get_glyph_kernings (font, glyph, kern, start_offset)

ot_math_get_glyph_top_accent_attachment (font, glyph)

ot_math_get_glyph_variants (font, glyph, direction, start_offset)

ot_math_get_min_connector_overlap (font, direction)

ot_math_has_data (face)

ot_math_is_glyph_extended_shape (face, glyph)

ot_meta_get_entry_tags (face, start_offset)

ot_meta_reference_entry (face, meta_tag)

ot_metrics_get_position (font, metrics_tag)

ot_metrics_get_position_with_fallback (font, metrics_tag)

ot_metrics_get_variation (font, metrics_tag)

ot_metrics_get_x_variation (font, metrics_tag)

ot_metrics_get_y_variation (font, metrics_tag)

ot_name_get_utf16 (face, name_id, language)

ot_name_get_utf32 (face, name_id, language)

ot_name_get_utf8 (face, name_id, language)

ot_name_list_names (face)

ot_shape_glyphs_closure (font, buffer, features)

ot_shape_plan_collect_lookups (shape_plan, table_tag)

ot_tag_from_language (language)

ot_tag_to_language (tag)

ot_tag_to_script (tag)

ot_tags_from_script (script)

ot_tags_from_script_and_language (script, language, script_count, language_count)

ot_tags_to_script_and_language (script_tag, language_tag)

ot_var_find_axis (face, axis_tag, axis_index)

ot_var_find_axis_info (face, axis_tag)

ot_var_get_axes (face, start_offset)

ot_var_get_axis_count (face)

ot_var_get_axis_infos (face, start_offset)

ot_var_get_named_instance_count (face)

ot_var_has_data (face)

ot_var_named_instance_get_design_coords (face, instance_index)

ot_var_named_instance_get_postscript_name_id (face, instance_index)

ot_var_named_instance_get_subfamily_name_id (face, instance_index)

ot_var_normalize_coords (face, coords_length, design_coords)

ot_var_normalize_variations (face, variations, variations_length)

paint_color (funcs, paint_data, is_foreground, color)

paint_color_glyph (funcs, paint_data, glyph, font)

paint_custom_palette_color (funcs, paint_data, color_index)

paint_funcs_create ()

paint_funcs_get_empty ()

paint_funcs_is_immutable (funcs)

paint_funcs_make_immutable (funcs)

paint_funcs_set_color_func (funcs, func, *user_data)

paint_funcs_set_color_glyph_func (funcs, func, *user_data)

paint_funcs_set_custom_palette_color_func (funcs, func, *user_data)

paint_funcs_set_image_func (funcs, func, *user_data)

paint_funcs_set_linear_gradient_func (funcs, func, *user_data)

paint_funcs_set_pop_clip_func (funcs, func, *user_data)

paint_funcs_set_pop_group_func (funcs, func, *user_data)

paint_funcs_set_pop_transform_func (funcs, func, *user_data)

paint_funcs_set_push_clip_glyph_func (funcs, func, *user_data)

paint_funcs_set_push_clip_rectangle_func (funcs, func, *user_data)

paint_funcs_set_push_group_func (funcs, func, *user_data)

paint_funcs_set_push_transform_func (funcs, func, *user_data)

paint_funcs_set_radial_gradient_func (funcs, func, *user_data)

paint_funcs_set_sweep_gradient_func (funcs, func, *user_data)

paint_image (funcs, paint_data, image, width, height, format, slant, extents)

paint_linear_gradient (funcs, paint_data, color_line, x0, y0, x1, y1, x2, y2)

paint_pop_clip (funcs, paint_data)

paint_pop_group (funcs, paint_data, mode)

paint_pop_transform (funcs, paint_data)

paint_push_clip_glyph (funcs, paint_data, glyph, font)

paint_push_clip_rectangle (funcs, paint_data, xmin, ymin, xmax, ymax)

paint_push_group (funcs, paint_data)

paint_push_transform (funcs, paint_data, xx, yx, xy, yy, dx, dy)

paint_radial_gradient (funcs, paint_data, color_line, x0, y0, r0, x1, y1, r1)

paint_sweep_gradient (funcs, paint_data, color_line, x0, y0, start_angle, end_angle)

script_from_iso15924_tag (tag)

script_from_string (str)

script_get_horizontal_direction (script)

script_to_iso15924_tag (script)

segment_properties_equal (a, b)

segment_properties_hash (p)

segment_properties_overlay (p, src)

set_add (set, codepoint)

set_add_range (set, first, last)

set_add_sorted_array (set, sorted_codepoints)

set_allocation_successful (set)

set_clear (set)

set_copy (set)

set_create ()

set_del (set, codepoint)

set_del_range (set, first, last)

set_get_empty ()

set_get_max (set)

set_get_min (set)

set_get_population (set)

set_has (set, codepoint)

set_hash (set)

set_intersect (set, other)

set_invert (set)

set_is_empty (set)

set_is_equal (set, other)

set_is_inverted (set)

set_is_subset (set, larger_set)

set_next (set, codepoint)

set_next_many (set, codepoint, out)

set_next_range (set, last)

set_previous (set, codepoint)

set_previous_range (set, first)

set_set (set, other)

set_subtract (set, other)

set_symmetric_difference (set, other)

set_union (set, other)

shape (font, buffer, features)

shape_full (font, buffer, features, shaper_list)

shape_justify (font, buffer, features, shaper_list, min_target_advance, max_target_advance, advance)

shape_list_shapers ()

shape_plan_create (face, props, user_features, shaper_list)

shape_plan_create2 (face, props, user_features, coords, shaper_list)

shape_plan_create_cached (face, props, user_features, shaper_list)

shape_plan_create_cached2 (face, props, user_features, coords, shaper_list)

shape_plan_execute (shape_plan, font, buffer, features)

shape_plan_get_empty ()

shape_plan_get_shaper (shape_plan)

style_get_value (font, style_tag)

tag_from_string (str)

tag_to_string (tag)

unicode_combining_class (ufuncs, unicode)

unicode_compose (ufuncs, a, b)

unicode_decompose (ufuncs, ab)

unicode_decompose_compatibility (ufuncs, u)

unicode_eastasian_width (ufuncs, unicode)

unicode_funcs_create (parent)

unicode_funcs_get_default ()

unicode_funcs_get_empty ()

unicode_funcs_get_parent (ufuncs)

unicode_funcs_is_immutable (ufuncs)

unicode_funcs_make_immutable (ufuncs)

unicode_funcs_set_combining_class_func (ufuncs, func, *user_data)

unicode_funcs_set_compose_func (ufuncs, func, *user_data)

unicode_funcs_set_decompose_compatibility_func (ufuncs, func, *user_data)

unicode_funcs_set_decompose_func (ufuncs, func, *user_data)

unicode_funcs_set_eastasian_width_func (ufuncs, func, *user_data)

unicode_funcs_set_general_category_func (ufuncs, func, *user_data)

unicode_funcs_set_mirroring_func (ufuncs, func, *user_data)

unicode_funcs_set_script_func (ufuncs, func, *user_data)

unicode_general_category (ufuncs, unicode)

unicode_mirroring (ufuncs, unicode)

unicode_script (ufuncs, unicode)

variation_from_string (str)

variation_to_string (variation)

Details

HarfBuzz.aat_layout_feature_type_get_name_id(face, feature_type)
Parameters:
Returns:

Name identifier of the requested feature type

Return type:

int

Fetches the name identifier of the specified feature type in the face’s name table.

New in version 2.2.0.

HarfBuzz.aat_layout_feature_type_get_selector_infos(face, feature_type, start_offset)
Parameters:
Returns:

Number of all available feature selectors

selectors:

A buffer pointer. The selectors available for the feature type queries.

default_index:

The index of the feature’s default selector, if any

Return type:

(int, selectors: [HarfBuzz.aat_layout_feature_selector_info_t], default_index: int)

Fetches a list of the selectors available for the specified feature in the given face.

If upon return, default_index is set to HarfBuzz.AAT_LAYOUT_NO_SELECTOR_INDEX, then the feature type is non-exclusive. Otherwise, default_index is the index of the selector that is selected by default.

New in version 2.2.0.

HarfBuzz.aat_layout_get_feature_types(face, start_offset)
Parameters:
Returns:

Number of all available feature types.

features:

Array of feature types found

Return type:

(int, features: [HarfBuzz.aat_layout_feature_type_t])

Fetches a list of the AAT feature types included in the specified face.

New in version 2.2.0.

HarfBuzz.aat_layout_has_positioning(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests whether the specified face includes any positioning information in the kerx table.

Note: does not examine the `GPOS` table.

New in version 2.3.0.

HarfBuzz.aat_layout_has_substitution(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests whether the specified face includes any substitutions in the morx or mort tables.

Note: does not examine the `GSUB` table.

New in version 2.3.0.

HarfBuzz.aat_layout_has_tracking(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests whether the specified face includes any tracking information in the trak table.

New in version 2.3.0.

HarfBuzz.blob_copy_writable_or_fail(blob)
Parameters:

blob (HarfBuzz.blob_t) – A blob.

Returns:

The new blob, or nullptr if allocation failed

Return type:

HarfBuzz.blob_t

Makes a writable copy of blob.

New in version 1.8.0.

HarfBuzz.blob_create_from_file(file_name)
Parameters:

file_name (str) – A font filename

Returns:

An HarfBuzz.blob_t pointer with the content of the file, or HarfBuzz.blob_get_empty() if failed.

Return type:

HarfBuzz.blob_t

Creates a new blob containing the data from the specified binary font file.

New in version 1.7.7.

HarfBuzz.blob_create_from_file_or_fail(file_name)
Parameters:

file_name (str) – A font filename

Returns:

An HarfBuzz.blob_t pointer with the content of the file, or NULL if failed.

Return type:

HarfBuzz.blob_t

Creates a new blob containing the data from the specified binary font file.

New in version 2.8.2.

HarfBuzz.blob_create_sub_blob(parent, offset, length)
Parameters:
  • parent (HarfBuzz.blob_t) – Parent blob.

  • offset (int) – Start offset of sub-blob within parent, in bytes.

  • length (int) – Length of sub-blob.

Returns:

New blob, or the empty blob if something failed or if length is zero or offset is beyond the end of parent's data. Destroy with hb_blob_destroy().

Return type:

HarfBuzz.blob_t

Returns a blob that represents a range of bytes in parent. The new blob is always created with HarfBuzz.memory_mode_t.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 parent immutable.

New in version 0.9.2.

HarfBuzz.blob_get_data(blob)
Parameters:

blob (HarfBuzz.blob_t) – a blob.

Returns:

the byte data of blob.

Return type:

[str] or None

Fetches the data from a blob.

New in version 0.9.2.

HarfBuzz.blob_get_data_writable(blob)
Parameters:

blob (HarfBuzz.blob_t) – a blob.

Returns:

Writable blob data, or NULL if failed.

Return type:

[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.

New in version 0.9.2.

HarfBuzz.blob_get_empty()
Returns:

The empty blob.

Return type:

HarfBuzz.blob_t

Returns the singleton empty blob.

See TODO:link object types for more information.

New in version 0.9.2.

HarfBuzz.blob_get_length(blob)
Parameters:

blob (HarfBuzz.blob_t) – a blob.

Returns:

the length of blob data in bytes.

Return type:

int

Fetches the length of a blob’s data.

New in version 0.9.2.

HarfBuzz.blob_is_immutable(blob)
Parameters:

blob (HarfBuzz.blob_t) – a blob.

Returns:

true if blob is immutable, false otherwise

Return type:

int

Tests whether a blob is immutable.

New in version 0.9.2.

HarfBuzz.blob_make_immutable(blob)
Parameters:

blob (HarfBuzz.blob_t) – a blob

Makes a blob immutable.

New in version 0.9.2.

HarfBuzz.buffer_add(buffer, codepoint, cluster)
Parameters:

Appends a character with the Unicode value of codepoint to buffer, and gives it the initial cluster value of cluster. Clusters can be any thing the client wants, they are usually used to refer to the index of the character in the input text stream and are output in HarfBuzz.glyph_info_t.cluster field.

This function does not check the validity of codepoint, it is up to the caller to ensure it is a valid Unicode code point.

New in version 0.9.7.

HarfBuzz.buffer_add_codepoints(buffer, text, item_offset, item_length)
Parameters:
  • buffer (HarfBuzz.buffer_t) – a HarfBuzz.buffer_t to append characters to.

  • text ([int]) – an array of Unicode code points to append.

  • item_offset (int) – the offset of the first code point to add to the buffer.

  • item_length (int) – the number of code points to add to the buffer, or -1 for the end of text (assuming it is NULL terminated).

Appends characters from text array to buffer. The item_offset is the position of the first character from text that will be appended, and item_length is the number of character. When shaping part of a larger text (e.g. a run of text from a paragraph), instead of passing just the substring corresponding to the run, it is preferable to pass the whole paragraph and specify the run start and length as item_offset and item_length, respectively, to give HarfBuzz the full context to be able, for example, to do cross-run Arabic shaping or properly handle combining marks at stat of run.

This function does not check the validity of text, it is up to the caller to ensure it contains a valid Unicode scalar values. In contrast, HarfBuzz.buffer_add_utf32() can be used that takes similar input but performs sanity-check on the input.

New in version 0.9.31.

HarfBuzz.buffer_add_latin1(buffer, text, item_offset, item_length)
Parameters:
  • buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

  • text (bytes) – an array of UTF-8 characters to append

  • item_offset (int) – the offset of the first character to add to the buffer

  • item_length (int) – the number of characters to add to the buffer, or -1 for the end of text (assuming it is NULL terminated)

Similar to HarfBuzz.buffer_add_codepoints(), but allows only access to first 256 Unicode code points that can fit in 8-bit strings.

Has nothing to do with non-Unicode Latin-1 encoding.

New in version 0.9.39.

HarfBuzz.buffer_add_utf16(buffer, text, item_offset, item_length)
Parameters:
  • buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

  • text ([int]) – An array of UTF-16 characters to append

  • item_offset (int) – The offset of the first character to add to the buffer

  • item_length (int) – The number of characters to add to the buffer, or -1 for the end of text (assuming it is NULL terminated)

See HarfBuzz.buffer_add_codepoints().

Replaces invalid UTF-16 characters with the buffer replacement code point, see HarfBuzz.buffer_set_replacement_codepoint().

New in version 0.9.2.

HarfBuzz.buffer_add_utf32(buffer, text, item_offset, item_length)
Parameters:
  • buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

  • text ([int]) – An array of UTF-32 characters to append

  • item_offset (int) – The offset of the first character to add to the buffer

  • item_length (int) – The number of characters to add to the buffer, or -1 for the end of text (assuming it is NULL terminated)

See HarfBuzz.buffer_add_codepoints().

Replaces invalid UTF-32 characters with the buffer replacement code point, see HarfBuzz.buffer_set_replacement_codepoint().

New in version 0.9.2.

HarfBuzz.buffer_add_utf8(buffer, text, item_offset, item_length)
Parameters:
  • buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

  • text (bytes) – An array of UTF-8 characters to append.

  • item_offset (int) – The offset of the first character to add to the buffer.

  • item_length (int) – The number of characters to add to the buffer, or -1 for the end of text (assuming it is NULL terminated).

See HarfBuzz.buffer_add_codepoints().

Replaces invalid UTF-8 characters with the buffer replacement code point, see HarfBuzz.buffer_set_replacement_codepoint().

New in version 0.9.2.

HarfBuzz.buffer_allocation_successful(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

true if buffer memory allocation succeeded, false otherwise.

Return type:

int

Check if allocating memory for the buffer succeeded.

New in version 0.9.2.

HarfBuzz.buffer_append(buffer, source, start, end)
Parameters:

Append (part of) contents of another buffer to this buffer.

New in version 1.5.0.

HarfBuzz.buffer_clear_contents(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Similar to HarfBuzz.buffer_reset(), but does not clear the Unicode functions and the replacement code point.

New in version 0.9.11.

HarfBuzz.buffer_create()
Returns:

A newly allocated HarfBuzz.buffer_t with a reference count of 1. The initial reference count should be released with hb_buffer_destroy() when you are done using the HarfBuzz.buffer_t. This function never returns NULL. If memory cannot be allocated, a special HarfBuzz.buffer_t object will be returned on which HarfBuzz.buffer_allocation_successful() returns false.

Return type:

HarfBuzz.buffer_t

Creates a new HarfBuzz.buffer_t with all properties to defaults.

New in version 0.9.2.

HarfBuzz.buffer_create_similar(src)
Parameters:

src (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

A newly allocated HarfBuzz.buffer_t, similar to HarfBuzz.buffer_create().

Return type:

HarfBuzz.buffer_t

Creates a new HarfBuzz.buffer_t, similar to HarfBuzz.buffer_create(). The only difference is that the buffer is configured similarly to src.

New in version 3.3.0.

HarfBuzz.buffer_deserialize_glyphs(buffer, buf, font, format)
Parameters:
Returns:

true if parse was successful, false if an error occurred.

end_ptr:

output pointer to the character after last consumed one.

Return type:

(int, end_ptr: str)

Deserializes glyphs buffer from textual representation in the format produced by HarfBuzz.buffer_serialize_glyphs().

New in version 0.9.7.

HarfBuzz.buffer_deserialize_unicode(buffer, buf, format)
Parameters:
Returns:

true if parse was successful, false if an error occurred.

end_ptr:

output pointer to the character after last consumed one.

Return type:

(int, end_ptr: str)

Deserializes Unicode buffer from textual representation in the format produced by HarfBuzz.buffer_serialize_unicode().

New in version 2.7.3.

HarfBuzz.buffer_diff(buffer, reference, dottedcircle_glyph, position_fuzz)
Parameters:
  • buffer (HarfBuzz.buffer_t) – a buffer.

  • reference (HarfBuzz.buffer_t) – other buffer to compare to.

  • dottedcircle_glyph (int) – glyph id of U+25CC DOTTED CIRCLE, or (hb_codepoint_t) -1.

  • position_fuzz (int) – allowed absolute difference in position values.

Return type:

HarfBuzz.buffer_diff_flags_t

If dottedcircle_glyph is (hb_codepoint_t) -1 then HarfBuzz.buffer_diff_flags_t.DOTTED_CIRCLE_PRESENT and HarfBuzz.buffer_diff_flags_t.NOTDEF_PRESENT are never returned. This should be used by most callers if just comparing two buffers is needed.

New in version 1.5.0.

HarfBuzz.buffer_get_cluster_level(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The cluster level of buffer

Return type:

HarfBuzz.buffer_cluster_level_t

Fetches the cluster level of a buffer. The HarfBuzz.buffer_cluster_level_t dictates one aspect of how HarfBuzz will treat non-base characters during shaping.

New in version 0.9.42.

HarfBuzz.buffer_get_content_type(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The type of buffer contents

Return type:

HarfBuzz.buffer_content_type_t

Fetches the type of buffer contents. Buffers are either empty, contain characters (before shaping), or contain glyphs (the result of shaping).

New in version 0.9.5.

HarfBuzz.buffer_get_direction(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The direction of the buffer.

Return type:

HarfBuzz.direction_t

See HarfBuzz.buffer_set_direction()

New in version 0.9.2.

HarfBuzz.buffer_get_empty()
Returns:

The empty buffer

Return type:

HarfBuzz.buffer_t

Fetches an empty HarfBuzz.buffer_t.

New in version 0.9.2.

HarfBuzz.buffer_get_flags(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The buffer flags

Return type:

HarfBuzz.buffer_flags_t

Fetches the HarfBuzz.buffer_flags_t of buffer.

New in version 0.9.7.

HarfBuzz.buffer_get_glyph_infos(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The buffer glyph information array. The value valid as long as buffer has not been modified.

Return type:

[HarfBuzz.glyph_info_t]

Returns buffer glyph information array. Returned pointer is valid as long as buffer contents are not modified.

New in version 0.9.2.

HarfBuzz.buffer_get_glyph_positions(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The buffer glyph position array. The value valid as long as buffer has not been modified.

Return type:

[HarfBuzz.glyph_position_t]

Returns buffer glyph position array. Returned pointer is valid as long as buffer contents 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 HarfBuzz.buffer_set_message_func()), in which case NULL is returned.

New in version 0.9.2.

HarfBuzz.buffer_get_invisible_glyph(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The buffer invisible #hb_codepoint_t

Return type:

int

See HarfBuzz.buffer_set_invisible_glyph().

New in version 2.0.0.

HarfBuzz.buffer_get_language(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The HarfBuzz.language_t of the buffer. Must not be freed by the caller.

Return type:

HarfBuzz.language_t

See HarfBuzz.buffer_set_language().

New in version 0.9.2.

HarfBuzz.buffer_get_length(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The buffer length. The value valid as long as buffer has not been modified.

Return type:

int

Returns the number of items in the buffer.

New in version 0.9.2.

HarfBuzz.buffer_get_not_found_glyph(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The buffer not-found #hb_codepoint_t

Return type:

int

See HarfBuzz.buffer_set_not_found_glyph().

New in version 3.1.0.

HarfBuzz.buffer_get_replacement_codepoint(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The buffer replacement #hb_codepoint_t

Return type:

int

Fetches the #hb_codepoint_t that replaces invalid entries for a given encoding when adding text to buffer.

New in version 0.9.31.

HarfBuzz.buffer_get_script(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The HarfBuzz.script_t of the buffer

Return type:

HarfBuzz.script_t

Fetches the script of buffer.

New in version 0.9.2.

HarfBuzz.buffer_get_segment_properties(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The output HarfBuzz.segment_properties_t

Return type:

props: HarfBuzz.segment_properties_t

Sets props to the HarfBuzz.segment_properties_t of buffer.

New in version 0.9.7.

HarfBuzz.buffer_get_unicode_funcs(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Returns:

The Unicode-functions structure

Return type:

HarfBuzz.unicode_funcs_t

Fetches the Unicode-functions structure of a buffer.

New in version 0.9.2.

HarfBuzz.buffer_guess_segment_properties(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Sets unset buffer segment properties based on buffer Unicode contents. If buffer is not empty, it must have content type HarfBuzz.buffer_content_type_t.UNICODE.

If buffer script is not set (ie. is HarfBuzz.script_t.INVALID), it will be set to the Unicode script of the first character in the buffer that has a script other than HarfBuzz.script_t.COMMON, HarfBuzz.script_t.INHERITED, and HarfBuzz.script_t.UNKNOWN.

Next, if buffer direction is not set (ie. is HarfBuzz.direction_t.INVALID), it will be set to the natural horizontal direction of the buffer script as returned by HarfBuzz.script_get_horizontal_direction(). If HarfBuzz.script_get_horizontal_direction() returns HarfBuzz.direction_t.INVALID, then HarfBuzz.direction_t.LTR is used.

Finally, if buffer language is not set (ie. is HarfBuzz.LANGUAGE_INVALID), it will be set to the process’s default language as returned by HarfBuzz.language_get_default(). This may change in the future by taking buffer script into consideration when choosing a language. Note that HarfBuzz.language_get_default() is NOT threadsafe the first time it is called. See documentation for that function for details.

New in version 0.9.7.

HarfBuzz.buffer_has_positions(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – an HarfBuzz.buffer_t.

Returns:

true if the buffer has position array, false otherwise.

Return type:

int

Returns whether buffer has glyph position data. A buffer gains position data when HarfBuzz.buffer_get_glyph_positions() is called on it, and cleared of position data when HarfBuzz.buffer_clear_contents() is called.

New in version 2.7.3.

HarfBuzz.buffer_normalize_glyphs(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Reorders a glyph buffer to have canonical in-cluster glyph order / position. The resulting clusters should behave identical to pre-reordering clusters.

This has nothing to do with Unicode normalization.

New in version 0.9.2.

HarfBuzz.buffer_pre_allocate(buffer, size)
Parameters:
Returns:

true if buffer memory allocation succeeded, false otherwise

Return type:

int

Pre allocates memory for buffer to fit at least size number of items.

New in version 0.9.2.

HarfBuzz.buffer_reset(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Resets the buffer to its initial status, as if it was just newly created with HarfBuzz.buffer_create().

New in version 0.9.2.

HarfBuzz.buffer_reverse(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Reverses buffer contents.

New in version 0.9.2.

HarfBuzz.buffer_reverse_clusters(buffer)
Parameters:

buffer (HarfBuzz.buffer_t) – An HarfBuzz.buffer_t

Reverses buffer clusters. That is, the buffer contents are reversed, then each cluster (consecutive items having the same cluster number) are reversed again.

New in version 0.9.2.

HarfBuzz.buffer_reverse_range(buffer, start, end)
Parameters:

Reverses buffer contents between start and end.

New in version 0.9.41.

HarfBuzz.buffer_serialize(buffer, start, end, font, format, flags)
Parameters:
Returns:

The number of serialized items.

buf:

output string to write serialized buffer into.

buf_consumed:

if not NULL, will be set to the number of bytes written into buf.

Return type:

(int, buf: bytes, buf_consumed: int)

Serializes buffer into a textual representation of its content, whether Unicode codepoints or glyph identifiers and positioning information. This is useful for showing the contents of the buffer, for example during debugging. See the documentation of HarfBuzz.buffer_serialize_unicode() and HarfBuzz.buffer_serialize_glyphs() for a description of the output format.

New in version 2.7.3.

HarfBuzz.buffer_serialize_format_from_string(str)
Parameters:

str (bytes) – a string to parse

Returns:

The parsed HarfBuzz.buffer_serialize_format_t.

Return type:

HarfBuzz.buffer_serialize_format_t

Parses a string into an HarfBuzz.buffer_serialize_format_t. Does not check if str is a valid buffer serialization format, use HarfBuzz.buffer_serialize_list_formats() to get the list of supported formats.

New in version 0.9.7.

HarfBuzz.buffer_serialize_format_to_string(format)
Parameters:

format (HarfBuzz.buffer_serialize_format_t) – an HarfBuzz.buffer_serialize_format_t to convert.

Returns:

A NULL terminated string corresponding to format. Should not be freed.

Return type:

str

Converts format to the string corresponding it, or NULL if it is not a valid HarfBuzz.buffer_serialize_format_t.

New in version 0.9.7.

HarfBuzz.buffer_serialize_glyphs(buffer, start, end, font, format, flags)
Parameters:
Returns:

The number of serialized items.

buf:

output string to write serialized buffer into.

buf_consumed:

if not NULL, will be set to the number of bytes written into buf.

Return type:

(int, buf: bytes, buf_consumed: int)

Serializes buffer into a textual representation of its glyph content, useful for showing the contents of the buffer, for example during debugging. There are currently two supported serialization formats:

text

A human-readable, plain text format. The serialized glyphs will look something like:

`` [uni0651=0@518,0+0|uni0628=0+1897] ``

json

A machine-readable, structured format. The serialized glyphs will look something like:

`` [{“g”:”uni0651”,”cl”:0,”dx”:518,”dy”:0,”ax”:0,”ay”:0}, {“g”:”uni0628”,”cl”:0,”dx”:0,”dy”:0,”ax”:1897,”ay”:0}] ``

Each glyph is a JSON object, with the following properties:

New in version 0.9.7.

HarfBuzz.buffer_serialize_list_formats()
Returns:

A string array of buffer serialization formats. Should not be freed.

Return type:

[str]

Returns a list of supported buffer serialization formats.

New in version 0.9.7.

HarfBuzz.buffer_serialize_unicode(buffer, start, end, format, flags)
Parameters:
Returns:

The number of serialized items.

buf:

output string to write serialized buffer into.

buf_consumed:

if not NULL, will be set to the number of bytes written into buf.

Return type:

(int, buf: bytes, buf_consumed: int)

Serializes buffer into a textual representation of its content, when the buffer contains Unicode codepoints (i.e., before shaping). This is useful for showing the contents of the buffer, for example during debugging. There are currently two supported serialization formats:

text

A human-readable, plain text format. The serialized codepoints will look something like:

``  <U+0651=0|U+0628=1> ``

json

A machine-readable, structured format. The serialized codepoints will be a list of objects with the following properties:

For example:

`` [{u:1617,cl:0},{u:1576,cl:1}] ``

New in version 2.7.3.

HarfBuzz.buffer_set_cluster_level(buffer, cluster_level)
Parameters:

Sets the cluster level of a buffer. The HarfBuzz.buffer_cluster_level_t dictates one aspect of how HarfBuzz will treat non-base characters during shaping.

New in version 0.9.42.

HarfBuzz.buffer_set_content_type(buffer, content_type)
Parameters:

Sets the type of buffer contents. 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:

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.

New in version 0.9.5.

HarfBuzz.buffer_set_direction(buffer, direction)
Parameters:

Set the text flow direction of the buffer. No shaping can happen without setting buffer direction, and it controls the visual direction for the output glyphs; for RTL direction the glyphs will be reversed. Many layout features depend on the proper setting of the direction, for example, reversing RTL text before shaping, then shaping with LTR direction is not the same as keeping the text in logical order and shaping with RTL direction.

New in version 0.9.2.

HarfBuzz.buffer_set_flags(buffer, flags)
Parameters:

Sets buffer flags to flags. See HarfBuzz.buffer_flags_t.

New in version 0.9.7.

HarfBuzz.buffer_set_invisible_glyph(buffer, invisible)
Parameters:

Sets the #hb_codepoint_t that replaces invisible characters in the shaping result. If set to zero (default), the glyph for the U+0020 SPACE character is used. Otherwise, this value is used verbatim.

New in version 2.0.0.

HarfBuzz.buffer_set_language(buffer, language)
Parameters:

Sets the language of buffer to language.

Languages are crucial for selecting which OpenType feature to apply to the buffer which can result in applying language-specific behaviour. Languages are orthogonal to the scripts, and though they are related, they are different concepts and should not be confused with each other.

Use HarfBuzz.language_from_string() to convert from BCP 47 language tags to HarfBuzz.language_t.

New in version 0.9.2.

HarfBuzz.buffer_set_length(buffer, length)
Parameters:
Returns:

true if buffer memory allocation succeeded, false otherwise.

Return type:

int

Similar to HarfBuzz.buffer_pre_allocate(), but clears any new items added at the end.

New in version 0.9.2.

HarfBuzz.buffer_set_message_func(buffer, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.buffer_message_func_t.

New in version 1.1.3.

HarfBuzz.buffer_set_not_found_glyph(buffer, not_found)
Parameters:

Sets the #hb_codepoint_t that 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.

New in version 3.1.0.

HarfBuzz.buffer_set_replacement_codepoint(buffer, replacement)
Parameters:

Sets the #hb_codepoint_t that replaces invalid entries for a given encoding when adding text to buffer.

Default is HarfBuzz.BUFFER_REPLACEMENT_CODEPOINT_DEFAULT.

New in version 0.9.31.

HarfBuzz.buffer_set_script(buffer, script)
Parameters:

Sets the script of buffer to script.

Script is crucial for choosing the proper shaping behaviour for scripts that require it (e.g. Arabic) and the which OpenType features defined in the font to be applied.

You can pass one of the predefined HarfBuzz.script_t values, or use HarfBuzz.script_from_string() or HarfBuzz.script_from_iso15924_tag() to get the corresponding script from an ISO 15924 script tag.

New in version 0.9.2.

HarfBuzz.buffer_set_segment_properties(buffer, props)
Parameters:

Sets the segment properties of the buffer, a shortcut for calling HarfBuzz.buffer_set_direction(), HarfBuzz.buffer_set_script() and HarfBuzz.buffer_set_language() individually.

New in version 0.9.7.

HarfBuzz.buffer_set_unicode_funcs(buffer, unicode_funcs)
Parameters:

Sets the Unicode-functions structure of a buffer to unicode_funcs.

New in version 0.9.2.

HarfBuzz.color_get_alpha(color)
Parameters:

color (int) – an #hb_color_t we are interested in its channels.

Returns:

Alpha channel value

Return type:

int

Fetches the alpha channel of the given color.

New in version 2.1.0.

HarfBuzz.color_get_blue(color)
Parameters:

color (int) – an #hb_color_t we are interested in its channels.

Returns:

Blue channel value

Return type:

int

Fetches the blue channel of the given color.

New in version 2.1.0.

HarfBuzz.color_get_green(color)
Parameters:

color (int) – an #hb_color_t we are interested in its channels.

Returns:

Green channel value

Return type:

int

Fetches the green channel of the given color.

New in version 2.1.0.

HarfBuzz.color_get_red(color)
Parameters:

color (int) – an #hb_color_t we are interested in its channels.

Returns:

Red channel value

Return type:

int

Fetches the red channel of the given color.

New in version 2.1.0.

HarfBuzz.color_line_get_color_stops(color_line, start)
Parameters:
Returns:

the total number of color stops in color_line

color_stops:

Array of HarfBuzz.color_stop_t to populate

Return type:

(int, color_stops: [HarfBuzz.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.

New in version 7.0.0.

HarfBuzz.color_line_get_extend(color_line)
Parameters:

color_line (HarfBuzz.color_line_t) – a HarfBuzz.color_line_t object

Returns:

the extend mode of color_line

Return type:

HarfBuzz.paint_extend_t

Fetches the extend mode of the color line object.

New in version 7.0.0.

HarfBuzz.direction_from_string(str)
Parameters:

str (bytes) – String to convert

Returns:

The HarfBuzz.direction_t matching str

Return type:

HarfBuzz.direction_t

Converts a string to an HarfBuzz.direction_t.

Matching is loose and applies only to the first letter. For examples, “LTR” and “left-to-right” will both return HarfBuzz.direction_t.LTR.

Unmatched strings will return HarfBuzz.direction_t.INVALID.

New in version 0.9.2.

HarfBuzz.direction_to_string(direction)
Parameters:

direction (HarfBuzz.direction_t) – The HarfBuzz.direction_t to convert

Returns:

The string corresponding to direction

Return type:

str

Converts an HarfBuzz.direction_t to a string.

New in version 0.9.2.

HarfBuzz.draw_close_path(dfuncs, draw_data, st)
Parameters:

Perform a “close-path” draw operation.

New in version 4.0.0.

HarfBuzz.draw_cubic_to(dfuncs, draw_data, st, control1_x, control1_y, control2_x, control2_y, to_x, to_y)
Parameters:
  • dfuncs (HarfBuzz.draw_funcs_t) – draw functions

  • draw_data (object or None) – associated draw data passed by the caller

  • st (HarfBuzz.draw_state_t) – current draw state

  • control1_x (float) – X component of first control point

  • control1_y (float) – Y component of first control point

  • control2_x (float) – X component of second control point

  • control2_y (float) – Y component of second control point

  • to_x (float) – X component of target point

  • to_y (float) – Y component of target point

Perform a “cubic-to” draw operation.

New in version 4.0.0.

HarfBuzz.draw_funcs_create()
Returns:

A newly allocated HarfBuzz.draw_funcs_t with a reference count of 1. The initial reference count should be released with hb_draw_funcs_destroy when you are done using the HarfBuzz.draw_funcs_t. This function never returns NULL. If memory cannot be allocated, a special singleton HarfBuzz.draw_funcs_t object will be returned.

Return type:

HarfBuzz.draw_funcs_t

Creates a new draw callbacks object.

New in version 4.0.0.

HarfBuzz.draw_funcs_get_empty()
Returns:

The empty draw-functions structure

Return type:

HarfBuzz.draw_funcs_t

Fetches the singleton empty draw-functions structure.

New in version 7.0.0.

HarfBuzz.draw_funcs_is_immutable(dfuncs)
Parameters:

dfuncs (HarfBuzz.draw_funcs_t) – draw functions

Returns:

true if dfuncs is immutable, false otherwise

Return type:

int

Checks whether dfuncs is immutable.

New in version 4.0.0.

HarfBuzz.draw_funcs_make_immutable(dfuncs)
Parameters:

dfuncs (HarfBuzz.draw_funcs_t) – draw functions

Makes dfuncs object immutable.

New in version 4.0.0.

HarfBuzz.draw_funcs_set_close_path_func(dfuncs, func, *user_data)
Parameters:

Sets close-path callback to the draw functions object.

New in version 4.0.0.

HarfBuzz.draw_funcs_set_cubic_to_func(dfuncs, func, *user_data)
Parameters:

Sets cubic-to callback to the draw functions object.

New in version 4.0.0.

HarfBuzz.draw_funcs_set_line_to_func(dfuncs, func, *user_data)
Parameters:

Sets line-to callback to the draw functions object.

New in version 4.0.0.

HarfBuzz.draw_funcs_set_move_to_func(dfuncs, func, *user_data)
Parameters:

Sets move-to callback to the draw functions object.

New in version 4.0.0.

HarfBuzz.draw_funcs_set_quadratic_to_func(dfuncs, func, *user_data)
Parameters:

Sets quadratic-to callback to the draw functions object.

New in version 4.0.0.

HarfBuzz.draw_line_to(dfuncs, draw_data, st, to_x, to_y)
Parameters:

Perform a “line-to” draw operation.

New in version 4.0.0.

HarfBuzz.draw_move_to(dfuncs, draw_data, st, to_x, to_y)
Parameters:

Perform a “move-to” draw operation.

New in version 4.0.0.

HarfBuzz.draw_quadratic_to(dfuncs, draw_data, st, control_x, control_y, to_x, to_y)
Parameters:
  • dfuncs (HarfBuzz.draw_funcs_t) – draw functions

  • draw_data (object or None) – associated draw data passed by the caller

  • st (HarfBuzz.draw_state_t) – current draw state

  • control_x (float) – X component of control point

  • control_y (float) – Y component of control point

  • to_x (float) – X component of target point

  • to_y (float) – Y component of target point

Perform a “quadratic-to” draw operation.

New in version 4.0.0.

HarfBuzz.face_builder_add_table(face, tag, blob)
Parameters:
Return type:

int

Add table for tag with data provided by blob to the face. face must be created using HarfBuzz.face_builder_create().

New in version 1.9.0.

HarfBuzz.face_builder_create()
Returns:

New face.

Return type:

HarfBuzz.face_t

Creates a HarfBuzz.face_t that can be used with HarfBuzz.face_builder_add_table(). After tables are added to the face, it can be compiled to a binary font file by calling HarfBuzz.face_reference_blob().

New in version 1.9.0.

HarfBuzz.face_builder_sort_tables(face, tags)
Parameters:

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.

New in version 5.3.0.

HarfBuzz.face_collect_nominal_glyph_mapping(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Returns:

mapping:

The map to add Unicode-to-glyph mapping to

unicodes:

The set to add Unicode characters to, or NULL

Return type:

(mapping: HarfBuzz.map_t, unicodes: HarfBuzz.set_t or None)

Collects the mapping from Unicode characters to nominal glyphs of the face, and optionally all of the Unicode characters covered by face.

New in version 7.0.0.

HarfBuzz.face_collect_unicodes(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Returns:

The set to add Unicode characters to

Return type:

out: HarfBuzz.set_t

Collects all of the Unicode characters covered by face and adds them to the HarfBuzz.set_t set out.

New in version 1.9.0.

HarfBuzz.face_collect_variation_selectors(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Returns:

The set to add Variation Selector characters to

Return type:

out: HarfBuzz.set_t

Collects all Unicode “Variation Selector” characters covered by face and adds them to the HarfBuzz.set_t set out.

New in version 1.9.0.

HarfBuzz.face_collect_variation_unicodes(face, variation_selector)
Parameters:
  • face (HarfBuzz.face_t) – A face object

  • variation_selector (int) – The Variation Selector to query

Returns:

The set to add Unicode characters to

Return type:

out: HarfBuzz.set_t

Collects all Unicode characters for variation_selector covered by face and adds them to the HarfBuzz.set_t set out.

New in version 1.9.0.

HarfBuzz.face_count(blob)
Parameters:

blob (HarfBuzz.blob_t) – a blob.

Returns:

Number of faces in blob

Return type:

int

Fetches the number of faces in a blob.

New in version 1.7.7.

HarfBuzz.face_create(blob, index)
Parameters:
Returns:

The new face object

Return type:

HarfBuzz.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: If the blob font format is not a collection, index is ignored. Otherwise, only the lower 16-bits of index are used. The unmodified index can be accessed via HarfBuzz.face_get_index(). Note: The high 16-bits of index, if non-zero, are used by HarfBuzz.font_create() to load named-instances in variable fonts. See HarfBuzz.font_create() for details.

New in version 0.9.2.

HarfBuzz.face_create_for_tables(reference_table_func, *user_data)
Parameters:
Returns:

The new face object

Return type:

HarfBuzz.face_t

Variant of HarfBuzz.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 that HarfBuzz.face_get_table_tags() does not currently work with faces created this way.

Creates a new face object from the specified user_data and reference_table_func, with the destroy callback.

New in version 0.9.2.

HarfBuzz.face_get_empty()
Returns:

The empty face object

Return type:

HarfBuzz.face_t

Fetches the singleton empty face object.

New in version 0.9.2.

HarfBuzz.face_get_glyph_count(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Returns:

The glyph-count value of face

Return type:

int

Fetches the glyph-count value of the specified face object.

New in version 0.9.7.

HarfBuzz.face_get_index(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Returns:

The index of face.

Return type:

int

Fetches the face-index corresponding to the given face.

Note: face indices within a collection are zero-based.

New in version 0.9.2.

HarfBuzz.face_get_table_tags(face, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – A face object

  • start_offset (int) – The index of first table tag to retrieve

Returns:

Total number of tables, or zero if it is not possible to list

table_tags:

The array of table tags found

Return type:

(int, table_tags: [int])

Fetches a list of all table tags for a face, if possible. The list returned will begin at the offset provided

New in version 1.6.0.

HarfBuzz.face_get_upem(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Returns:

The upem value of face

Return type:

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.

New in version 0.9.2.

HarfBuzz.face_is_immutable(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Returns:

true is face is immutable, false otherwise

Return type:

int

Tests whether the given face object is immutable.

New in version 0.9.2.

HarfBuzz.face_make_immutable(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Makes the given face object immutable.

New in version 0.9.2.

HarfBuzz.face_reference_blob(face)
Parameters:

face (HarfBuzz.face_t) – A face object

Returns:

A pointer to the blob for face

Return type:

HarfBuzz.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.

New in version 0.9.2.

HarfBuzz.face_reference_table(face, tag)
Parameters:
  • face (HarfBuzz.face_t) – A face object

  • tag (int) – The #hb_tag_t of the table to query

Returns:

A pointer to the tag table within face

Return type:

HarfBuzz.blob_t

Fetches a reference to the specified table within the specified face.

New in version 0.9.2.

HarfBuzz.face_set_glyph_count(face, glyph_count)
Parameters:
  • face (HarfBuzz.face_t) – A face object

  • glyph_count (int) – The glyph-count value to assign

Sets the glyph count for a face object to the specified value.

This API is used in rare circumstances.

New in version 0.9.7.

HarfBuzz.face_set_index(face, index)
Parameters:

Assigns the specified face-index to face. Fails if the face is immutable.

Note: changing the index has no effect on the face itself This only changes the value returned by HarfBuzz.face_get_index().

New in version 0.9.2.

HarfBuzz.face_set_upem(face, upem)
Parameters:
  • face (HarfBuzz.face_t) – A face object

  • upem (int) – The units-per-em value to assign

Sets the units-per-em (upem) for a face object to the specified value.

This API is used in rare circumstances.

New in version 0.9.2.

HarfBuzz.feature_from_string(str)
Parameters:

str (bytes) – a string to parse

Returns:

true if str is successfully parsed, false otherwise

feature:

the HarfBuzz.feature_t to initialize with the parsed values

Return type:

(int, feature: HarfBuzz.feature_t)

Parses a string into a HarfBuzz.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:

Syntax Value Start End

Setting value: kern 1 0 ∞ Turn feature on +kern 1 0 ∞ Turn feature on -kern 0 0 ∞ Turn feature off kern=0 0 0 ∞ Turn feature off kern=1 1 0 ∞ Turn feature on aalt=2 2 0 ∞ Choose 2nd alternate Setting index: kern[] 1 0 ∞ Turn feature on kern[:] 1 0 ∞ Turn feature on kern[5:] 1 5 ∞ Turn feature on, partial kern[:5] 1 0 5 Turn feature on, partial kern[3:5] 1 3 5 Turn feature on, range kern[3] 1 3 3+1 Turn feature on, single str Mixing it all: aalt[3:5]=2 2 3 5 Turn 2nd alternate on for range

New in version 0.9.5.

HarfBuzz.feature_to_string(feature)
Parameters:

feature (HarfBuzz.feature_t) – an HarfBuzz.feature_t to convert

Returns:

output string

Return type:

buf: [str]

Converts a HarfBuzz.feature_t into a NULL-terminated string in the format understood by HarfBuzz.feature_from_string(). The client in responsible for allocating big enough size for buf, 128 bytes is more than enough.

New in version 0.9.5.

HarfBuzz.font_add_glyph_origin_for_direction(font, glyph, direction, x, y)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • glyph (int) – The glyph ID to query

  • direction (HarfBuzz.direction_t) – The direction of the text segment

  • x (int) – Input = The original X coordinate Output = The X coordinate plus the X-coordinate of the origin

  • y (int) – Input = The original Y coordinate Output = The Y coordinate plus the Y-coordinate of the origin

Returns:

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

Return type:

(x: int, y: 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.

New in version 0.9.2.

HarfBuzz.font_changed(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Notifies the font that underlying font data has changed. This has the effect of increasing the serial as returned by HarfBuzz.font_get_serial(), which invalidates internal caches.

New in version 4.4.0.

HarfBuzz.font_create(face)
Parameters:

face (HarfBuzz.face_t) – a face.

Returns:

The new font object

Return type:

HarfBuzz.font_t

Constructs a new font object from the specified face.

Note: If face's index value (as passed to HarfBuzz.face_create() has non-zero top 16-bits, those bits minus one are passed to HarfBuzz.font_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.

New in version 0.9.2.

HarfBuzz.font_create_sub_font(parent)
Parameters:

parent (HarfBuzz.font_t) – The parent font object

Returns:

The new sub-font font object

Return type:

HarfBuzz.font_t

Constructs a sub-font font object from the specified parent font, replicating the parent’s properties.

New in version 0.9.2.

HarfBuzz.font_draw_glyph(font, glyph, dfuncs, draw_data)
Parameters:

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 dfuncs objects, with draw_data passed to them.

New in version 7.0.0.

HarfBuzz.font_funcs_create()
Returns:

The font-functions structure

Return type:

HarfBuzz.font_funcs_t

Creates a new HarfBuzz.font_funcs_t structure of font functions.

New in version 0.9.2.

HarfBuzz.font_funcs_get_empty()
Returns:

The font-functions structure

Return type:

HarfBuzz.font_funcs_t

Fetches an empty font-functions structure.

New in version 0.9.2.

HarfBuzz.font_funcs_is_immutable(ffuncs)
Parameters:

ffuncs (HarfBuzz.font_funcs_t) – The font-functions structure

Returns:

true if ffuncs is immutable, false otherwise

Return type:

int

Tests whether a font-functions structure is immutable.

New in version 0.9.2.

HarfBuzz.font_funcs_make_immutable(ffuncs)
Parameters:

ffuncs (HarfBuzz.font_funcs_t) – The font-functions structure

Makes a font-functions structure immutable.

New in version 0.9.2.

HarfBuzz.font_funcs_set_draw_glyph_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_draw_glyph_func_t.

New in version 7.0.0.

HarfBuzz.font_funcs_set_font_h_extents_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_font_h_extents_func_t.

New in version 1.1.2.

HarfBuzz.font_funcs_set_font_v_extents_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_font_v_extents_func_t.

New in version 1.1.2.

HarfBuzz.font_funcs_set_glyph_contour_point_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_get_glyph_contour_point_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_glyph_extents_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_get_glyph_extents_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_glyph_from_name_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_get_glyph_from_name_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_glyph_func(ffuncs, func, *user_data)
Parameters:

Deprecated. Use HarfBuzz.font_funcs_set_nominal_glyph_func() and HarfBuzz.font_funcs_set_variation_glyph_func() instead.

New in version 0.9.2.

Deprecated since version 1.2.3.

HarfBuzz.font_funcs_set_glyph_h_advance_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_glyph_h_advance_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_glyph_h_advances_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_glyph_h_advances_func_t.

New in version 1.8.6.

HarfBuzz.font_funcs_set_glyph_h_kerning_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_glyph_h_kerning_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_glyph_h_origin_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_glyph_h_origin_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_glyph_name_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_get_glyph_name_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_glyph_shape_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_get_glyph_shape_func_t, which is the same as HarfBuzz.font_draw_glyph_func_t.

New in version 4.0.0.

Deprecated since version 7.0.0: Use HarfBuzz.font_funcs_set_draw_glyph_func() instead

HarfBuzz.font_funcs_set_glyph_v_advance_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_glyph_v_advance_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_glyph_v_advances_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_glyph_v_advances_func_t.

New in version 1.8.6.

HarfBuzz.font_funcs_set_glyph_v_kerning_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_glyph_v_kerning_func_t.

New in version 0.9.2.

Deprecated since version 2.0.0.

HarfBuzz.font_funcs_set_glyph_v_origin_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for #hb_font_get_glyph_v_origin_func_t.

New in version 0.9.2.

HarfBuzz.font_funcs_set_nominal_glyph_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_get_nominal_glyph_func_t.

New in version 1.2.3.

HarfBuzz.font_funcs_set_nominal_glyphs_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_get_nominal_glyphs_func_t.

New in version 2.0.0.

HarfBuzz.font_funcs_set_paint_glyph_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_paint_glyph_func_t.

New in version 7.0.0.

HarfBuzz.font_funcs_set_variation_glyph_func(ffuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.font_get_variation_glyph_func_t.

New in version 1.2.3.

HarfBuzz.font_get_empty()
Returns:

The empty font object

Return type:

HarfBuzz.font_t

Fetches the empty font object.

New in version 0.9.2.

HarfBuzz.font_get_extents_for_direction(font, direction)
Parameters:
Returns:

The HarfBuzz.font_extents_t retrieved

Return type:

extents: HarfBuzz.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.

New in version 1.1.3.

HarfBuzz.font_get_face(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

The HarfBuzz.face_t value

Return type:

HarfBuzz.face_t

Fetches the face associated with the specified font object.

New in version 0.9.2.

HarfBuzz.font_get_glyph(font, unicode, variation_selector)
Parameters:
Returns:

true if data found, false otherwise

glyph:

The glyph ID retrieved

Return type:

(int, glyph: int)

Fetches the glyph ID for a Unicode code point in the specified font, with an optional variation selector.

If variation_selector is 0, calls HarfBuzz.font_get_nominal_glyph(); otherwise calls HarfBuzz.font_get_variation_glyph().

New in version 0.9.2.

HarfBuzz.font_get_glyph_advance_for_direction(font, glyph, direction)
Parameters:
Returns:

x:

The horizontal advance retrieved

y:

The vertical advance retrieved

Return type:

(x: int, y: 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.

New in version 0.9.2.

HarfBuzz.font_get_glyph_advances_for_direction(font, direction, count, first_glyph, glyph_stride)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • direction (HarfBuzz.direction_t) – The direction of the text segment

  • count (int) – The number of glyph IDs in the sequence queried

  • first_glyph (int) – The first glyph ID to query

  • glyph_stride (int) – The stride between successive glyph IDs

Returns:

first_advance:

The first advance retrieved

advance_stride:

The stride between successive advances

Return type:

(first_advance: int, advance_stride: 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.

New in version 1.8.6.

HarfBuzz.font_get_glyph_contour_point(font, glyph, point_index)
Parameters:
Returns:

true if data found, false otherwise

x:

The X value retrieved for the contour point

y:

The Y value retrieved for the contour point

Return type:

(int, x: int, y: int)

Fetches the (x,y) coordinates of a specified contour-point index in the specified glyph, within the specified font.

New in version 0.9.2.

HarfBuzz.font_get_glyph_contour_point_for_origin(font, glyph, point_index, direction)
Parameters:
Returns:

true if data found, false otherwise

x:

The X value retrieved for the contour point

y:

The Y value retrieved for the contour point

Return type:

(int, x: int, y: 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.

New in version 0.9.2.

HarfBuzz.font_get_glyph_extents(font, glyph)
Parameters:
Returns:

true if data found, false otherwise

extents:

The HarfBuzz.glyph_extents_t retrieved

Return type:

(int, extents: HarfBuzz.glyph_extents_t)

Fetches the HarfBuzz.glyph_extents_t data for a glyph ID in the specified font.

New in version 0.9.2.

HarfBuzz.font_get_glyph_extents_for_origin(font, glyph, direction)
Parameters:
Returns:

true if data found, false otherwise

extents:

The HarfBuzz.glyph_extents_t retrieved

Return type:

(int, extents: HarfBuzz.glyph_extents_t)

Fetches the HarfBuzz.glyph_extents_t data 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.

New in version 0.9.2.

HarfBuzz.font_get_glyph_from_name(font, name)
Parameters:
Returns:

true if data found, false otherwise

glyph:

The glyph ID retrieved

Return type:

(int, glyph: int)

Fetches the glyph ID that corresponds to a name string in the specified font.

Note: len == -1 means the name string is null-terminated.

New in version 0.9.2.

HarfBuzz.font_get_glyph_h_advance(font, glyph)
Parameters:
Returns:

The advance of glyph within font

Return type:

int

Fetches the advance for a glyph ID in the specified font, for horizontal text segments.

New in version 0.9.2.

HarfBuzz.font_get_glyph_h_advances(font, count, first_glyph, glyph_stride, advance_stride)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • count (int) – The number of glyph IDs in the sequence queried

  • first_glyph (int) – The first glyph ID to query

  • glyph_stride (int) – The stride between successive glyph IDs

  • advance_stride (int) – The stride between successive advances

Returns:

The first advance retrieved

Return type:

first_advance: int

Fetches the advances for a sequence of glyph IDs in the specified font, for horizontal text segments.

New in version 1.8.6.

HarfBuzz.font_get_glyph_h_kerning(font, left_glyph, right_glyph)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • left_glyph (int) – The glyph ID of the left glyph in the glyph pair

  • right_glyph (int) – The glyph ID of the right glyph in the glyph pair

Returns:

The kerning adjustment value

Return type:

int

Fetches the kerning-adjustment value for a glyph-pair in the specified font, for horizontal text segments.

It handles legacy kerning only (as returned by the corresponding HarfBuzz.font_funcs_t function).

New in version 0.9.2.

HarfBuzz.font_get_glyph_h_origin(font, glyph)
Parameters:
Returns:

true if data found, false otherwise

x:

The X coordinate of the origin

y:

The Y coordinate of the origin

Return type:

(int, x: int, y: int)

Fetches the (X,Y) coordinates of the origin for a glyph ID in the specified font, for horizontal text segments.

New in version 0.9.2.

HarfBuzz.font_get_glyph_kerning_for_direction(font, first_glyph, second_glyph, direction)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • first_glyph (int) – The glyph ID of the first glyph in the glyph pair to query

  • second_glyph (int) – The glyph ID of the second glyph in the glyph pair to query

  • direction (HarfBuzz.direction_t) – The direction of the text segment

Returns:

x:

The horizontal kerning-adjustment value retrieved

y:

The vertical kerning-adjustment value retrieved

Return type:

(x: int, y: 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.

New in version 0.9.2.

HarfBuzz.font_get_glyph_name(font, glyph)
Parameters:
Returns:

true if data found, false otherwise

name:

Name string retrieved for the glyph ID

Return type:

(int, name: [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.

New in version 0.9.2.

HarfBuzz.font_get_glyph_origin_for_direction(font, glyph, direction)
Parameters:
Returns:

x:

The X coordinate retrieved for the origin

y:

The Y coordinate retrieved for the origin

Return type:

(x: int, y: 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.

New in version 0.9.2.

HarfBuzz.font_get_glyph_shape(font, glyph, dfuncs, draw_data)
Parameters:

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 the dfuncs objects, with draw_data passed to them.

New in version 4.0.0.

Deprecated since version 7.0.0: Use HarfBuzz.font_draw_glyph() instead

HarfBuzz.font_get_glyph_v_advance(font, glyph)
Parameters:
Returns:

The advance of glyph within font

Return type:

int

Fetches the advance for a glyph ID in the specified font, for vertical text segments.

New in version 0.9.2.

HarfBuzz.font_get_glyph_v_advances(font, count, first_glyph, glyph_stride)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • count (int) – The number of glyph IDs in the sequence queried

  • first_glyph (int) – The first glyph ID to query

  • glyph_stride (int) – The stride between successive glyph IDs

Returns:

first_advance:

The first advance retrieved

advance_stride:

The stride between successive advances

Return type:

(first_advance: int, advance_stride: int)

Fetches the advances for a sequence of glyph IDs in the specified font, for vertical text segments.

New in version 1.8.6.

HarfBuzz.font_get_glyph_v_kerning(font, top_glyph, bottom_glyph)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • top_glyph (int) – The glyph ID of the top glyph in the glyph pair

  • bottom_glyph (int) – The glyph ID of the bottom glyph in the glyph pair

Returns:

The kerning adjustment value

Return type:

int

Fetches the kerning-adjustment value for a glyph-pair in the specified font, for vertical text segments.

It handles legacy kerning only (as returned by the corresponding HarfBuzz.font_funcs_t function).

New in version 0.9.2.

Deprecated since version 2.0.0.

HarfBuzz.font_get_glyph_v_origin(font, glyph)
Parameters:
Returns:

true if data found, false otherwise

x:

The X coordinate of the origin

y:

The Y coordinate of the origin

Return type:

(int, x: int, y: int)

Fetches the (X,Y) coordinates of the origin for a glyph ID in the specified font, for vertical text segments.

New in version 0.9.2.

HarfBuzz.font_get_h_extents(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

true if data found, false otherwise

extents:

The font extents retrieved

Return type:

(int, extents: HarfBuzz.font_extents_t)

Fetches the extents for a specified font, for horizontal text segments.

New in version 1.1.3.

HarfBuzz.font_get_nominal_glyph(font, unicode)
Parameters:
Returns:

true if data found, false otherwise

glyph:

The glyph ID retrieved

Return type:

(int, glyph: 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 HarfBuzz.font_get_variation_glyph() or use HarfBuzz.font_get_glyph().

New in version 1.2.3.

HarfBuzz.font_get_nominal_glyphs(font, count, first_unicode, unicode_stride, glyph_stride)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • count (int) – number of code points to query

  • first_unicode (int) – The first Unicode code point to query

  • unicode_stride (int) – The stride between successive code points

  • glyph_stride (int) – The stride between successive glyph IDs

Returns:

the number of code points processed

first_glyph:

The first glyph ID retrieved

Return type:

(int, first_glyph: int)

Fetches the nominal glyph IDs for a sequence of Unicode code points. Glyph IDs must be returned in a #hb_codepoint_t output parameter. Stops at the first unsupported glyph ID.

New in version 2.6.3.

HarfBuzz.font_get_parent(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

The parent font object

Return type:

HarfBuzz.font_t

Fetches the parent font of font.

New in version 0.9.2.

HarfBuzz.font_get_ppem(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

x_ppem:

Horizontal ppem value

y_ppem:

Vertical ppem value

Return type:

(x_ppem: int, y_ppem: int)

Fetches the horizontal and vertical points-per-em (ppem) of a font.

New in version 0.9.2.

HarfBuzz.font_get_ptem(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

Point size. A value of zero means “not set.”

Return type:

float

Fetches the “point size” of a font. Used in CoreText to implement optical sizing.

New in version 1.6.0.

HarfBuzz.font_get_scale(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

x_scale:

Horizontal scale value

y_scale:

Vertical scale value

Return type:

(x_scale: int, y_scale: int)

Fetches the horizontal and vertical scale of a font.

New in version 0.9.2.

HarfBuzz.font_get_serial(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

serial number

Return type:

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.

New in version 4.4.0.

HarfBuzz.font_get_synthetic_bold(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

x_embolden:

return location for horizontal value

y_embolden:

return location for vertical value

in_place:

return location for in-place value

Return type:

(x_embolden: float, y_embolden: float, in_place: int)

Fetches the “synthetic boldness” parameters of a font.

New in version 7.0.0.

HarfBuzz.font_get_synthetic_slant(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

Synthetic slant. By default is zero.

Return type:

float

Fetches the “synthetic slant” of a font.

New in version 3.3.0.

HarfBuzz.font_get_v_extents(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

true if data found, false otherwise

extents:

The font extents retrieved

Return type:

(int, extents: HarfBuzz.font_extents_t)

Fetches the extents for a specified font, for vertical text segments.

New in version 1.1.3.

HarfBuzz.font_get_var_coords_design(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

coordinates array

length:

Number of coordinates retrieved

Return type:

(float, length: 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.

New in version 3.3.0.

HarfBuzz.font_get_var_coords_normalized(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

coordinates array

length:

Number of coordinates retrieved

Return type:

(int, length: 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.

New in version 1.4.2.

HarfBuzz.font_get_var_named_instance(font)
Parameters:

font (HarfBuzz.font_t) – a font.

Returns:

Named-instance index or HarfBuzz.FONT_NO_VAR_NAMED_INSTANCE.

Return type:

int

Returns the currently-set named-instance index of the font.

New in version 7.0.0.

HarfBuzz.font_get_variation_glyph(font, unicode, variation_selector)
Parameters:
Returns:

true if data found, false otherwise

glyph:

The glyph ID retrieved

Return type:

(int, glyph: int)

Fetches the glyph ID for a Unicode code point when followed by by the specified variation-selector code point, in the specified font.

New in version 1.2.3.

HarfBuzz.font_glyph_from_string(font, s)
Parameters:
Returns:

true if data found, false otherwise

glyph:

The glyph ID corresponding to the string requested

Return type:

(int, glyph: int)

Fetches the glyph ID from font that matches the specified string. Strings of the format gidDDD or uniUUUU are parsed automatically.

Note: len == -1 means the string is null-terminated.

New in version 0.9.2.

HarfBuzz.font_glyph_to_string(font, glyph)
Parameters:
Returns:

The string containing the glyph name

Return type:

s: [str]

Fetches the name of the specified glyph ID in font and returns it in string s.

If the glyph ID has no name in font, a string of the form gidDDD is generated, with DDD being the glyph ID.

According to the OpenType specification, glyph names are limited to 63 characters and can only contain (a subset of) ASCII.

New in version 0.9.2.

HarfBuzz.font_is_immutable(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

true if font is immutable, false otherwise

Return type:

int

Tests whether a font object is immutable.

New in version 0.9.2.

HarfBuzz.font_make_immutable(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Makes font immutable.

New in version 0.9.2.

HarfBuzz.font_paint_glyph(font, glyph, pfuncs, paint_data, palette_index, foreground)
Parameters:

Paints the glyph.

The painting instructions are returned by way of calls to the callbacks of the funcs object, with paint_data passed to them.

If the font has color palettes (see HarfBuzz.ot_color_has_palettes()), then palette_index selects the palette to use. If the font only has one palette, this will be 0.

New in version 7.0.0.

HarfBuzz.font_set_face(font, face)
Parameters:

Sets face as the font-face value of font.

New in version 1.4.3.

HarfBuzz.font_set_funcs(font, klass, font_data, destroy)
Parameters:

Replaces the font-functions structure attached to a font, updating the font’s user-data with font-data and the destroy callback.

New in version 0.9.2.

HarfBuzz.font_set_funcs_data(font, font_data, destroy)
Parameters:

Replaces the user data attached to a font, updating the font’s destroy callback.

New in version 0.9.2.

HarfBuzz.font_set_parent(font, parent)
Parameters:

Sets the parent font of font.

New in version 1.0.5.

HarfBuzz.font_set_ppem(font, x_ppem, y_ppem)
Parameters:

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.

New in version 0.9.2.

HarfBuzz.font_set_ptem(font, ptem)
Parameters:

Sets the “point size” of a font. Set to zero to unset. Used in CoreText to implement optical sizing.

Note: There are 72 points in an inch.

New in version 1.6.0.

HarfBuzz.font_set_scale(font, x_scale, y_scale)
Parameters:

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 #hb_position_t values 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 HarfBuzz.font_set_ptem(), and the pixel size using HarfBuzz.font_set_ppem().

The choice of scale is yours but needs to be consistent between what you set here, and what you expect out of #hb_position_t as 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.

New in version 0.9.2.

HarfBuzz.font_set_synthetic_bold(font, x_embolden, y_embolden, in_place)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • x_embolden (float) – the amount to embolden horizontally

  • y_embolden (float) – the amount to embolden vertically

  • in_place (int) – whether to embolden glyphs in-place

Sets the “synthetic boldness” of a font.

Positive values for x_embolden / y_embolden make 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 HarfBuzz.font_draw_glyph().

If in_place is false, then glyph advance-widths are also adjusted, otherwise they are not. The in-place mode is useful for simulating font grading.

New in version 7.0.0.

HarfBuzz.font_set_synthetic_slant(font, slant)
Parameters:

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: The glyph shape fetched via the HarfBuzz.font_draw_glyph() function is slanted to reflect this value as well. Note: The slant value is a ratio. For example, a 20% slant would be represented as a 0.2 value.

New in version 3.3.0.

HarfBuzz.font_set_var_coords_design(font, coords)
Parameters:

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 in coords will be effectively set to their default values.

New in version 1.4.2.

HarfBuzz.font_set_var_coords_normalized(font, coords)
Parameters:

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 in coords will be effectively set to their default values.

Note: Coordinates should be normalized to 2.14.

New in version 1.4.2.

HarfBuzz.font_set_var_named_instance(font, instance_index)
Parameters:

Sets design coords of a font from a named-instance index.

New in version 2.6.0.

HarfBuzz.font_set_variation(font, tag, value)
Parameters:

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 HarfBuzz.font_set_variations() instead.

New in version 7.1.0.

HarfBuzz.font_set_variations(font, variations)
Parameters:

Applies a list of font-variation settings to a font.

Note that this overrides all existing variations set on font. Axes not included in variations will be effectively set to their default values.

New in version 1.4.2.

HarfBuzz.font_subtract_glyph_origin_for_direction(font, glyph, direction, x, y)
Parameters:
  • font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

  • glyph (int) – The glyph ID to query

  • direction (HarfBuzz.direction_t) – The direction of the text segment

  • x (int) – Input = The original X coordinate Output = The X coordinate minus the X-coordinate of the origin

  • y (int) – Input = The original Y coordinate Output = The Y coordinate minus the Y-coordinate of the origin

Returns:

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

Return type:

(x: int, y: 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.

New in version 0.9.2.

HarfBuzz.ft_face_create(ft_face, destroy)
Parameters:
Returns:

the new HarfBuzz.face_t face object

Return type:

HarfBuzz.face_t

Creates an HarfBuzz.face_t face object from the specified freetype2.Face.

Note that this is using the freetype2.Face object just to get at the underlying font data, and fonts created from the returned HarfBuzz.face_t will use the native HarfBuzz font implementation, unless you call HarfBuzz.ft_font_set_funcs() on them.

This variant of the function does not provide any life-cycle management.

Most client programs should use HarfBuzz.ft_face_create_referenced() (or, perhaps, HarfBuzz.ft_face_create_cached()) instead.

If you know you have valid reasons not to use HarfBuzz.ft_face_create_referenced(), then it is the client program’s responsibility to destroy ft_face after the HarfBuzz.face_t face object has been destroyed.

New in version 0.9.2.

HarfBuzz.ft_face_create_cached(ft_face)
Parameters:

ft_face (freetype2.Face) – freetype2.Face to work upon

Returns:

the new HarfBuzz.face_t face object

Return type:

HarfBuzz.face_t

Creates an HarfBuzz.face_t face object from the specified freetype2.Face.

Note that this is using the freetype2.Face object just to get at the underlying font data, and fonts created from the returned HarfBuzz.face_t will use the native HarfBuzz font implementation, unless you call HarfBuzz.ft_font_set_funcs() on them.

This variant of the function caches the newly created HarfBuzz.face_t face object, using the generic pointer of ft_face. Subsequent function calls that are passed the same ft_face parameter will have the same HarfBuzz.face_t returned to them, and that HarfBuzz.face_t will be correctly reference counted.

However, client programs are still responsible for destroying ft_face after the last HarfBuzz.face_t face object has been destroyed.

New in version 0.9.2.

HarfBuzz.ft_face_create_referenced(ft_face)
Parameters:

ft_face (freetype2.Face) – freetype2.Face to work upon

Returns:

the new HarfBuzz.face_t face object

Return type:

HarfBuzz.face_t

Creates an HarfBuzz.face_t face object from the specified freetype2.Face.

Note that this is using the freetype2.Face object just to get at the underlying font data, and fonts created from the returned HarfBuzz.face_t will use the native HarfBuzz font implementation, unless you call HarfBuzz.ft_font_set_funcs() on them.

This is the preferred variant of the HarfBuzz.ft_face_create function family, because it calls FT_Reference_Face() on ft_face, ensuring that ft_face remains alive as long as the resulting HarfBuzz.face_t face object remains alive. Also calls FT_Done_Face() when the HarfBuzz.face_t face object is destroyed.

Use this version unless you know you have good reasons not to.

New in version 0.9.38.

HarfBuzz.ft_font_changed(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Refreshes the state of font when the underlying freetype2.Face has changed. This function should be called after changing the size or variation-axis settings on the freetype2.Face.

New in version 1.0.5.

HarfBuzz.ft_font_create(ft_face, destroy)
Parameters:
Returns:

the new HarfBuzz.font_t font object

Return type:

HarfBuzz.font_t

Creates an HarfBuzz.font_t font object from the specified freetype2.Face.

Note: You must set the face size on ft_face before calling HarfBuzz.ft_font_create() on it. HarfBuzz assumes size is always set and will access `size` member of freetype2.Face unconditionally. This variant of the function does not provide any life-cycle management.

Most client programs should use HarfBuzz.ft_font_create_referenced() instead.

If you know you have valid reasons not to use HarfBuzz.ft_font_create_referenced(), then it is the client program’s responsibility to destroy ft_face after the HarfBuzz.font_t font object has been destroyed.

HarfBuzz will use the destroy callback on the HarfBuzz.font_t font object if it is supplied when you use this function. However, even if destroy is provided, it is the client program’s responsibility to destroy ft_face, and it is the client program’s responsibility to ensure that ft_face is destroyed only after the HarfBuzz.font_t font object has been destroyed.

New in version 0.9.2.

HarfBuzz.ft_font_create_referenced(ft_face)
Parameters:

ft_face (freetype2.Face) – freetype2.Face to work upon

Returns:

the new HarfBuzz.font_t font object

Return type:

HarfBuzz.font_t

Creates an HarfBuzz.font_t font object from the specified freetype2.Face.

Note: You must set the face size on ft_face before calling HarfBuzz.ft_font_create_referenced() on it. HarfBuzz assumes size is always set and will access `size` member of freetype2.Face unconditionally. This is the preferred variant of the HarfBuzz.ft_font_create function family, because it calls FT_Reference_Face() on ft_face, ensuring that ft_face remains alive as long as the resulting HarfBuzz.font_t font object remains alive.

Use this version unless you know you have good reasons not to.

New in version 0.9.38.

HarfBuzz.ft_font_get_load_flags(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

FT_Load_Glyph flags found, or 0

Return type:

int

Fetches the FT_Load_Glyph load flags of the specified HarfBuzz.font_t.

For more information, see <https://freetype.org/freetype2/docs/reference/ft2-glyph_retrieval.html#ft_load_xxx>

This function works with HarfBuzz.font_t objects created by HarfBuzz.ft_font_create() or HarfBuzz.ft_font_create_referenced().

New in version 1.0.5.

HarfBuzz.ft_font_set_funcs(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Configures the font-functions structure of the specified HarfBuzz.font_t font object to use FreeType font functions.

In particular, you can use this function to configure an existing HarfBuzz.face_t face object for use with FreeType font functions even if that HarfBuzz.face_t face object was initially created with HarfBuzz.face_create(), and therefore was not initially configured to use FreeType font functions.

An HarfBuzz.font_t object created with HarfBuzz.ft_font_create() is preconfigured for FreeType font functions and does not require this function to be used.

Note that if you modify the underlying HarfBuzz.font_t after calling this function, you need to call HarfBuzz.ft_hb_font_changed() to update the underlying freetype2.Face.

Note: Internally, this function creates an freetype2.Face.

New in version 1.0.5.

HarfBuzz.ft_font_set_load_flags(font, load_flags)
Parameters:

Sets the FT_Load_Glyph load flags for the specified HarfBuzz.font_t.

For more information, see <https://freetype.org/freetype2/docs/reference/ft2-glyph_retrieval.html#ft_load_xxx>

This function works with HarfBuzz.font_t objects created by HarfBuzz.ft_font_create() or HarfBuzz.ft_font_create_referenced().

New in version 1.0.5.

HarfBuzz.ft_hb_font_changed(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Returns:

true if changed, false otherwise

Return type:

int

Refreshes the state of the underlying freetype2.Face of font when the HarfBuzz.font_t font has changed. This function should be called after changing the size or variation-axis settings on the font. This call is fast if nothing has changed on font.

New in version 4.4.0.

HarfBuzz.glib_blob_create(gbytes)
Parameters:

gbytes (GLib.Bytes) – the GLib.Bytes structure to work upon

Returns:

the new HarfBuzz.blob_t blob object

Return type:

HarfBuzz.blob_t

Creates an HarfBuzz.blob_t blob from the specified GLib.Bytes data structure.

New in version 0.9.38.

HarfBuzz.glib_get_unicode_funcs()
Returns:

a pointer to the HarfBuzz.unicode_funcs_t Unicode-functions structure

Return type:

HarfBuzz.unicode_funcs_t

Fetches a Unicode-functions structure that is populated with the appropriate GLib function for each method.

New in version 0.9.38.

HarfBuzz.glib_script_from_script(script)
Parameters:

script (HarfBuzz.script_t) – The HarfBuzz.script_t to query

Returns:

the GLib.UnicodeScript identifier found

Return type:

GLib.UnicodeScript

Fetches the GLib.UnicodeScript identifier that corresponds to the specified HarfBuzz.script_t script.

New in version 0.9.38.

HarfBuzz.glib_script_to_script(script)
Parameters:

script (GLib.UnicodeScript) – The GLib.UnicodeScript identifier to query

Returns:

the HarfBuzz.script_t script found

Return type:

HarfBuzz.script_t

Fetches the HarfBuzz.script_t script that corresponds to the specified GLib.UnicodeScript identifier.

New in version 0.9.38.

HarfBuzz.glyph_info_get_glyph_flags(info)
Parameters:

info (HarfBuzz.glyph_info_t) – a HarfBuzz.glyph_info_t

Returns:

The HarfBuzz.glyph_flags_t encoded within info

Return type:

HarfBuzz.glyph_flags_t

Returns glyph flags encoded within a HarfBuzz.glyph_info_t.

New in version 1.5.0.

HarfBuzz.language_from_string(str)
Parameters:

str (bytes) – a string representing a BCP 47 language tag

Returns:

The HarfBuzz.language_t corresponding to the BCP 47 language tag.

Return type:

HarfBuzz.language_t

Converts str representing a BCP 47 language tag to the corresponding HarfBuzz.language_t.

New in version 0.9.2.

HarfBuzz.language_get_default()
Returns:

The default language of the locale as an HarfBuzz.language_t

Return type:

HarfBuzz.language_t

Fetch the default language from current locale.

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 HarfBuzz.buffer_guess_segment_properties() by HarfBuzz itself.

New in version 0.9.2.

HarfBuzz.language_matches(language, specific)
Parameters:
Returns:

true if languages match, false otherwise.

Return type:

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”.

New in version 5.0.0.

HarfBuzz.language_to_string(language)
Parameters:

language (HarfBuzz.language_t) – The HarfBuzz.language_t to convert

Returns:

A NULL-terminated string representing the language. Must not be freed by the caller.

Return type:

str

Converts an HarfBuzz.language_t to a string.

New in version 0.9.2.

HarfBuzz.map_allocation_successful(map)
Parameters:

map (HarfBuzz.map_t) – A map

Returns:

true if allocation succeeded, false otherwise

Return type:

int

Tests whether memory allocation for a set was successful.

New in version 1.7.7.

HarfBuzz.map_clear(map)
Parameters:

map (HarfBuzz.map_t) – A map

Clears out the contents of map.

New in version 1.7.7.

HarfBuzz.map_copy(map)
Parameters:

map (HarfBuzz.map_t) – A map

Returns:

Newly-allocated map.

Return type:

HarfBuzz.map_t

Allocate a copy of map.

New in version 4.4.0.

HarfBuzz.map_create()
Returns:

The new HarfBuzz.map_t

Return type:

HarfBuzz.map_t

Creates a new, initially empty map.

New in version 1.7.7.

HarfBuzz.map_del(map, key)
Parameters:

Removes key and its stored value from map.

New in version 1.7.7.

HarfBuzz.map_get(map, key)
Parameters:
Return type:

int

Fetches the value stored for key in map.

New in version 1.7.7.

HarfBuzz.map_get_empty()
Returns:

The empty HarfBuzz.map_t

Return type:

HarfBuzz.map_t

Fetches the singleton empty HarfBuzz.map_t.

New in version 1.7.7.

HarfBuzz.map_get_population(map)
Parameters:

map (HarfBuzz.map_t) – A map

Returns:

The population of map

Return type:

int

Returns the number of key-value pairs in the map.

New in version 1.7.7.

HarfBuzz.map_has(map, key)
Parameters:
Returns:

true if key is found in map, false otherwise

Return type:

int

Tests whether key is an element of map.

New in version 1.7.7.

HarfBuzz.map_hash(map)
Parameters:

map (HarfBuzz.map_t) – A map

Returns:

A hash of map.

Return type:

int

Creates a hash representing map.

New in version 4.4.0.

HarfBuzz.map_is_empty(map)
Parameters:

map (HarfBuzz.map_t) – A map

Returns:

true if map is empty

Return type:

int

Tests whether map is empty (contains no elements).

New in version 1.7.7.

HarfBuzz.map_is_equal(map, other)
Parameters:
Returns:

true if the two maps are equal, false otherwise.

Return type:

int

Tests whether map and other are equal (contain the same elements).

New in version 4.3.0.

HarfBuzz.map_keys(map, keys)
Parameters:

Add the keys of map to keys.

New in version 7.0.0.

HarfBuzz.map_next(map, idx)
Parameters:
Returns:

true if there was a next value, false otherwise

idx:

Iterator internal state

key:

Key retrieved

value:

Value retrieved

Return type:

(int, idx: int, key: int, value: int)

Fetches the next key/value pair in map.

Set idx to -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.

New in version 7.0.0.

HarfBuzz.map_set(map, key, value)
Parameters:
  • map (HarfBuzz.map_t) – A map

  • key (int) – The key to store in the map

  • value (int) – The value to store for key

Stores key:value in the map.

New in version 1.7.7.

HarfBuzz.map_update(map, other)
Parameters:

Add the contents of other to map.

New in version 7.0.0.

HarfBuzz.map_values(map, values)
Parameters:

Add the values of map to values.

New in version 7.0.0.

HarfBuzz.ot_color_glyph_get_layers(face, glyph, start_offset)
Parameters:
Returns:

Total number of layers available for the glyph index queried

layers:

The array of layers found

Return type:

(int, layers: [HarfBuzz.ot_color_layer_t])

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.

New in version 2.1.0.

HarfBuzz.ot_color_glyph_has_paint(face, glyph)
Parameters:
Returns:

true if data found, false otherwise

Return type:

int

Tests where a face includes COLRv1 paint data for glyph.

New in version 7.0.0.

HarfBuzz.ot_color_glyph_reference_png(font, glyph)
Parameters:
Returns:

An HarfBuzz.blob_t containing the PNG image for the glyph, if available

Return type:

HarfBuzz.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 font object. 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.

New in version 2.1.0.

HarfBuzz.ot_color_glyph_reference_svg(face, glyph)
Parameters:
Returns:

An HarfBuzz.blob_t containing the SVG document of the glyph, if available

Return type:

HarfBuzz.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.

New in version 2.1.0.

HarfBuzz.ot_color_has_layers(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests whether a face includes a COLR table with data according to COLRv0.

New in version 2.1.0.

HarfBuzz.ot_color_has_paint(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests where a face includes a COLR table with data according to COLRv1.

New in version 7.0.0.

HarfBuzz.ot_color_has_palettes(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests whether a face includes a CPAL color-palette table.

New in version 2.1.0.

HarfBuzz.ot_color_has_png(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests whether a face has PNG glyph images (either in CBDT or sbix tables).

New in version 2.1.0.

HarfBuzz.ot_color_has_svg(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon.

Returns:

true if data found, false otherwise.

Return type:

int

Tests whether a face includes any SVG glyph images.

New in version 2.1.0.

HarfBuzz.ot_color_palette_color_get_name_id(face, color_index)
Parameters:
Returns:

the Name ID found for the color.

Return type:

int

Fetches the name table Name ID that provides display names for the specified color in a face’s CPAL color palette.

Display names can be generic (e.g., “Background”) or specific (e.g., “Eye color”).

New in version 2.1.0.

HarfBuzz.ot_color_palette_get_colors(face, palette_index, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • palette_index (int) – the index of the color palette to query

  • start_offset (int) – offset of the first color to retrieve

Returns:

the total number of colors in the palette

colors:

The array of #hb_color_t records found

Return type:

(int, colors: [int])

Fetches a list of the colors in a color palette.

After calling this function, colors will be filled with the palette colors. If colors is None, 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 calling HarfBuzz.ot_color_palette_get_colors() a second time.

The RGBA values in the palette are unpremultiplied. See the OpenType spec CPAL section for details.

New in version 2.1.0.

HarfBuzz.ot_color_palette_get_count(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

the number of palettes found

Return type:

int

Fetches the number of color palettes in a face.

New in version 2.1.0.

HarfBuzz.ot_color_palette_get_flags(face, palette_index)
Parameters:
Returns:

the HarfBuzz.ot_color_palette_flags_t of the requested color palette

Return type:

HarfBuzz.ot_color_palette_flags_t

Fetches the flags defined for a color palette.

New in version 2.1.0.

HarfBuzz.ot_color_palette_get_name_id(face, palette_index)
Parameters:
Returns:

the Named ID found for the palette. If the requested palette has no name the result is HarfBuzz.ot_name_id_predefined_t.INVALID.

Return type:

int

Fetches the name table Name ID that provides display names for a CPAL color palette.

Palette display names can be generic (e.g., “Default”) or provide specific, themed names (e.g., “Spring”, “Summer”, “Fall”, and “Winter”).

New in version 2.1.0.

HarfBuzz.ot_font_set_funcs(font)
Parameters:

font (HarfBuzz.font_t) – HarfBuzz.font_t to work upon

Sets the font functions to use when working with font.

New in version 0.9.28.

HarfBuzz.ot_layout_collect_features(face, table_tag, scripts, languages, features)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • scripts ([int] or None) – The array of scripts to collect features for, terminated by %HB_TAG_NONE

  • languages ([int] or None) – The array of languages to collect features for, terminated by %HB_TAG_NONE

  • features ([int] or None) – The array of features to collect, terminated by %HB_TAG_NONE

Returns:

The set of feature indexes found for the query

Return type:

feature_indexes: HarfBuzz.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.

New in version 1.8.5.

HarfBuzz.ot_layout_collect_features_map(face, table_tag, script_index, language_index)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_index (int) – The index of the requested language tag

Returns:

The map of feature tag to feature index.

Return type:

feature_map: HarfBuzz.map_t

Fetches the mapping from feature tags to feature indexes for the specified script and language.

New in version 8.1.0.

HarfBuzz.ot_layout_collect_lookups(face, table_tag, scripts, languages, features)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • scripts ([int] or None) – The array of scripts to collect lookups for, terminated by %HB_TAG_NONE

  • languages ([int] or None) – The array of languages to collect lookups for, terminated by %HB_TAG_NONE

  • features ([int] or None) – The array of features to collect lookups for, terminated by %HB_TAG_NONE

Returns:

The array of lookup indexes found for the query

Return type:

lookup_indexes: HarfBuzz.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.

New in version 0.9.8.

HarfBuzz.ot_layout_feature_get_characters(face, table_tag, feature_index, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – table tag to query, “GSUB” or “GPOS”.

  • feature_index (int) – index of feature to query.

  • start_offset (int) – offset of the first character to retrieve

Returns:

Number of total sample characters in the cvXX feature.

characters:

A buffer pointer. The Unicode codepoints of the characters for which this feature provides glyph variants.

Return type:

(int, characters: [int])

Fetches a list of the characters defined as having a variant under the specified “Character Variant” (“cvXX”) feature tag.

New in version 2.0.0.

HarfBuzz.ot_layout_feature_get_lookups(face, table_tag, feature_index, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • feature_index (int) – The index of the requested feature

  • start_offset (int) – offset of the first lookup to retrieve

Returns:

Total number of lookups.

lookup_indexes:

The array of lookup indexes found for the query

Return type:

(int, lookup_indexes: [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.

New in version 0.9.7.

HarfBuzz.ot_layout_feature_get_name_ids(face, table_tag, feature_index)
Parameters:
Returns:

true if data found, false otherwise

label_id:

The ‘name’ table name ID that specifies a string for a user-interface label for this feature. (May be None.)

tooltip_id:

The ‘name’ table name ID that specifies a string that an application can use for tooltip text for this feature. (May be None.)

sample_id:

The ‘name’ table name ID that specifies sample text that illustrates the effect of this feature. (May be None.)

num_named_parameters:

Number of named parameters. (May be zero.)

first_param_id:

The first ‘name’ table name ID used to specify strings for user-interface labels for the feature parameters. (Must be zero if numParameters is zero.)

Return type:

(int, label_id: int, tooltip_id: int, sample_id: int, num_named_parameters: int, first_param_id: int)

Fetches name indices from feature parameters for “Stylistic Set” (‘ssXX’) or “Character Variant” (‘cvXX’) features.

New in version 2.0.0.

HarfBuzz.ot_layout_feature_with_variations_get_lookups(face, table_tag, feature_index, variations_index, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • feature_index (int) – The index of the feature to query

  • variations_index (int) – The index of the feature variation to query

  • start_offset (int) – offset of the first lookup to retrieve

Returns:

Total number of lookups.

lookup_indexes:

The array of lookups found for the query

Return type:

(int, lookup_indexes: [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.

New in version 1.4.0.

HarfBuzz.ot_layout_get_attach_points(face, glyph, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – The HarfBuzz.face_t to work on

  • glyph (int) – The #hb_codepoint_t code point to query

  • start_offset (int) – offset of the first attachment point to retrieve

Returns:

Total number of attachment points for glyph.

point_array:

The array of attachment points found for the query

Return type:

(int, point_array: [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.

HarfBuzz.ot_layout_get_baseline(font, baseline_tag, direction, script_tag, language_tag)
Parameters:
Returns:

true if found baseline value in the font.

coord:

baseline value if found.

Return type:

(int, coord: int)

Fetches a baseline value from the face.

New in version 2.6.0.

HarfBuzz.ot_layout_get_baseline2(font, baseline_tag, direction, script, language)
Parameters:
Returns:

true if found baseline value in the font.

coord:

baseline value if found.

Return type:

(int, coord: int)

Fetches a baseline value from the face.

This function is like HarfBuzz.ot_layout_get_baseline() but takes HarfBuzz.script_t and HarfBuzz.language_t instead of OpenType #hb_tag_t.

New in version 8.0.0.

HarfBuzz.ot_layout_get_baseline_with_fallback(font, baseline_tag, direction, script_tag, language_tag)
Parameters:
Returns:

baseline value if found.

Return type:

coord: int

Fetches a baseline value from the face, and synthesizes it if the font does not have it.

New in version 4.0.0.

HarfBuzz.ot_layout_get_baseline_with_fallback2(font, baseline_tag, direction, script, language)
Parameters:
Returns:

baseline value if found.

Return type:

coord: int

Fetches a baseline value from the face, and synthesizes it if the font does not have it.

This function is like HarfBuzz.ot_layout_get_baseline_with_fallback() but takes HarfBuzz.script_t and HarfBuzz.language_t instead of OpenType #hb_tag_t.

New in version 8.0.0.

HarfBuzz.ot_layout_get_font_extents(font, direction, script_tag, language_tag)
Parameters:
Returns:

true if found script/language-specific font extents.

extents:

font extents if found.

Return type:

(int, extents: HarfBuzz.font_extents_t or None)

Fetches script/language-specific font extents. These values are looked up in the BASE table’s MinMax records.

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.

New in version 8.0.0.

HarfBuzz.ot_layout_get_font_extents2(font, direction, script, language)
Parameters:
Returns:

true if found script/language-specific font extents.

extents:

font extents if found.

Return type:

(int, extents: HarfBuzz.font_extents_t or None)

Fetches script/language-specific font extents. These values are looked up in the BASE table’s MinMax records.

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 HarfBuzz.ot_layout_get_font_extents() but takes HarfBuzz.script_t and HarfBuzz.language_t instead of OpenType #hb_tag_t.

New in version 8.0.0.

HarfBuzz.ot_layout_get_glyph_class(face, glyph)
Parameters:
Returns:

The HarfBuzz.ot_layout_glyph_class_t glyph class of the given code point in the GDEF table of the face.

Return type:

HarfBuzz.ot_layout_glyph_class_t

Fetches the GDEF class of the requested glyph in the specified face.

New in version 0.9.7.

HarfBuzz.ot_layout_get_glyphs_in_class(face, klass)
Parameters:
Returns:

The HarfBuzz.set_t set of all glyphs belonging to the requested class.

Return type:

glyphs: HarfBuzz.set_t

Retrieves the set of all glyphs from the face that belong to the requested glyph class in the face’s GDEF table.

New in version 0.9.7.

HarfBuzz.ot_layout_get_horizontal_baseline_tag_for_script(script)
Parameters:

script (HarfBuzz.script_t) – a script tag.

Returns:

dominant baseline tag for the script.

Return type:

HarfBuzz.ot_layout_baseline_tag_t

Fetches the dominant horizontal baseline tag used by script.

New in version 4.0.0.

HarfBuzz.ot_layout_get_ligature_carets(font, direction, glyph, start_offset)
Parameters:
Returns:

Total number of ligature caret positions for glyph.

caret_array:

The array of caret positions found for the query

Return type:

(int, caret_array: [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.

HarfBuzz.ot_layout_get_size_params(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

design_size:

The design size of the face

subfamily_id:

The identifier of the face within the font subfamily

subfamily_name_id:

The ‘name’ table name ID of the face within the font subfamily

range_start:

The minimum size of the recommended size range for the face

range_end:

The maximum size of the recommended size range for the face

Return type:

(int, design_size: int, subfamily_id: int, subfamily_name_id: int, range_start: int, range_end: int)

Fetches optical-size feature data (i.e., the size feature 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 the size feature.

For more information on this distinction, see the `size feature documentation < https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#tag-size>`__.

New in version 0.9.10.

HarfBuzz.ot_layout_has_glyph_classes(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests whether a face has any glyph classes defined in its GDEF table.

HarfBuzz.ot_layout_has_positioning(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if the face has GPOS data, false otherwise

Return type:

int

Tests whether the specified face includes any GPOS positioning.

HarfBuzz.ot_layout_has_substitution(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

Returns:

true if data found, false otherwise

Return type:

int

Tests whether the specified face includes any GSUB substitutions.

New in version 0.6.0.

HarfBuzz.ot_layout_language_find_feature(face, table_tag, script_index, language_index, feature_tag)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_index (int) – The index of the requested language tag

  • feature_tag (int) – #hb_tag_t of the feature tag requested

Returns:

true if the feature is found, false otherwise

feature_index:

The index of the requested feature

Return type:

(int, feature_index: 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.

New in version 0.6.0.

HarfBuzz.ot_layout_language_get_feature_indexes(face, table_tag, script_index, language_index, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_index (int) – The index of the requested language tag

  • start_offset (int) – offset of the first feature tag to retrieve

Returns:

Total number of features.

feature_indexes:

The array of feature indexes found for the query

Return type:

(int, feature_indexes: [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.

New in version 0.6.0.

HarfBuzz.ot_layout_language_get_feature_tags(face, table_tag, script_index, language_index, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_index (int) – The index of the requested language tag

  • start_offset (int) – offset of the first feature tag to retrieve

Returns:

Total number of feature tags.

feature_tags:

The array of #hb_tag_t feature tags found for the query

Return type:

(int, feature_tags: [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.

New in version 0.6.0.

HarfBuzz.ot_layout_language_get_required_feature(face, table_tag, script_index, language_index)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_index (int) – The index of the requested language tag

Returns:

true if the feature is found, false otherwise

feature_index:

The index of the requested feature

feature_tag:

The #hb_tag_t of the requested feature

Return type:

(int, feature_index: int, feature_tag: int)

Fetches the tag of a requested feature index in the given face’s GSUB or GPOS table, underneath the specified script and language.

New in version 0.9.30.

HarfBuzz.ot_layout_language_get_required_feature_index(face, table_tag, script_index, language_index)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_index (int) – The index of the requested language tag

Returns:

true if the feature is found, false otherwise

feature_index:

The index of the requested feature

Return type:

(int, feature_index: int)

Fetches the index of a requested feature in the given face’s GSUB or GPOS table, underneath the specified script and language.

New in version 0.6.0.

HarfBuzz.ot_layout_lookup_collect_glyphs(face, table_tag, lookup_index)
Parameters:
Returns:

glyphs_before:

Array of glyphs preceding the substitution range

glyphs_input:

Array of input glyphs that would be substituted by the lookup

glyphs_after:

Array of glyphs following the substitution range

glyphs_output:

Array of glyphs that would be the substituted output of the lookup

Return type:

(glyphs_before: HarfBuzz.set_t, glyphs_input: HarfBuzz.set_t, glyphs_after: HarfBuzz.set_t, glyphs_output: HarfBuzz.set_t)

Fetches a list of all glyphs affected by the specified lookup in the specified face’s GSUB table or GPOS table.

New in version 0.9.7.

HarfBuzz.ot_layout_lookup_get_glyph_alternates(face, lookup_index, glyph, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – a face.

  • lookup_index (int) – index of the feature lookup to query.

  • glyph (int) – a glyph id.

  • start_offset (int) – starting offset.

Returns:

Total number of alternates found in the specific lookup index for the given glyph id.

alternate_glyphs:

A glyphs buffer. Alternate glyphs associated with the glyph id.

Return type:

(int, alternate_glyphs: [int])

Fetches alternates of a glyph from a given GSUB lookup index.

New in version 2.6.8.

HarfBuzz.ot_layout_lookup_get_optical_bound(font, lookup_index, direction, glyph)
Parameters:
Returns:

Adjustment value. Negative values mean the glyph will stick out of the margin.

Return type:

int

Fetches the optical bound of a glyph positioned at the margin of text. The direction identifies which edge of the glyph to query.

New in version 5.3.0.

HarfBuzz.ot_layout_lookup_substitute_closure(face, lookup_index)
Parameters:
Returns:

Array of glyphs comprising the transitive closure of the lookup

Return type:

glyphs: HarfBuzz.set_t

Compute the transitive closure of glyphs needed for a specified lookup.

New in version 0.9.7.

HarfBuzz.ot_layout_lookup_would_substitute(face, lookup_index, glyphs, glyphs_length, zero_context)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • lookup_index (int) – The index of the lookup to query

  • glyphs (int) – The sequence of glyphs to query for substitution

  • glyphs_length (int) – The length of the glyph sequence

  • zero_context (int) – #hb_bool_t indicating whether pre-/post-context are disallowed in substitutions

Returns:

true if a substitution would be triggered, false otherwise

Return type:

int

Tests whether a specified lookup in the specified face would trigger a substitution on the given glyph sequence.

New in version 0.9.7.

HarfBuzz.ot_layout_lookups_substitute_closure(face, lookups)
Parameters:
Returns:

Array of glyphs comprising the transitive closure of the lookups

Return type:

glyphs: HarfBuzz.set_t

Compute the transitive closure of glyphs needed for all of the provided lookups.

New in version 1.8.1.

HarfBuzz.ot_layout_script_find_language(face, table_tag, script_index, language_tag, language_index)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_tag (int) – The #hb_tag_t of the requested language

  • language_index (int) – The index of the requested language

Returns:

true if the language tag is found, false otherwise

Return type:

int

Fetches the index of a given language tag in the specified face’s GSUB table or GPOS table, underneath the specified script tag.

New in version 0.6.0.

Deprecated since version 2.0.0.

HarfBuzz.ot_layout_script_get_language_tags(face, table_tag, script_index, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • start_offset (int) – offset of the first language tag to retrieve

Returns:

Total number of language tags.

language_tags:

Array of language tags found in the table

Return type:

(int, language_tags: [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.

New in version 0.6.0.

HarfBuzz.ot_layout_script_select_language(face, table_tag, script_index, language_count, language_tags)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_count (int) – The number of languages in the specified script

  • language_tags (int) – The array of language tags

Returns:

true if one of the given language tags is found, false otherwise

language_index:

The index of the requested language

Return type:

(int, language_index: int)

Fetches the index of the first language tag fom language_tags that 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, false is returned and language_index is set to the default language index.

New in version 2.0.0.

HarfBuzz.ot_layout_script_select_language2(face, table_tag, script_index, language_count, language_tags)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_index (int) – The index of the requested script tag

  • language_count (int) – The number of languages in the specified script

  • language_tags (int) – The array of language tags

Returns:

true if one of the given language tags is found, false otherwise

language_index:

The index of the chosen language

chosen_language:

#hb_tag_t of the chosen language

Return type:

(int, language_index: int, chosen_language: int)

Fetches the index of the first language tag fom language_tags that 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, false is returned and language_index is set to HarfBuzz.OT_LAYOUT_DEFAULT_LANGUAGE_INDEX and chosen_language is set to #HB_TAG_NONE.

New in version 7.0.0.

HarfBuzz.ot_layout_table_choose_script(face, table_tag, script_tags)
Parameters:
Returns:

script_index:

The index of the chosen script

chosen_script:

#hb_tag_t of the chosen script

Return type:

(int, script_index: int, chosen_script: int)

Deprecated since 2.0.0

HarfBuzz.ot_layout_table_find_feature_variations(face, table_tag, coords, num_coords)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • coords (int) – The variation coordinates to query

  • num_coords (int) – The number of variation coordinates

Returns:

true if feature variations were found, false otherwise.

variations_index:

The array of feature variations found for the query

Return type:

(int, variations_index: int)

Fetches a list of feature variations in the specified face’s GSUB table or GPOS table, at the specified variation coordinates.

New in version 1.4.0.

HarfBuzz.ot_layout_table_find_script(face, table_tag, script_tag)
Parameters:
Returns:

true if the script is found, false otherwise

script_index:

The index of the requested script tag

Return type:

(int, script_index: int)

Fetches the index if a given script tag in the specified face’s GSUB table or GPOS table.

HarfBuzz.ot_layout_table_get_feature_tags(face, table_tag, start_offset)
Parameters:
Returns:

Total number of feature tags.

feature_tags:

Array of feature tags found in the table

Return type:

(int, feature_tags: [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.

New in version 0.6.0.

HarfBuzz.ot_layout_table_get_lookup_count(face, table_tag)
Parameters:
Returns:

Total number of lookups.

Return type:

int

Fetches the total number of lookups enumerated in the specified face’s GSUB table or GPOS table.

New in version 0.9.22.

HarfBuzz.ot_layout_table_get_script_tags(face, table_tag, start_offset)
Parameters:
Returns:

Total number of script tags.

script_tags:

The array of #hb_tag_t script tags found for the query

Return type:

(int, script_tags: [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.

HarfBuzz.ot_layout_table_select_script(face, table_tag, script_count, script_tags)
Parameters:
  • face (HarfBuzz.face_t) – HarfBuzz.face_t to work upon

  • table_tag (int) – #HB_OT_TAG_GSUB or #HB_OT_TAG_GPOS

  • script_count (int) – Number of script tags in the array

  • script_tags (int) – Array of #hb_tag_t script tags

Returns:

true if one of the requested scripts is selected, false if a fallback script is selected or if no scripts are selected.

script_index:

The index of the requested script

chosen_script:

#hb_tag_t of the requested script

Return type:

(int, script_index: int, chosen_script: int)

Selects an OpenType script for table_tag from the script_tags array.

If the table does not have any of the requested scripts, then DFLT, dflt, and latn tags are tried in that order. If the table still does not have any of these scripts, script_index is set to HarfBuzz.OT_LAYOUT_NO_SCRIPT_INDEX and chosen_script is set to #HB_TAG_NONE.

New in version 2.0.0.

HarfBuzz.ot_math_get_constant(font, constant)
Parameters:
Returns:

the requested constant or zero

Return type:

int

Fetches the specified math constant. For most constants, the value returned is an #hb_position_t.

However, if the requested constant is HarfBuzz.ot_math_constant_t.SCRIPT_PERCENT_SCALE_DOWN, HarfBuzz.ot_math_constant_t.SCRIPT_SCRIPT_PERCENT_SCALE_DOWN or HarfBuzz.ot_math_constant_t.RADICAL_DEGREE_BOTTOM_RAISE_PERCENT, then the return value is an integer between 0 and 100 representing that percentage.

New in version 1.3.3.

HarfBuzz.ot_math_get_glyph_assembly(font, glyph, direction, start_offset)
Parameters:
Returns:

the total number of parts in the glyph assembly

parts:

the glyph parts returned

italics_correction:

italics correction of the glyph assembly

Return type:

(int, parts: [HarfBuzz.ot_math_glyph_part_t], italics_correction: int)

Fetches the GlyphAssembly for the specified font, glyph index, and direction. Returned are a list of HarfBuzz.ot_math_glyph_part_t glyph parts that can be used to draw the glyph and an italics-correction value (if one is defined in the font).

The direction parameter is only used to select between horizontal or vertical directions for the construction. Even though all HarfBuzz.direction_t values are accepted, only the result of #HB_DIRECTION_IS_HORIZONTAL is considered.

New in version 1.3.3.

HarfBuzz.ot_math_get_glyph_italics_correction(font, glyph)
Parameters:
Returns:

the italics correction of the glyph or zero

Return type:

int

Fetches an italics-correction value (if one exists) for the specified glyph index.

New in version 1.3.3.

HarfBuzz.ot_math_get_glyph_kerning(font, glyph, kern, correction_height)
Parameters:
Returns:

requested kerning value or zero

Return type:

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.

New in version 1.3.3.

HarfBuzz.ot_math_get_glyph_kernings(font, glyph, kern, start_offset)
Parameters:
Returns:

the total number of kern values available or zero

kern_entries:

array of kern entries returned

Return type:

(int, kern_entries: [HarfBuzz.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 of HarfBuzz.ot_math_kern_entry_t structs.

See also HarfBuzz.ot_math_get_glyph_kerning, which handles selecting the appropriate kern value for a given correction height.

For a glyph with n defined kern values (where n > 0), there are only n−1 defined correction heights, as each correction height defines a boundary past which the next kern value should be selected. Therefore, only the HarfBuzz.ot_math_kern_entry_t.kern_value of the uppermost HarfBuzz.ot_math_kern_entry_t actually comes from the font; its corresponding HarfBuzz.ot_math_kern_entry_t.max_correction_height is always set to INT32_MAX.

New in version 3.4.0.

HarfBuzz.ot_math_get_glyph_top_accent_attachment(font, glyph)
Parameters:
Returns:

the top accent attachment of the glyph or 0.5 * the advance width of glyph

Return type:

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 MathTopAccentAttachment table (or, when font has no MathTopAccentAttachment table or no MATH table, any glyph) - the function synthesizes a value, returning the position at one-half the glyph’s advance width.

New in version 1.3.3.

HarfBuzz.ot_math_get_glyph_variants(font, glyph, direction, start_offset)
Parameters:
Returns:

the total number of size variants available or zero

variants:

array of variants returned

Return type:

(int, variants: [HarfBuzz.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 HarfBuzz.ot_math_glyph_variant_t structs.

The direction parameter is only used to select between horizontal or vertical directions for the construction. Even though all HarfBuzz.direction_t values are accepted, only the result of #HB_DIRECTION_IS_HORIZONTAL is considered.

New in version 1.3.3.

HarfBuzz.ot_math_get_min_connector_overlap(font, direction)
Parameters:
Returns:

requested minimum connector overlap or zero

Return type:

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.

The direction parameter is only used to select between horizontal or vertical directions for the construction. Even though all HarfBuzz.direction_t values are accepted, only the result of #HB_DIRECTION_IS_HORIZONTAL is considered.

New in version 1.3.3.

HarfBuzz.ot_math_has_data(face)
Parameters:

face (HarfBuzz.face_t) – HarfBuzz.face_t to test

Returns:

true if the table is found, false otherwise

Return type:

int

Tests whether a face has a MATH table.

New in version 1.3.3.

HarfBuzz.ot_math_is_glyph_extended_shape(face, glyph)
Parameters:
Returns:

true if the glyph is an extended shape, false otherwise

Return type:

int

Tests whether the given glyph index is an extended shape in the face.

New in version 1.3.3.

HarfBuzz.ot_meta_get_entry_tags(face, start_offset)
Parameters:
  • face (HarfBuzz.face_t) – a face object

  • start_offset (int) – iteration’s start offset

Returns:

Number of all available feature types.

entries:

entries tags buffer

Return type:

(int, entries: [HarfBuzz.ot_meta_tag_t])

Fetches all available feature types.

New in version 2.6.0.

HarfBuzz.ot_meta_reference_entry(face, meta_tag)
Parameters:
Returns:

A blob containing the blob.

Return type:

HarfBuzz.blob_t

It fetches metadata entry of a given tag from a font.

New in version 2.6.0.

HarfBuzz.ot_metrics_get_position(font, metrics_tag)
Parameters:
Returns:

Whether found the requested metrics in the font.

position:

result of metrics value from the font.

Return type:

(int, position: int)

Fetches metrics value corresponding to metrics_tag from font.

New in version 2.6.0.

HarfBuzz.ot_metrics_get_position_with_fallback(font, metrics_tag)
Parameters:
Returns:

result of metrics value from the font.

Return type:

position: int

Fetches metrics value corresponding to metrics_tag from font, and synthesizes a value if it the value is missing in the font.

New in version 4.0.0.

HarfBuzz.ot_metrics_get_variation(font, metrics_tag)
Parameters:
Returns:

The requested metric value.

Return type:

float

Fetches metrics value corresponding to metrics_tag from font with the current font variation settings applied.

New in version 2.6.0.

HarfBuzz.ot_metrics_get_x_variation(font, metrics_tag)
Parameters:
Returns:

The requested metric value.

Return type:

int

Fetches horizontal metrics value corresponding to metrics_tag from font with the current font variation settings applied.

New in version 2.6.0.

HarfBuzz.ot_metrics_get_y_variation(font, metrics_tag)
Parameters:
Returns:

The requested metric value.

Return type:

int

Fetches vertical metrics value corresponding to metrics_tag from font with the current font variation settings applied.

New in version 2.6.0.

HarfBuzz.ot_name_get_utf16(face, name_id, language)
Parameters:
Returns:

full length of the requested string, or 0 if not found.

text:

buffer to write fetched name into.

Return type:

(int, text: [int])

Fetches a font name from the OpenType ‘name’ table. If language is HarfBuzz.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 output text_size.

New in version 2.1.0.

HarfBuzz.ot_name_get_utf32(face, name_id, language)
Parameters:
Returns:

full length of the requested string, or 0 if not found.

text:

buffer to write fetched name into.

Return type:

(int, text: [int])

Fetches a font name from the OpenType ‘name’ table. If language is HarfBuzz.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 output text_size.

New in version 2.1.0.

HarfBuzz.ot_name_get_utf8(face, name_id, language)
Parameters:
Returns:

full length of the requested string, or 0 if not found.

text:

buffer to write fetched name into.

Return type:

(int, text: [str])

Fetches a font name from the OpenType ‘name’ table. If language is HarfBuzz.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 output text_size.

New in version 2.1.0.

HarfBuzz.ot_name_list_names(face)
Parameters:

face (HarfBuzz.face_t) – font face.

Returns:

Array of available name entries.

Return type:

[HarfBuzz.ot_name_entry_t]

Enumerates all available name IDs and language combinations. Returned array is owned by the face and should not be modified. It can be used as long as face is alive.

New in version 2.1.0.

HarfBuzz.ot_shape_glyphs_closure(font, buffer, features)
Parameters:
Returns:

The HarfBuzz.set_t set of glyphs comprising the transitive closure of the query

Return type:

glyphs: HarfBuzz.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.

New in version 0.9.2.

HarfBuzz.ot_shape_plan_collect_lookups(shape_plan, table_tag)
Parameters:
Returns:

The HarfBuzz.set_t set of lookups returned

Return type:

lookup_indexes: HarfBuzz.set_t

Computes the complete set of GSUB or GPOS lookups that are applicable under a given shape_plan.

New in version 0.9.7.

HarfBuzz.ot_tag_from_language(language)
Parameters:

language (HarfBuzz.language_t) – an HarfBuzz.language_t to convert.

Return type:

int

Converts an HarfBuzz.language_t to an #hb_tag_t.

New in version 0.6.0.

Deprecated since version 2.0.0: use HarfBuzz.ot_tags_from_script_and_language() instead

HarfBuzz.ot_tag_to_language(tag)
Parameters:

tag (int) – an language tag

Returns:

The HarfBuzz.language_t corresponding to tag.

Return type:

HarfBuzz.language_t or None

Converts a language tag to an HarfBuzz.language_t.

New in version 0.9.2.

HarfBuzz.ot_tag_to_script(tag)
Parameters:

tag (int) – a script tag

Returns:

The HarfBuzz.script_t corresponding to tag.

Return type:

HarfBuzz.script_t

Converts a script tag to an HarfBuzz.script_t.

HarfBuzz.ot_tags_from_script(script)
Parameters:

script (HarfBuzz.script_t) – an HarfBuzz.script_t to convert.

Returns:

script_tag_1:

output #hb_tag_t.

script_tag_2:

output #hb_tag_t.

Return type:

(script_tag_1: int, script_tag_2: int)

Converts an HarfBuzz.script_t to script tags.

New in version 0.6.0.

Deprecated since version 2.0.0: use HarfBuzz.ot_tags_from_script_and_language() instead

HarfBuzz.ot_tags_from_script_and_language(script, language, script_count, language_count)
Parameters:
Returns:

script_count:

maximum number of script tags to retrieve (IN) and actual number of script tags retrieved (OUT)

script_tags:

array of size at least script_count to store the script tag results

language_count:

maximum number of language tags to retrieve (IN) and actual number of language tags retrieved (OUT)

language_tags:

array of size at least language_count to store the language tag results

Return type:

(script_count: int, script_tags: int, language_count: int, language_tags: int)

Converts an HarfBuzz.script_t and an HarfBuzz.language_t to script and language tags.

New in version 2.0.0.

HarfBuzz.ot_tags_to_script_and_language(script_tag, language_tag)
Parameters:
  • script_tag (int) – a script tag

  • language_tag (int) – a language tag

Returns:

script:

the HarfBuzz.script_t corresponding to script_tag.

language:

the HarfBuzz.language_t corresponding to script_tag and language_tag.

Return type:

(script: HarfBuzz.script_t, language: HarfBuzz.language_t)

Converts a script tag and a language tag to an HarfBuzz.script_t and an HarfBuzz.language_t.

New in version 2.0.0.

HarfBuzz.ot_var_find_axis(face, axis_tag, axis_index)
Parameters:
Returns:

axis_info:

The HarfBuzz.ot_var_axis_info_t of the axis tag queried

Return type:

(int, axis_info: HarfBuzz.ot_var_axis_t)

Fetches the variation-axis information corresponding to the specified axis tag in the specified face.

New in version 1.4.2.

Deprecated since version 2.2.0: * use HarfBuzz.ot_var_find_axis_info() instead

HarfBuzz.ot_var_find_axis_info(face, axis_tag)
Parameters:
Returns:

true if data found, false otherwise

axis_info:

The HarfBuzz.ot_var_axis_info_t of the axis tag queried

Return type:

(int, axis_info: HarfBuzz.ot_var_axis_info_t)

Fetches the variation-axis information corresponding to the specified axis tag in the specified face.

New in version 2.2.0.

HarfBuzz.ot_var_get_axes(face, start_offset)
Parameters:
Returns:

axes_array:

The array of variation axes found

Return type:

(int, axes_array: [HarfBuzz.ot_var_axis_t])

Fetches a list of all variation axes in the specified face. The list returned will begin at the offset provided.

New in version 1.4.2.

Deprecated since version 2.2.0: use HarfBuzz.ot_var_get_axis_infos() instead

HarfBuzz.ot_var_get_axis_count(face)
Parameters:

face (HarfBuzz.face_t) – The HarfBuzz.face_t to work on

Returns:

the number of variation axes defined

Return type:

int

Fetches the number of OpenType variation axes included in the face.

New in version 1.4.2.

HarfBuzz.ot_var_get_axis_infos(face, start_offset)
Parameters:
Returns:

the number of variation axes in the face

axes_array:

The array of variation axes found

Return type:

(int, axes_array: [HarfBuzz.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.

New in version 2.2.0.

HarfBuzz.ot_var_get_named_instance_count(face)
Parameters:

face (HarfBuzz.face_t) – The HarfBuzz.face_t to work on

Returns:

the number of named instances defined

Return type:

int

Fetches the number of named instances included in the face.

New in version 2.2.0.

HarfBuzz.ot_var_has_data(face)
Parameters:

face (HarfBuzz.face_t) – The HarfBuzz.face_t to work on

Returns:

true if data found, false otherwise

Return type:

int

Tests whether a face includes any OpenType variation data in the fvar table.

New in version 1.4.2.

HarfBuzz.ot_var_named_instance_get_design_coords(face, instance_index)
Parameters:
Returns:

the number of variation axes in the face

coords:

The array of coordinates found for the query

Return type:

(int, coords: [float])

Fetches the design-space coordinates corresponding to the given named instance in the face.

New in version 2.2.0.

HarfBuzz.ot_var_named_instance_get_postscript_name_id(face, instance_index)
Parameters:
Returns:

the Name ID found for the PostScript name

Return type:

int

Fetches the name table Name ID that provides display names for the “PostScript name” defined for the given named instance in the face.

New in version 2.2.0.

HarfBuzz.ot_var_named_instance_get_subfamily_name_id(face, instance_index)
Parameters:
Returns:

the Name ID found for the Subfamily name

Return type:

int

Fetches the name table Name ID that provides display names for the “Subfamily name” defined for the given named instance in the face.

New in version 2.2.0.

HarfBuzz.ot_var_normalize_coords(face, coords_length, design_coords)
Parameters:
Returns:

The normalized coordinates

Return type:

normalized_coords: 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 avar table is also applied, as described at https://docs.microsoft.com/en-us/typography/opentype/spec/avar

New in version 1.4.2.

HarfBuzz.ot_var_normalize_variations(face, variations, variations_length)
Parameters:
Returns:

The array of normalized coordinates

Return type:

coords: [int]

Normalizes all of the coordinates in the given list of variation axes.

New in version 1.4.2.

HarfBuzz.paint_color(funcs, paint_data, is_foreground, color)
Parameters:
  • funcs (HarfBuzz.paint_funcs_t) – paint functions

  • paint_data (object or None) – associated data passed by the caller

  • is_foreground (int) – whether the color is the foreground

  • color (int) – The color to use

Perform a “color” paint operation.

New in version 7.0.0.

HarfBuzz.paint_color_glyph(funcs, paint_data, glyph, font)
Parameters:
Return type:

int

Perform a “color-glyph” paint operation.

New in version 8.2.0.

HarfBuzz.paint_custom_palette_color(funcs, paint_data, color_index)
Parameters:
Returns:

true if found, false otherwise

color:

fetched color

Return type:

(int, color: int)

Gets the custom palette color for color_index.

New in version 7.0.0.

HarfBuzz.paint_funcs_create()
Returns:

the paint-functions structure

Return type:

HarfBuzz.paint_funcs_t

Creates a new HarfBuzz.paint_funcs_t structure of paint functions.

The initial reference count of 1 should be released with hb_paint_funcs_destroy() when you are done using the HarfBuzz.paint_funcs_t. This function never returns NULL. If memory cannot be allocated, a special singleton HarfBuzz.paint_funcs_t object will be returned.

New in version 7.0.0.

HarfBuzz.paint_funcs_get_empty()
Returns:

The empty paint-functions structure

Return type:

HarfBuzz.paint_funcs_t

Fetches the singleton empty paint-functions structure.

New in version 7.0.0.

HarfBuzz.paint_funcs_is_immutable(funcs)
Parameters:

funcs (HarfBuzz.paint_funcs_t) – The paint-functions structure

Returns:

true if funcs is immutable, false otherwise

Return type:

int

Tests whether a paint-functions structure is immutable.

New in version 7.0.0.

HarfBuzz.paint_funcs_make_immutable(funcs)
Parameters:

funcs (HarfBuzz.paint_funcs_t) – The paint-functions structure

Makes a paint-functions structure immutable.

After this call, all attempts to set one of the callbacks on funcs will fail.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_color_func(funcs, func, *user_data)
Parameters:

Sets the paint-color callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_color_glyph_func(funcs, func, *user_data)
Parameters:

Sets the color-glyph callback on the paint functions struct.

New in version 8.2.0.

HarfBuzz.paint_funcs_set_custom_palette_color_func(funcs, func, *user_data)
Parameters:

Sets the custom-palette-color callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_image_func(funcs, func, *user_data)
Parameters:

Sets the paint-image callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_linear_gradient_func(funcs, func, *user_data)
Parameters:

Sets the linear-gradient callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_pop_clip_func(funcs, func, *user_data)
Parameters:

Sets the pop-clip callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_pop_group_func(funcs, func, *user_data)
Parameters:

Sets the pop-group callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_pop_transform_func(funcs, func, *user_data)
Parameters:

Sets the pop-transform callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_push_clip_glyph_func(funcs, func, *user_data)
Parameters:

Sets the push-clip-glyph callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_push_clip_rectangle_func(funcs, func, *user_data)
Parameters:

Sets the push-clip-rect callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_push_group_func(funcs, func, *user_data)
Parameters:

Sets the push-group callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_push_transform_func(funcs, func, *user_data)
Parameters:

Sets the push-transform callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_radial_gradient_func(funcs, func, *user_data)
Parameters:

Sets the radial-gradient callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_funcs_set_sweep_gradient_func(funcs, func, *user_data)
Parameters:

Sets the sweep-gradient callback on the paint functions struct.

New in version 7.0.0.

HarfBuzz.paint_image(funcs, paint_data, image, width, height, format, slant, extents)
Parameters:
  • funcs (HarfBuzz.paint_funcs_t) – paint functions

  • paint_data (object or None) – associated data passed by the caller

  • image (HarfBuzz.blob_t) – image data

  • width (int) – width of the raster image in pixels, or 0

  • height (int) – height of the raster image in pixels, or 0

  • format (int) – the image format as a tag

  • slant (float) – the synthetic slant ratio to be applied to the image during rendering

  • extents (HarfBuzz.glyph_extents_t or None) – the extents of the glyph

Perform a “image” paint operation.

New in version 7.0.0.

HarfBuzz.paint_linear_gradient(funcs, paint_data, color_line, x0, y0, x1, y1, x2, y2)
Parameters:
  • funcs (HarfBuzz.paint_funcs_t) – paint functions

  • paint_data (object or None) – associated data passed by the caller

  • color_line (HarfBuzz.color_line_t) – Color information for the gradient

  • x0 (float) – X coordinate of the first point

  • y0 (float) – Y coordinate of the first point

  • x1 (float) – X coordinate of the second point

  • y1 (float) – Y coordinate of the second point

  • x2 (float) – X coordinate of the third point

  • y2 (float) – Y coordinate of the third point

Perform a “linear-gradient” paint operation.

New in version 7.0.0.

HarfBuzz.paint_pop_clip(funcs, paint_data)
Parameters:

Perform a “pop-clip” paint operation.

New in version 7.0.0.

HarfBuzz.paint_pop_group(funcs, paint_data, mode)
Parameters:

Perform a “pop-group” paint operation.

New in version 7.0.0.

HarfBuzz.paint_pop_transform(funcs, paint_data)
Parameters:

Perform a “pop-transform” paint operation.

New in version 7.0.0.

HarfBuzz.paint_push_clip_glyph(funcs, paint_data, glyph, font)
Parameters:

Perform a “push-clip-glyph” paint operation.

New in version 7.0.0.

HarfBuzz.paint_push_clip_rectangle(funcs, paint_data, xmin, ymin, xmax, ymax)
Parameters:
  • funcs (HarfBuzz.paint_funcs_t) – paint functions

  • paint_data (object or None) – associated data passed by the caller

  • xmin (float) – min X for the rectangle

  • ymin (float) – min Y for the rectangle

  • xmax (float) – max X for the rectangle

  • ymax (float) – max Y for the rectangle

Perform a “push-clip-rect” paint operation.

New in version 7.0.0.

HarfBuzz.paint_push_group(funcs, paint_data)
Parameters:

Perform a “push-group” paint operation.

New in version 7.0.0.

HarfBuzz.paint_push_transform(funcs, paint_data, xx, yx, xy, yy, dx, dy)
Parameters:
  • funcs (HarfBuzz.paint_funcs_t) – paint functions

  • paint_data (object or None) – associated data passed by the caller

  • xx (float) – xx component of the transform matrix

  • yx (float) – yx component of the transform matrix

  • xy (float) – xy component of the transform matrix

  • yy (float) – yy component of the transform matrix

  • dx (float) – dx component of the transform matrix

  • dy (float) – dy component of the transform matrix

Perform a “push-transform” paint operation.

New in version 7.0.0.

HarfBuzz.paint_radial_gradient(funcs, paint_data, color_line, x0, y0, r0, x1, y1, r1)
Parameters:
  • funcs (HarfBuzz.paint_funcs_t) – paint functions

  • paint_data (object or None) – associated data passed by the caller

  • color_line (HarfBuzz.color_line_t) – Color information for the gradient

  • x0 (float) – X coordinate of the first circle’s center

  • y0 (float) – Y coordinate of the first circle’s center

  • r0 (float) – radius of the first circle

  • x1 (float) – X coordinate of the second circle’s center

  • y1 (float) – Y coordinate of the second circle’s center

  • r1 (float) – radius of the second circle

Perform a “radial-gradient” paint operation.

New in version 7.0.0.

HarfBuzz.paint_sweep_gradient(funcs, paint_data, color_line, x0, y0, start_angle, end_angle)
Parameters:
  • funcs (HarfBuzz.paint_funcs_t) – paint functions

  • paint_data (object or None) – associated data passed by the caller

  • color_line (HarfBuzz.color_line_t) – Color information for the gradient

  • x0 (float) – X coordinate of the circle’s center

  • y0 (float) – Y coordinate of the circle’s center

  • start_angle (float) – the start angle

  • end_angle (float) – the end angle

Perform a “sweep-gradient” paint operation.

New in version 7.0.0.

HarfBuzz.script_from_iso15924_tag(tag)
Parameters:

tag (int) – an #hb_tag_t representing an ISO 15924 tag.

Returns:

An HarfBuzz.script_t corresponding to the ISO 15924 tag.

Return type:

HarfBuzz.script_t

Converts an ISO 15924 script tag to a corresponding HarfBuzz.script_t.

New in version 0.9.2.

HarfBuzz.script_from_string(str)
Parameters:

str (bytes) – a string representing an ISO 15924 tag.

Returns:

An HarfBuzz.script_t corresponding to the ISO 15924 tag.

Return type:

HarfBuzz.script_t

Converts a string str representing an ISO 15924 script tag to a corresponding HarfBuzz.script_t. Shorthand for HarfBuzz.tag_from_string() then HarfBuzz.script_from_iso15924_tag().

New in version 0.9.2.

HarfBuzz.script_get_horizontal_direction(script)
Parameters:

script (HarfBuzz.script_t) – The HarfBuzz.script_t to query

Returns:

The horizontal HarfBuzz.direction_t of script

Return type:

HarfBuzz.direction_t

Fetches the HarfBuzz.direction_t of a script when it is set horizontally. All right-to-left scripts will return HarfBuzz.direction_t.RTL. All left-to-right scripts will return HarfBuzz.direction_t.LTR. Scripts that can be written either horizontally or vertically will return HarfBuzz.direction_t.INVALID. Unknown scripts will return HarfBuzz.direction_t.LTR.

New in version 0.9.2.

HarfBuzz.script_to_iso15924_tag(script)
Parameters:

script (HarfBuzz.script_t) – an HarfBuzz.script_t to convert.

Returns:

An #hb_tag_t representing an ISO 15924 script tag.

Return type:

int

Converts an HarfBuzz.script_t to a corresponding ISO 15924 script tag.

New in version 0.9.2.

HarfBuzz.segment_properties_equal(a, b)
Parameters:
Returns:

true if all properties of a equal those of b, false otherwise.

Return type:

int

Checks the equality of two HarfBuzz.segment_properties_t's.

New in version 0.9.7.

HarfBuzz.segment_properties_hash(p)
Parameters:

p (HarfBuzz.segment_properties_t) – HarfBuzz.segment_properties_t to hash.

Returns:

A hash of p.

Return type:

int

Creates a hash representing p.

New in version 0.9.7.

HarfBuzz.segment_properties_overlay(p, src)
Parameters:

Fills in missing fields of p from src in a considered manner.

First, if p does not have direction set, direction is copied from src.

Next, if p and src have the same direction (which can be unset), if p does not have script set, script is copied from src.

Finally, if p and src have the same direction and script (which either can be unset), if p does not have language set, language is copied from src.

New in version 3.3.0.

HarfBuzz.set_add(set, codepoint)
Parameters:

Adds codepoint to set.

New in version 0.9.2.

HarfBuzz.set_add_range(set, first, last)
Parameters:
  • set (HarfBuzz.set_t) – A set

  • first (int) – The first element to add to set

  • last (int) – The final element to add to set

Adds all of the elements from first to last (inclusive) to set.

New in version 0.9.7.

HarfBuzz.set_add_sorted_array(set, sorted_codepoints)
Parameters:
  • set (HarfBuzz.set_t) – A set

  • sorted_codepoints ([int]) – Array of codepoints to add

Adds num_codepoints codepoints to a set at once. The codepoints array must be in increasing order, with size at least num_codepoints.

New in version 4.1.0.

HarfBuzz.set_allocation_successful(set)
Parameters:

set (HarfBuzz.set_t) – A set

Returns:

true if allocation succeeded, false otherwise

Return type:

int

Tests whether memory allocation for a set was successful.

New in version 0.9.2.

HarfBuzz.set_clear(set)
Parameters:

set (HarfBuzz.set_t) – A set

Clears out the contents of a set.

New in version 0.9.2.

HarfBuzz.set_copy(set)
Parameters:

set (HarfBuzz.set_t) – A set

Returns:

Newly-allocated set.

Return type:

HarfBuzz.set_t

Allocate a copy of set.

New in version 2.8.2.

HarfBuzz.set_create()
Returns:

The new HarfBuzz.set_t

Return type:

HarfBuzz.set_t

Creates a new, initially empty set.

New in version 0.9.2.

HarfBuzz.set_del(set, codepoint)
Parameters:

Removes codepoint from set.

New in version 0.9.2.

HarfBuzz.set_del_range(set, first, last)
Parameters:
  • set (HarfBuzz.set_t) – A set

  • first (int) – The first element to remove from set

  • last (int) – The final element to remove from set

Removes all of the elements from first to last (inclusive) from set.

If last is #HB_SET_VALUE_INVALID, then all values greater than or equal to first are removed.

New in version 0.9.7.

HarfBuzz.set_get_empty()
Returns:

The empty HarfBuzz.set_t

Return type:

HarfBuzz.set_t

Fetches the singleton empty HarfBuzz.set_t.

New in version 0.9.2.

HarfBuzz.set_get_max(set)
Parameters:

set (HarfBuzz.set_t) – A set

Returns:

maximum of set, or #HB_SET_VALUE_INVALID if set is empty.

Return type:

int

Finds the largest element in the set.

New in version 0.9.7.

HarfBuzz.set_get_min(set)
Parameters:

set (HarfBuzz.set_t) – A set

Returns:

minimum of set, or #HB_SET_VALUE_INVALID if set is empty.

Return type:

int

Finds the smallest element in the set.

New in version 0.9.7.

HarfBuzz.set_get_population(set)
Parameters:

set (HarfBuzz.set_t) – A set

Returns:

The population of set

Return type:

int

Returns the number of elements in the set.

New in version 0.9.7.

HarfBuzz.set_has(set, codepoint)
Parameters:
Returns:

true if codepoint is in set, false otherwise

Return type:

int

Tests whether codepoint belongs to set.

New in version 0.9.2.

HarfBuzz.set_hash(set)
Parameters:

set (HarfBuzz.set_t) – A set

Returns:

A hash of set.

Return type:

int

Creates a hash representing set.

New in version 4.4.0.

HarfBuzz.set_intersect(set, other)
Parameters:

Makes set the intersection of set and other.

New in version 0.9.2.

HarfBuzz.set_invert(set)
Parameters:

set (HarfBuzz.set_t) – A set

Inverts the contents of set.

New in version 3.0.0.

HarfBuzz.set_is_empty(set)
Parameters:

set (HarfBuzz.set_t) – a set.

Returns:

true if set is empty

Return type:

int

Tests whether a set is empty (contains no elements).

New in version 0.9.7.

HarfBuzz.set_is_equal(set, other)
Parameters:
Returns:

true if the two sets are equal, false otherwise.

Return type:

int

Tests whether set and other are equal (contain the same elements).

New in version 0.9.7.

HarfBuzz.set_is_inverted(set)
Parameters:

set (HarfBuzz.set_t) – A set

Returns:

true if the set is inverted, false otherwise

Return type:

int

Returns whether the set is inverted.

New in version 7.0.0.

HarfBuzz.set_is_subset(set, larger_set)
Parameters:
Returns:

true if the set is a subset of (or equal to) larger_set, false otherwise.

Return type:

int

Tests whether set is a subset of larger_set.

New in version 1.8.1.

HarfBuzz.set_next(set, codepoint)
Parameters:
  • set (HarfBuzz.set_t) – A set

  • codepoint (int) – Input = Code point to query Output = Code point retrieved

Returns:

true if there was a next value, false otherwise

codepoint:

Input = Code point to query Output = Code point retrieved

Return type:

(int, codepoint: int)

Fetches the next element in set that is greater than current value of codepoint.

Set codepoint to #HB_SET_VALUE_INVALID to get started.

New in version 0.9.2.

HarfBuzz.set_next_many(set, codepoint, out)
Parameters:
  • set (HarfBuzz.set_t) – A set

  • codepoint (int) – Outputting codepoints starting after this one. Use #HB_SET_VALUE_INVALID to get started.

  • out ([int]) – An array of codepoints to write to.

Returns:

the number of values written.

Return type:

int

Finds the next element in set that is greater than codepoint. Writes out codepoints to out, until either the set runs out of elements, or size codepoints are written, whichever comes first.

New in version 4.2.0.

HarfBuzz.set_next_range(set, last)
Parameters:
  • set (HarfBuzz.set_t) – A set

  • last (int) – Input = The current last code point in the range Output = The last code point in the range

Returns:

true if there was a next range, false otherwise

first:

The first code point in the range

last:

Input = The current last code point in the range Output = The last code point in the range

Return type:

(int, first: int, last: int)

Fetches the next consecutive range of elements in set that are greater than current value of last.

Set last to #HB_SET_VALUE_INVALID to get started.

New in version 0.9.7.

HarfBuzz.set_previous(set, codepoint)
Parameters:
  • set (HarfBuzz.set_t) – A set

  • codepoint (int) – Input = Code point to query Output = Code point retrieved

Returns:

true if there was a previous value, false otherwise

codepoint:

Input = Code point to query Output = Code point retrieved

Return type:

(int, codepoint: int)

Fetches the previous element in set that is lower than current value of codepoint.

Set codepoint to #HB_SET_VALUE_INVALID to get started.

New in version 1.8.0.

HarfBuzz.set_previous_range(set, first)
Parameters:
  • set (HarfBuzz.set_t) – A set

  • first (int) – Input = The current first code point in the range Output = The first code point in the range

Returns:

true if there was a previous range, false otherwise

first:

Input = The current first code point in the range Output = The first code point in the range

last:

The last code point in the range

Return type:

(int, first: int, last: int)

Fetches the previous consecutive range of elements in set that are greater than current value of last.

Set first to #HB_SET_VALUE_INVALID to get started.

New in version 1.8.0.

HarfBuzz.set_set(set, other)
Parameters:

Makes the contents of set equal to the contents of other.

New in version 0.9.2.

HarfBuzz.set_subtract(set, other)
Parameters:

Subtracts the contents of other from set.

New in version 0.9.2.

HarfBuzz.set_symmetric_difference(set, other)
Parameters:

Makes set the symmetric difference of set and other.

New in version 0.9.2.

HarfBuzz.set_union(set, other)
Parameters:

Makes set the union of set and other.

New in version 0.9.2.

HarfBuzz.shape(font, buffer, features)
Parameters:

Shapes buffer using font turning its Unicode characters content to positioned glyphs. If features is not NULL, it will be used to control the features applied during shaping. If two features have the same tag but overlapping ranges the value of the feature with the higher index takes precedence.

New in version 0.9.2.

HarfBuzz.shape_full(font, buffer, features, shaper_list)
Parameters:
Returns:

false if all shapers failed, true otherwise

Return type:

int

See HarfBuzz.shape() for details. If shaper_list is not NULL, the specified shapers will be used in the given order, otherwise the default shapers list will be used.

New in version 0.9.2.

HarfBuzz.shape_justify(font, buffer, features, shaper_list, min_target_advance, max_target_advance, advance)
Parameters:
Returns:

false if all shapers failed, true otherwise

XSince: EXPERIMENTAL

advance:

Input/output advance width/height of the buffer.

var_tag:

Variation-axis tag used for justification.

var_value:

Variation-axis value used to reach target justification.

Return type:

(int, advance: float, var_tag: int, var_value: float)

See HarfBuzz.shape_full() for basic details. If shaper_list is not NULL, 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 HarfBuzz.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.

HarfBuzz.shape_list_shapers()
Returns:

an array of constant strings

Return type:

[str]

Retrieves the list of shapers supported by HarfBuzz.

New in version 0.9.2.

HarfBuzz.shape_plan_create(face, props, user_features, shaper_list)
Parameters:
Returns:

The shaping plan

Return type:

HarfBuzz.shape_plan_t

Constructs a shaping plan for a combination of face, user_features, props, and shaper_list.

New in version 0.9.7.

HarfBuzz.shape_plan_create2(face, props, user_features, coords, shaper_list)
Parameters:
Returns:

The shaping plan

Return type:

HarfBuzz.shape_plan_t

The variable-font version of HarfBuzz.shape_plan_create. Constructs a shaping plan for a combination of face, user_features, props, and shaper_list, plus the variation-space coordinates coords.

New in version 1.4.0.

HarfBuzz.shape_plan_create_cached(face, props, user_features, shaper_list)
Parameters:
Returns:

The shaping plan

Return type:

HarfBuzz.shape_plan_t

Creates a cached shaping plan suitable for reuse, for a combination of face, user_features, props, and shaper_list.

New in version 0.9.7.

HarfBuzz.shape_plan_create_cached2(face, props, user_features, coords, shaper_list)
Parameters:
Returns:

The shaping plan

Return type:

HarfBuzz.shape_plan_t

The variable-font version of HarfBuzz.shape_plan_create_cached. Creates a cached shaping plan suitable for reuse, for a combination of face, user_features, props, and shaper_list, plus the variation-space coordinates coords.

New in version 1.4.0.

HarfBuzz.shape_plan_execute(shape_plan, font, buffer, features)
Parameters:
Returns:

true if success, false otherwise.

Return type:

int

Executes the given shaping plan on the specified buffer, using the given font and features.

New in version 0.9.7.

HarfBuzz.shape_plan_get_empty()
Returns:

The empty shaping plan

Return type:

HarfBuzz.shape_plan_t

Fetches the singleton empty shaping plan.

New in version 0.9.7.

HarfBuzz.shape_plan_get_shaper(shape_plan)
Parameters:

shape_plan (HarfBuzz.shape_plan_t) – A shaping plan

Returns:

The shaper

Return type:

str

Fetches the shaper from a given shaping plan.

New in version 0.9.7.

HarfBuzz.style_get_value(font, style_tag)
Parameters:
Returns:

Corresponding axis or default value to a style tag.

Return type:

float

Searches variation axes of a HarfBuzz.font_t object for a specific axis first, if not set, then tries to get default style values from different tables of the font.

New in version 3.0.0.

HarfBuzz.tag_from_string(str)
Parameters:

str (bytes) – String to convert

Returns:

The #hb_tag_t corresponding to str

Return type:

int

Converts a string into an #hb_tag_t. Valid tags are four characters. Shorter input strings will be padded with spaces. Longer input strings will be truncated.

New in version 0.9.2.

HarfBuzz.tag_to_string(tag)
Parameters:

tag (int) – #hb_tag_t to convert

Returns:

Converted string

Return type:

buf: bytes

Converts an #hb_tag_t to a string and returns it in buf. Strings will be four characters long.

New in version 0.9.5.

HarfBuzz.unicode_combining_class(ufuncs, unicode)
Parameters:
Returns:

The HarfBuzz.unicode_combining_class_t of unicode

Return type:

HarfBuzz.unicode_combining_class_t

Retrieves the Canonical Combining Class (ccc) property of code point unicode.

New in version 0.9.2.

HarfBuzz.unicode_compose(ufuncs, a, b)
Parameters:
  • ufuncs (HarfBuzz.unicode_funcs_t) – The Unicode-functions structure

  • a (int) – The first Unicode code point to compose

  • b (int) – The second Unicode code point to compose

Returns:

true if a and b composed, false otherwise

ab:

The composition of a, b

Return type:

(int, ab: int)

Fetches the composition of a sequence of two Unicode code points.

Calls the composition function of the specified Unicode-functions structure ufuncs.

New in version 0.9.2.

HarfBuzz.unicode_decompose(ufuncs, ab)
Parameters:
Returns:

true if ab was decomposed, false otherwise

a:

The first code point of the decomposition of ab

b:

The second code point of the decomposition of ab

Return type:

(int, a: int, b: int)

Fetches the decomposition of a Unicode code point.

Calls the decomposition function of the specified Unicode-functions structure ufuncs.

New in version 0.9.2.

HarfBuzz.unicode_decompose_compatibility(ufuncs, u)
Parameters:
Returns:

length of decomposed.

decomposed:

Compatibility decomposition of u

Return type:

(int, decomposed: int)

Fetches the compatibility decomposition of a Unicode code point. Deprecated.

New in version 0.9.2.

Deprecated since version 2.0.0.

HarfBuzz.unicode_eastasian_width(ufuncs, unicode)
Parameters:
Return type:

int

Don’t use. Not used by HarfBuzz.

New in version 0.9.2.

Deprecated since version 2.0.0.

HarfBuzz.unicode_funcs_create(parent)
Parameters:

parent (HarfBuzz.unicode_funcs_t or None) – Parent Unicode-functions structure

Returns:

The Unicode-functions structure

Return type:

HarfBuzz.unicode_funcs_t

Creates a new HarfBuzz.unicode_funcs_t structure of Unicode functions.

New in version 0.9.2.

HarfBuzz.unicode_funcs_get_default()
Returns:

a pointer to the HarfBuzz.unicode_funcs_t Unicode-functions structure

Return type:

HarfBuzz.unicode_funcs_t

Fetches a pointer to the default Unicode-functions structure that is used when no functions are explicitly set on HarfBuzz.buffer_t.

New in version 0.9.2.

HarfBuzz.unicode_funcs_get_empty()
Returns:

The empty Unicode-functions structure

Return type:

HarfBuzz.unicode_funcs_t

Fetches the singleton empty Unicode-functions structure.

New in version 0.9.2.

HarfBuzz.unicode_funcs_get_parent(ufuncs)
Parameters:

ufuncs (HarfBuzz.unicode_funcs_t) – The Unicode-functions structure

Returns:

The parent Unicode-functions structure

Return type:

HarfBuzz.unicode_funcs_t

Fetches the parent of the Unicode-functions structure ufuncs.

New in version 0.9.2.

HarfBuzz.unicode_funcs_is_immutable(ufuncs)
Parameters:

ufuncs (HarfBuzz.unicode_funcs_t) – The Unicode-functions structure

Returns:

true if ufuncs is immutable, false otherwise

Return type:

int

Tests whether the specified Unicode-functions structure is immutable.

New in version 0.9.2.

HarfBuzz.unicode_funcs_make_immutable(ufuncs)
Parameters:

ufuncs (HarfBuzz.unicode_funcs_t) – The Unicode-functions structure

Makes the specified Unicode-functions structure immutable.

New in version 0.9.2.

HarfBuzz.unicode_funcs_set_combining_class_func(ufuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.unicode_combining_class_func_t.

New in version 0.9.2.

HarfBuzz.unicode_funcs_set_compose_func(ufuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.unicode_compose_func_t.

New in version 0.9.2.

HarfBuzz.unicode_funcs_set_decompose_compatibility_func(ufuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.unicode_decompose_compatibility_func_t.

New in version 0.9.2.

Deprecated since version 2.0.0.

HarfBuzz.unicode_funcs_set_decompose_func(ufuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.unicode_decompose_func_t.

New in version 0.9.2.

HarfBuzz.unicode_funcs_set_eastasian_width_func(ufuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.unicode_eastasian_width_func_t.

New in version 0.9.2.

Deprecated since version 2.0.0.

HarfBuzz.unicode_funcs_set_general_category_func(ufuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.unicode_general_category_func_t.

New in version 0.9.2.

HarfBuzz.unicode_funcs_set_mirroring_func(ufuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.unicode_mirroring_func_t.

New in version 0.9.2.

HarfBuzz.unicode_funcs_set_script_func(ufuncs, func, *user_data)
Parameters:

Sets the implementation function for HarfBuzz.unicode_script_func_t.

New in version 0.9.2.

HarfBuzz.unicode_general_category(ufuncs, unicode)
Parameters:
Returns:

The HarfBuzz.unicode_general_category_t of unicode

Return type:

HarfBuzz.unicode_general_category_t

Retrieves the General Category (gc) property of code point unicode.

New in version 0.9.2.

HarfBuzz.unicode_mirroring(ufuncs, unicode)
Parameters:
Returns:

The #hb_codepoint_t of the Mirroring Glyph for unicode

Return type:

int

Retrieves the Bi-directional Mirroring Glyph code point defined for code point unicode.

New in version 0.9.2.

HarfBuzz.unicode_script(ufuncs, unicode)
Parameters:
Returns:

The HarfBuzz.script_t of unicode

Return type:

HarfBuzz.script_t

Retrieves the HarfBuzz.script_t script to which code point unicode belongs.

New in version 0.9.2.

HarfBuzz.variation_from_string(str)
Parameters:

str (bytes) – a string to parse

Returns:

true if str is successfully parsed, false otherwise

variation:

the HarfBuzz.variation_t to initialize with the parsed values

Return type:

(int, variation: HarfBuzz.variation_t)

Parses a string into a HarfBuzz.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, or slnt=-7.5.

New in version 1.4.2.

HarfBuzz.variation_to_string(variation)
Parameters:

variation (HarfBuzz.variation_t) – an HarfBuzz.variation_t to convert

Returns:

output string

Return type:

buf: [str]

Converts an HarfBuzz.variation_t into a NULL-terminated string in the format understood by HarfBuzz.variation_from_string(). The client in responsible for allocating big enough size for buf, 128 bytes is more than enough.

New in version 1.4.2.