hb-ot-math

hb-ot-math — OpenType Math information

Functions

Types and Values

Includes

#include <hb-ot.h>

Description

Functions for fetching mathematics layout data from OpenType fonts.

HarfBuzz itself does not implement a math layout solution. The functions and types provided can be used by client programs to access the font data necessary for typesetting OpenType Math layout.

Functions

hb_ot_math_has_data ()

hb_bool_t
hb_ot_math_has_data (hb_face_t *face);

Tests whether a face has a MATH table.

Parameters

face

hb_face_t to test

 

Returns

true if the table is found, false otherwise

Since: 1.3.3


hb_ot_math_get_constant ()

hb_position_t
hb_ot_math_get_constant (hb_font_t *font,
                         hb_ot_math_constant_t constant);

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

However, if the requested constant is HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN, HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN or HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT, then the return value is an integer between 0 and 100 representing that percentage.

Parameters

font

hb_font_t to work upon

 

constant

hb_ot_math_constant_t the constant to retrieve

 

Returns

the requested constant or zero

Since: 1.3.3


hb_ot_math_get_glyph_italics_correction ()

hb_position_t
hb_ot_math_get_glyph_italics_correction
                               (hb_font_t *font,
                                hb_codepoint_t glyph);

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

Parameters

font

hb_font_t to work upon

 

glyph

The glyph index from which to retrieve the value

 

Returns

the italics correction of the glyph or zero

Since: 1.3.3


hb_ot_math_get_glyph_top_accent_attachment ()

hb_position_t
hb_ot_math_get_glyph_top_accent_attachment
                               (hb_font_t *font,
                                hb_codepoint_t glyph);

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.

Parameters

font

hb_font_t to work upon

 

glyph

The glyph index from which to retrieve the value

 

Returns

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

Since: 1.3.3


hb_ot_math_get_glyph_kerning ()

hb_position_t
hb_ot_math_get_glyph_kerning (hb_font_t *font,
                              hb_codepoint_t glyph,
                              hb_ot_math_kern_t kern,
                              hb_position_t correction_height);

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.

Parameters

font

hb_font_t to work upon

 

glyph

The glyph index from which to retrieve the value

 

kern

The hb_ot_math_kern_t from which to retrieve the value

 

correction_height

the correction height to use to determine the kerning.

 

Returns

requested kerning value or zero

Since: 1.3.3


hb_ot_math_get_glyph_kernings ()

unsigned int
hb_ot_math_get_glyph_kernings (hb_font_t *font,
                               hb_codepoint_t glyph,
                               hb_ot_math_kern_t kern,
                               unsigned int start_offset,
                               unsigned int *entries_count,
                               hb_ot_math_kern_entry_t *kern_entries);

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 hb_ot_math_kern_entry_t structs.

See also hb_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 hb_ot_math_kern_entry_t.kern_value of the uppermost hb_ot_math_kern_entry_t actually comes from the font; its corresponding hb_ot_math_kern_entry_t.max_correction_height is always set to INT32_MAX.

Parameters

font

hb_font_t to work upon

 

glyph

The glyph index from which to retrieve the kernings

 

kern

The hb_ot_math_kern_t from which to retrieve the kernings

 

start_offset

offset of the first kern entry to retrieve

 

entries_count

Input = the maximum number of kern entries to return; Output = the actual number of kern entries returned.

[inout][optional]

kern_entries

array of kern entries returned.

[out caller-allocates][array length=entries_count]

Returns

the total number of kern values available or zero

Since: 3.4.0


hb_ot_math_is_glyph_extended_shape ()

hb_bool_t
hb_ot_math_is_glyph_extended_shape (hb_face_t *face,
                                    hb_codepoint_t glyph);

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

Parameters

face

hb_face_t to work upon

 

glyph

The glyph index to test

 

Returns

true if the glyph is an extended shape, false otherwise

Since: 1.3.3


hb_ot_math_get_glyph_variants ()

unsigned int
hb_ot_math_get_glyph_variants (hb_font_t *font,
                               hb_codepoint_t glyph,
                               hb_direction_t direction,
                               unsigned int start_offset,
                               unsigned int *variants_count,
                               hb_ot_math_glyph_variant_t *variants);

