Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion harfrust_capi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ along with the tags, directions, scripts, languages, features and variations
they need. OpenType `BASE` baseline queries are available through
`hr_ot_layout_get_baseline` and its related functions. OpenType `MATH` queries
are available through `hr_ot_math_*` functions. Layout lookup queries support
glyph participation checks. The complete HarfBuzz set and map APIs are available
glyph participation checks. Script selection and language-specific feature lookup
are available with `hr_ot_layout_table_select_script` and
`hr_ot_layout_language_find_feature`; `hr_ot_layout_table_get_feature_tags`
enumerates all feature records, including duplicate tags. The complete HarfBuzz set and map APIs are available
as `hr_set_*` and `hr_map_*`, including inverted sets, ranges, set algebra, and
iteration. OpenType script and language tags can be converted with
`hr_ot_tag_to_language` and `hr_ot_tags_from_script_and_language`.
Expand Down
10 changes: 10 additions & 0 deletions harfrust_capi/include/hr-hb-ot.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
#define hb_ot_layout_get_horizontal_baseline_tag_for_script hr_ot_layout_get_horizontal_baseline_tag_for_script
#define hb_ot_layout_has_positioning hr_ot_layout_has_positioning
#define hb_ot_layout_has_substitution hr_ot_layout_has_substitution
#define hb_ot_layout_language_find_feature hr_ot_layout_language_find_feature
#define hb_ot_layout_lookup_collect_glyphs hr_ot_layout_lookup_collect_glyphs
#define hb_ot_layout_table_get_feature_tags hr_ot_layout_table_get_feature_tags
#define hb_ot_layout_table_get_lookup_count hr_ot_layout_table_get_lookup_count
#define hb_ot_layout_table_select_script hr_ot_layout_table_select_script
#define hb_ot_math_constant_t hr_ot_math_constant_t
#define hb_ot_math_get_constant hr_ot_math_get_constant
#define hb_ot_math_get_glyph_assembly hr_ot_math_get_glyph_assembly
Expand Down Expand Up @@ -46,6 +49,9 @@
#define HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT HR_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT
#define HB_OT_LAYOUT_BASELINE_TAG_MATH HR_OT_LAYOUT_BASELINE_TAG_MATH
#define HB_OT_LAYOUT_BASELINE_TAG_ROMAN HR_OT_LAYOUT_BASELINE_TAG_ROMAN
#define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX HR_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX
#define HB_OT_LAYOUT_NO_FEATURE_INDEX HR_OT_LAYOUT_NO_FEATURE_INDEX
#define HB_OT_LAYOUT_NO_SCRIPT_INDEX HR_OT_LAYOUT_NO_SCRIPT_INDEX
#define HB_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT HR_OT_MATH_CONSTANT_ACCENT_BASE_HEIGHT
#define HB_OT_MATH_CONSTANT_AXIS_HEIGHT HR_OT_MATH_CONSTANT_AXIS_HEIGHT
#define HB_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT HR_OT_MATH_CONSTANT_DELIMITED_SUB_FORMULA_MIN_HEIGHT
Expand Down Expand Up @@ -107,6 +113,10 @@
#define HB_OT_MATH_KERN_BOTTOM_RIGHT HR_OT_MATH_KERN_BOTTOM_RIGHT
#define HB_OT_MATH_KERN_TOP_LEFT HR_OT_MATH_KERN_TOP_LEFT
#define HB_OT_MATH_KERN_TOP_RIGHT HR_OT_MATH_KERN_TOP_RIGHT
#define HB_OT_TAG_DEFAULT_LANGUAGE HR_OT_TAG_DEFAULT_LANGUAGE
#define HB_OT_TAG_DEFAULT_SCRIPT HR_OT_TAG_DEFAULT_SCRIPT
#define HB_OT_TAG_GPOS HR_OT_TAG_GPOS
#define HB_OT_TAG_GSUB HR_OT_TAG_GSUB
#define HB_OT_TAG_MATH HR_OT_TAG_MATH
#define HB_OT_TAG_MATH_SCRIPT HR_OT_TAG_MATH_SCRIPT

Expand Down
3 changes: 2 additions & 1 deletion harfrust_capi/include/hr-hb.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* macros below would rewrite HarfBuzz's own declarations. Include one or the
* other.
*
* Shaping, BASE baseline, MATH, layout lookup, set, map, and OpenType tag
* Shaping, BASE baseline, MATH, layout script/feature/lookup, set, map, and OpenType tag
* conversion APIs are covered.
* Anything else HarfBuzz offers -- drawing and painting callbacks,
* subsetting, other layout table introspection, custom Unicode
Expand Down Expand Up @@ -378,6 +378,7 @@
#define HB_GLYPH_FLAG_UNSAFE_TO_CONCAT HR_GLYPH_FLAG_UNSAFE_TO_CONCAT
#define HB_LANGUAGE_INVALID HR_LANGUAGE_INVALID
#define HB_MAP_VALUE_INVALID HR_MAP_VALUE_INVALID
#define HB_MATH_GLYPH_PART_FLAG_EXTENDER HR_MATH_GLYPH_PART_FLAG_EXTENDER
#define HB_MEMORY_MODE_DUPLICATE HR_MEMORY_MODE_DUPLICATE
#define HB_MEMORY_MODE_READONLY HR_MEMORY_MODE_READONLY
#define HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE HR_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE
Expand Down
92 changes: 92 additions & 0 deletions harfrust_capi/include/hr.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@
*/
#define HR_FEATURE_GLOBAL_END 4294967295

