From d18aad7ec5e940cf2bd31f5005df739f42da2590 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Fri, 13 Aug 2021 15:05:48 -0700 Subject: [PATCH] [subset] restore old subsetting api methods. These will be left in place until the 3.0.0 release. --- src/hb-subset-input.cc | 130 +++++++++++++++++++++++++++++++++++++++++ src/hb-subset.cc | 8 +++ src/hb-subset.h | 61 +++++++++++++++++++ 3 files changed, 199 insertions(+) diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index fd49cb34f..9e91b08db 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -426,3 +426,133 @@ hb_subset_input_get_user_data (const hb_subset_input_t *input, { return hb_object_get_user_data (input, key); } + + +static void set_flag_value (hb_subset_input_t *input, hb_subset_flags_t flag, hb_bool_t value) +{ + hb_subset_input_set_flags (input, + value + ? hb_subset_input_get_flags (input) | flag + : hb_subset_input_get_flags (input) & ~flag); +} + +void +hb_subset_input_set_retain_all_features (hb_subset_input_t *subset_input, + hb_bool_t value) +{ + return set_flag_value (subset_input, + HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES, + value); +} + +hb_bool_t +hb_subset_input_get_retain_all_features (hb_subset_input_t *subset_input) +{ + return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_RETAIN_ALL_FEATURES; +} + +void +hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, + hb_bool_t drop_hints) +{ + return set_flag_value (subset_input, + HB_SUBSET_FLAGS_NO_HINTING, + drop_hints); +} + +hb_bool_t +hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input) +{ + return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NO_HINTING; +} + +void +hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, + hb_bool_t desubroutinize) +{ + return set_flag_value (subset_input, + HB_SUBSET_FLAGS_DESUBROUTINIZE, + desubroutinize); +} + +hb_bool_t +hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input) +{ + return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_DESUBROUTINIZE; +} + +void +hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input, + hb_bool_t retain_gids) +{ + return set_flag_value (subset_input, + HB_SUBSET_FLAGS_RETAIN_GIDS, + retain_gids); +} + +hb_bool_t +hb_subset_input_get_retain_gids (hb_subset_input_t *subset_input) +{ + return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_RETAIN_GIDS; +} + +void +hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input, + hb_bool_t name_legacy) +{ + return set_flag_value (subset_input, + HB_SUBSET_FLAGS_NAME_LEGACY, + name_legacy); +} + +hb_bool_t +hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input) +{ + return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NAME_LEGACY; +} + +void +hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input, + hb_bool_t overlaps_flag) +{ + return set_flag_value (subset_input, + HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG, + overlaps_flag); +} + +hb_bool_t +hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input) +{ + return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG; +} + +void +hb_subset_input_set_notdef_outline (hb_subset_input_t *subset_input, + hb_bool_t notdef_outline) +{ + return set_flag_value (subset_input, + HB_SUBSET_FLAGS_NOTDEF_OUTLINE, + notdef_outline); +} + +hb_bool_t +hb_subset_input_get_notdef_outline (hb_subset_input_t *subset_input) +{ + return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NOTDEF_OUTLINE; +} + +void +hb_subset_input_set_no_prune_unicode_ranges (hb_subset_input_t *subset_input, + hb_bool_t no_prune_unicode_ranges) +{ + return set_flag_value (subset_input, + HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES, + no_prune_unicode_ranges); +} + + +hb_bool_t +hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input) +{ + return hb_subset_input_get_flags (subset_input) & HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES; +} diff --git a/src/hb-subset.cc b/src/hb-subset.cc index fdc584e42..cde73bda6 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -330,6 +330,14 @@ _subset_table (hb_subset_plan_t *plan, hb_tag_t tag) } } +hb_face_t * +hb_subset (hb_face_t *source, hb_subset_input_t *input) +{ + hb_face_t* face = hb_subset_or_fail (source, input); + if (face) return face; + return hb_face_get_empty (); +} + /** * hb_subset_or_fail: * @source: font face data to be subset. diff --git a/src/hb-subset.h b/src/hb-subset.h index 7ba849636..6d22fa54b 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -135,6 +135,67 @@ hb_subset_input_set_flags (hb_subset_input_t *input, HB_EXTERN hb_face_t * hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input); + +/* + * ### Legacy API ### + * The methods below are part of the legacy harfbuzz subsetting API and will be + * Removed as of version 3.0.0 + */ + +HB_EXTERN void +hb_subset_input_set_retain_all_features (hb_subset_input_t *subset_input, + hb_bool_t value); +HB_EXTERN hb_bool_t +hb_subset_input_get_retain_all_features (hb_subset_input_t *subset_input); + +HB_EXTERN void +hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input, + hb_bool_t drop_hints); +HB_EXTERN hb_bool_t +hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input); + +HB_EXTERN void +hb_subset_input_set_desubroutinize (hb_subset_input_t *subset_input, + hb_bool_t desubroutinize); +HB_EXTERN hb_bool_t +hb_subset_input_get_desubroutinize (hb_subset_input_t *subset_input); + +HB_EXTERN void +hb_subset_input_set_retain_gids (hb_subset_input_t *subset_input, + hb_bool_t retain_gids); +HB_EXTERN hb_bool_t +hb_subset_input_get_retain_gids (hb_subset_input_t *subset_input); + +HB_EXTERN void +hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input, + hb_bool_t name_legacy); +HB_EXTERN hb_bool_t +hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input); + +HB_EXTERN void +hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input, + hb_bool_t overlaps_flag); + +HB_EXTERN hb_bool_t +hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input); + +HB_EXTERN void +hb_subset_input_set_notdef_outline (hb_subset_input_t *subset_input, + hb_bool_t notdef_outline); + +HB_EXTERN hb_bool_t +hb_subset_input_get_notdef_outline (hb_subset_input_t *subset_input); + +HB_EXTERN void +hb_subset_input_set_no_prune_unicode_ranges (hb_subset_input_t *subset_input, + hb_bool_t no_prune_unicode_ranges); + +HB_EXTERN hb_bool_t +hb_subset_input_get_no_prune_unicode_ranges (hb_subset_input_t *subset_input); + +HB_EXTERN hb_face_t * +hb_subset (hb_face_t *source, hb_subset_input_t *input); + HB_END_DECLS #endif /* HB_SUBSET_H */