Fetches the MathGlyphConstruction for the specified font, glyph index, and direction. The corresponding list of size variants is returned as a list of hb_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 hb_direction_t values are accepted, only the result of HB_DIRECTION_IS_HORIZONTAL is considered.

Parameters

font

hb_font_t to work upon

 

glyph

The index of the glyph to stretch

 

direction

The direction of the stretching (horizontal or vertical)

 

start_offset

offset of the first variant to retrieve

 

variants_count

Input = the maximum number of variants to return; Output = the actual number of variants returned.

[inout]

variants

array of variants returned.

[out][array length=variants_count]

Returns

the total number of size variants available or zero

Since: 1.3.3


hb_ot_math_get_min_connector_overlap ()

hb_position_t
hb_ot_math_get_min_connector_overlap (hb_font_t *font,
                                      hb_direction_t direction);

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 hb_direction_t values are accepted, only the result of HB_DIRECTION_IS_HORIZONTAL is considered.

Parameters

font

hb_font_t to work upon

 

direction

direction of the stretching (horizontal or vertical)

 

Returns

requested minimum connector overlap or zero

Since: 1.3.3


hb_ot_math_get_glyph_assembly ()

unsigned int
hb_ot_math_get_glyph_assembly (hb_font_t *font,
                               hb_codepoint_t glyph,
                               hb_direction_t direction,
                               unsigned int start_offset,
                               unsigned int *parts_count,
                               hb_ot_math_glyph_part_t *parts,
                               hb_position_t *italics_correction);

Fetches the GlyphAssembly for the specified font, glyph index, and direction. Returned are a list of hb_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 hb_direction_t values are accepted, only the result of HB_DIRECTION_IS_HORIZONTAL is considered.

Parameters

font

hb_font_t to work upon

 

glyph

The index of the glyph to stretch

 

direction

direction of the stretching (horizontal or vertical)

 

start_offset

offset of the first glyph part to retrieve

 

parts_count

Input = maximum number of glyph parts to return; Output = actual number of parts returned.

[inout]

parts

the glyph parts returned.

[out][array length=parts_count]

italics_correction

italics correction of the glyph assembly.

[out]

Returns

the total number of parts in the glyph assembly

Since: 1.3.3

Types and Values

HB_OT_TAG_MATH

#define HB_OT_TAG_MATH HB_TAG('M','A','T','H')

OpenType Mathematical Typesetting Table.

Since: 1.3.3


HB_OT_TAG_MATH_SCRIPT

#define HB_OT_TAG_MATH_SCRIPT HB_TAG('m','a','t','h')

OpenType script tag, math, for features specific to math shaping.

HB_OT_TAG_MATH_SCRIPT is not a valid hb_script_t and should only be used with functions that accept raw OpenType script tags, such as hb_ot_layout_collect_features. In other cases, HB_SCRIPT_MATH should be used instead.

Since: 3.4.0


enum hb_ot_math_constant_t

The 'MATH' table constants, refer to OpenType documentation For more explanations.

Members

HB_OT_MATH_CONSTANT_SCRIPT_PERCENT_SCALE_DOWN

scriptPercentScaleDown

 

HB_OT_MATH_CONSTANT_SCRIPT_SCRIPT_PERCENT_SCALE_DOWN

scriptScriptPercentScaleDown

 

HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT

delimitedSubFormulaMinHeight

 

HB_OT_MATH_CONSTANT_DISPLAY_OPERATOR_MIN_HEIGHT

displayOperatorMinHeight

 

HB_OT_MATH_CONSTANT_MATH_LEADING

mathLeading

 

HB_OT_MATH_CONSTANT_AXIS_HEIGHT

axisHeight

 

HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT

accentBaseHeight

 

HB_OT_MATH_CONSTANT_FLATTENED_ACCENT_BASE_HEIGHT

flattenedAccentBaseHeight

 

HB_OT_MATH_CONSTANT_SUBSCRIPT_SHIFT_DOWN

subscriptShiftDown

 

HB_OT_MATH_CONSTANT_SUBSCRIPT_TOP_MAX

subscriptTopMax

 