/**
* No script was selected.
*/
#define HR_OT_LAYOUT_NO_SCRIPT_INDEX 65535

/**
* No feature was found.
*/
#define HR_OT_LAYOUT_NO_FEATURE_INDEX 65535

/**
* Selects a script's default language system.
*/
#define HR_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 65535

/**
* The major version of this library.
*
Expand Down Expand Up @@ -1662,6 +1677,26 @@ typedef struct hr_ot_math_glyph_part_t {
*/
#define HR_MAP_VALUE_INVALID HR_CODEPOINT_INVALID

/**
* The OpenType substitution table tag.
*/
#define HR_OT_TAG_GSUB 1196643650

/**
* The OpenType positioning table tag.
*/
#define HR_OT_TAG_GPOS 1196445523

/**
* The default OpenType script tag, `DFLT`.
*/
#define HR_OT_TAG_DEFAULT_SCRIPT 1145457748

/**
* The default OpenType language tag, `dflt`.
*/
#define HR_OT_TAG_DEFAULT_LANGUAGE 1684434036

#define HR_OT_LAYOUT_BASELINE_TAG_ROMAN 1919905134

#define HR_OT_LAYOUT_BASELINE_TAG_HANGING 1751215719
Expand Down Expand Up @@ -1802,6 +1837,11 @@ typedef struct hr_ot_math_glyph_part_t {

#define HR_OT_MATH_GLYPH_PART_FLAG_EXTENDER 1

/**
* Deprecated HarfBuzz spelling of `HR_OT_MATH_GLYPH_PART_FLAG_EXTENDER`.
*/
#define HR_MATH_GLYPH_PART_FLAG_EXTENDER HR_OT_MATH_GLYPH_PART_FLAG_EXTENDER

#define HR_OT_TAG_MATH 1296127048

#define HR_OT_TAG_MATH_SCRIPT 1835103336
Expand Down Expand Up @@ -3911,6 +3951,58 @@ void hr_map_keys(const struct hr_map_t *map, struct hr_set_t *keys);
*/
void hr_map_values(const struct hr_map_t *map, struct hr_set_t *values);

/**
* Selects the first available requested script in GSUB or GPOS.
*
* If none matches, tries `DFLT`, `dflt`, then `latn`. Returns true only for
* a requested script, even when a fallback was selected. With no match,
* writes `HR_OT_LAYOUT_NO_SCRIPT_INDEX` and a zero tag to the outputs.
*
* # Safety
* `face` must be null or live; `script_tags` must hold `script_count` tags
* when non-null. Both output pointers must be null or writable.
*/
hr_bool_t hr_ot_layout_table_select_script(struct hr_face_t *face,
hr_tag_t table_tag,
unsigned int script_count,
const hr_tag_t *script_tags,
unsigned int *script_index,
hr_tag_t *chosen_script);

/**
* Returns the total number of feature records in GSUB or GPOS.
*
* Copies tags starting at `start_offset`, including duplicates. When both
* array and count are non-null, the count gives capacity on entry and the
* number written on return. A null array leaves the count unchanged.
*
* # Safety
* `face` must be null or live; `feature_count` must be null or writable;
* `feature_tags` must hold the input capacity when non-null.
*/
unsigned int hr_ot_layout_table_get_feature_tags(struct hr_face_t *face,
hr_tag_t table_tag,
unsigned int start_offset,
unsigned int *feature_count,
hr_tag_t *feature_tags);

/**
* Finds an optional feature in a script's language system in GSUB or GPOS.
*
* Use `HR_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX` for the default language system.
* A required feature is not included in this search. Writes the feature's
* table-wide index, or `HR_OT_LAYOUT_NO_FEATURE_INDEX` on failure.
*
* # Safety
* `face` must be null or live; `feature_index` must be null or writable.
*/
hr_bool_t hr_ot_layout_language_find_feature(struct hr_face_t *face,
hr_tag_t table_tag,
unsigned int script_index,
unsigned int language_index,
hr_tag_t feature_tag,
unsigned int *feature_index);

/**
* Returns whether the face has a readable GSUB table.
*
Expand Down
10 changes: 9 additions & 1 deletion harfrust_capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ as HarfBuzz itself without collisions.
# Scope

This covers shaping: blobs, faces, fonts, buffers and `hr_shape`, plus OpenType
`BASE` baseline and `MATH` queries. It also provides layout lookup queries,
`BASE` baseline and `MATH` queries. It also provides layout script/feature and lookup queries,
OpenType script and language tag conversion, and the complete set and map
container APIs. Drawing and painting callbacks and subsetting are outside this API.

Expand Down Expand Up @@ -84,3 +84,11 @@ mod skia_batch_tests;
#[cfg(test)]
#[path = "../tests/skia_version.rs"]
mod skia_version_tests;

#[cfg(test)]
#[path = "../tests/tables.rs"]
mod table_tests;

#[cfg(test)]
#[path = "../tests/ot_queries.rs"]
mod ot_query_tests;
Loading
Loading