HB_OT_MATH_CONSTANT_SUBSCRIPT_BASELINE_DROP_MIN

subscriptBaselineDropMin

 

HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP

superscriptShiftUp

 

HB_OT_MATH_CONSTANT_SUPERSCRIPT_SHIFT_UP_CRAMPED

superscriptShiftUpCramped

 

HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MIN

superscriptBottomMin

 

HB_OT_MATH_CONSTANT_SUPERSCRIPT_BASELINE_DROP_MAX

superscriptBaselineDropMax

 

HB_OT_MATH_CONSTANT_SUB_SUPERSCRIPT_GAP_MIN

subSuperscriptGapMin

 

HB_OT_MATH_CONSTANT_SUPERSCRIPT_BOTTOM_MAX_WITH_SUBSCRIPT

superscriptBottomMaxWithSubscript

 

HB_OT_MATH_CONSTANT_SPACE_AFTER_SCRIPT

spaceAfterScript

 

HB_OT_MATH_CONSTANT_UPPER_LIMIT_GAP_MIN

upperLimitGapMin

 

HB_OT_MATH_CONSTANT_UPPER_LIMIT_BASELINE_RISE_MIN

upperLimitBaselineRiseMin

 

HB_OT_MATH_CONSTANT_LOWER_LIMIT_GAP_MIN

lowerLimitGapMin

 

HB_OT_MATH_CONSTANT_LOWER_LIMIT_BASELINE_DROP_MIN

lowerLimitBaselineDropMin

 

HB_OT_MATH_CONSTANT_STACK_TOP_SHIFT_UP

stackTopShiftUp

 

HB_OT_MATH_CONSTANT_STACK_TOP_DISPLAY_STYLE_SHIFT_UP

stackTopDisplayStyleShiftUp

 

HB_OT_MATH_CONSTANT_STACK_BOTTOM_SHIFT_DOWN

stackBottomShiftDown

 

HB_OT_MATH_CONSTANT_STACK_BOTTOM_DISPLAY_STYLE_SHIFT_DOWN

stackBottomDisplayStyleShiftDown

 

HB_OT_MATH_CONSTANT_STACK_GAP_MIN

stackGapMin

 

HB_OT_MATH_CONSTANT_STACK_DISPLAY_STYLE_GAP_MIN

stackDisplayStyleGapMin

 

HB_OT_MATH_CONSTANT_STRETCH_STACK_TOP_SHIFT_UP

stretchStackTopShiftUp

 

HB_OT_MATH_CONSTANT_STRETCH_STACK_BOTTOM_SHIFT_DOWN

stretchStackBottomShiftDown

 

HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_ABOVE_MIN

stretchStackGapAboveMin

 

HB_OT_MATH_CONSTANT_STRETCH_STACK_GAP_BELOW_MIN

stretchStackGapBelowMin

 

HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_SHIFT_UP

fractionNumeratorShiftUp

 

HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_DISPLAY_STYLE_SHIFT_UP

fractionNumeratorDisplayStyleShiftUp

 

HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_SHIFT_DOWN

fractionDenominatorShiftDown

 

HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_DISPLAY_STYLE_SHIFT_DOWN

fractionDenominatorDisplayStyleShiftDown

 

HB_OT_MATH_CONSTANT_FRACTION_NUMERATOR_GAP_MIN

fractionNumeratorGapMin

 

HB_OT_MATH_CONSTANT_FRACTION_NUM_DISPLAY_STYLE_GAP_MIN

fractionNumDisplayStyleGapMin

 

HB_OT_MATH_CONSTANT_FRACTION_RULE_THICKNESS

fractionRuleThickness

 

HB_OT_MATH_CONSTANT_FRACTION_DENOMINATOR_GAP_MIN

fractionDenominatorGapMin

 

HB_OT_MATH_CONSTANT_FRACTION_DENOM_DISPLAY_STYLE_GAP_MIN

fractionDenomDisplayStyleGapMin

 

HB_OT_MATH_CONSTANT_SKEWED_FRACTION_HORIZONTAL_GAP

skewedFractionHorizontalGap

 

HB_OT_MATH_CONSTANT_SKEWED_FRACTION_VERTICAL_GAP

skewedFractionVerticalGap

 

HB_OT_MATH_CONSTANT_OVERBAR_VERTICAL_GAP

overbarVerticalGap

 

HB_OT_MATH_CONSTANT_OVERBAR_RULE_THICKNESS

overbarRuleThickness

 

HB_OT_MATH_CONSTANT_OVERBAR_EXTRA_ASCENDER

overbarExtraAscender

 

HB_OT_MATH_CONSTANT_UNDERBAR_VERTICAL_GAP

underbarVerticalGap

 

HB_OT_MATH_CONSTANT_UNDERBAR_RULE_THICKNESS

underbarRuleThickness

 

HB_OT_MATH_CONSTANT_UNDERBAR_EXTRA_DESCENDER

underbarExtraDescender

 

HB_OT_MATH_CONSTANT_RADICAL_VERTICAL_GAP

radicalVerticalGap

 

HB_OT_MATH_CONSTANT_RADICAL_DISPLAY_STYLE_VERTICAL_GAP

radicalDisplayStyleVerticalGap

 

HB_OT_MATH_CONSTANT_RADICAL_RULE_THICKNESS

radicalRuleThickness

 

HB_OT_MATH_CONSTANT_RADICAL_EXTRA_ASCENDER

radicalExtraAscender

 

HB_OT_MATH_CONSTANT_RADICAL_KERN_BEFORE_DEGREE

radicalKernBeforeDegree

 

HB_OT_MATH_CONSTANT_RADICAL_KERN_AFTER_DEGREE

radicalKernAfterDegree

 

HB_OT_MATH_CONSTANT_RADICAL_DEGREE_BOTTOM_RAISE_PERCENT

radicalDegreeBottomRaisePercent

 

Since: 1.3.3


enum hb_ot_math_kern_t

The math kerning-table types defined for the four corners of a glyph.

Members

HB_OT_MATH_KERN_TOP_RIGHT

The top right corner of the glyph.

 

HB_OT_MATH_KERN_TOP_LEFT

The top left corner of the glyph.

 

HB_OT_MATH_KERN_BOTTOM_RIGHT

The bottom right corner of the glyph.

 

HB_OT_MATH_KERN_BOTTOM_LEFT

The bottom left corner of the glyph.

 

Since: 1.3.3


hb_ot_math_kern_entry_t

typedef struct {
  hb_position_t max_correction_height;
  hb_position_t kern_value;
} hb_ot_math_kern_entry_t;

Data type to hold math kerning (cut-in) information for a glyph.

Members

hb_position_t max_correction_height;

The maximum height at which this entry should be used

 

hb_position_t kern_value;

The kern value of the entry

 

Since: 3.4.0


hb_ot_math_glyph_variant_t

typedef struct {
  hb_codepoint_t glyph;
  hb_position_t advance;
} hb_ot_math_glyph_variant_t;

Data type to hold math-variant information for a glyph.

Members

hb_codepoint_t glyph;

The glyph index of the variant

 

hb_position_t advance;

The advance width of the variant

 

Since: 1.3.3


enum hb_ot_math_glyph_part_flags_t

Flags for math glyph parts.

Members

HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER

This is an extender glyph part that can be repeated to reach the desired length.

 

Since: 1.3.3


hb_ot_math_glyph_part_t

typedef struct {
  hb_codepoint_t glyph;
  hb_position_t start_connector_length;
  hb_position_t end_connector_length;
  hb_position_t full_advance;
  hb_ot_math_glyph_part_flags_t flags;
} hb_ot_math_glyph_part_t;

Data type to hold information for a "part" component of a math-variant glyph. Large variants for stretchable math glyphs (such as parentheses) can be constructed on the fly from parts.

Members

hb_codepoint_t glyph;

The glyph index of the variant part

 

hb_position_t start_connector_length;

The length of the connector on the starting side of the variant part

 

hb_position_t end_connector_length;

The length of the connector on the ending side of the variant part

 

hb_position_t full_advance;

The total advance of the part

 

hb_ot_math_glyph_part_flags_t flags;

hb_ot_math_glyph_part_flags_t flags for the part

 

Since: 1.3.3