Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | bfa8716 | 2018-02-10 13:37:28 -0600 | [diff] [blame] | 2 | * Copyright © 2018 Google, Inc. |
Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 3 | * |
| 4 | * This is part of HarfBuzz, a text shaping library. |
| 5 | * |
| 6 | * Permission is hereby granted, without written agreement and without |
| 7 | * license or royalty fees, to use, copy, modify, and distribute this |
| 8 | * software and its documentation for any purpose, provided that the |
| 9 | * above copyright notice and the following two paragraphs appear in |
| 10 | * all copies of this software. |
| 11 | * |
| 12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 16 | * DAMAGE. |
| 17 | * |
| 18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 23 | * |
| 24 | * Google Author(s): Rod Sheeter |
| 25 | */ |
| 26 | |
Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 27 | #ifndef HB_SUBSET_H |
| 28 | #define HB_SUBSET_H |
| 29 | |
Behdad Esfahbod | 0ff007d | 2018-02-04 20:22:07 -0500 | [diff] [blame] | 30 | #include "hb.h" |
Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 31 | |
| 32 | HB_BEGIN_DECLS |
| 33 | |
Khaled Hosny | acc7100 | 2021-07-26 02:13:49 +0200 | [diff] [blame] | 34 | /** |
| 35 | * hb_subset_input_t: |
Behdad Esfahbod | d5b33f2 | 2018-02-13 13:50:50 -0800 | [diff] [blame] | 36 | * |
Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 37 | * Things that change based on the input. Characters to keep, etc. |
| 38 | */ |
| 39 | |
| 40 | typedef struct hb_subset_input_t hb_subset_input_t; |
| 41 | |
Garret Rieger | 8ce9683 | 2021-06-23 13:55:11 -0700 | [diff] [blame] | 42 | /** |
Garret Rieger | b65e48a | 2022-02-11 12:44:58 -0800 | [diff] [blame] | 43 | * hb_subset_plan_t: |
| 44 | * |
| 45 | * Contains information about how the subset operation will be executed. |
| 46 | * Such as mappings from the old glyph ids to the new ones in the subset. |
| 47 | */ |
| 48 | |
| 49 | typedef struct hb_subset_plan_t hb_subset_plan_t; |
| 50 | |
| 51 | /** |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 52 | * hb_subset_flags_t: |
Ben Wagner | f5ba1fa | 2021-08-07 16:05:51 -0400 | [diff] [blame] | 53 | * @HB_SUBSET_FLAGS_DEFAULT: all flags at their default value of false. |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 54 | * @HB_SUBSET_FLAGS_NO_HINTING: If set hinting instructions will be dropped in |
| 55 | * the produced subset. Otherwise hinting instructions will be retained. |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 56 | * @HB_SUBSET_FLAGS_RETAIN_GIDS: If set glyph indices will not be modified in |
Garret Rieger | 8ce9683 | 2021-06-23 13:55:11 -0700 | [diff] [blame] | 57 | * the produced subset. If glyphs are dropped their indices will be retained |
Ben Wagner | f5ba1fa | 2021-08-07 16:05:51 -0400 | [diff] [blame] | 58 | * as an empty glyph. |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 59 | * @HB_SUBSET_FLAGS_DESUBROUTINIZE: If set and subsetting a CFF font the |
Garret Rieger | 8ce9683 | 2021-06-23 13:55:11 -0700 | [diff] [blame] | 60 | * subsetter will attempt to remove subroutines from the CFF glyphs. |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 61 | * @HB_SUBSET_FLAGS_NAME_LEGACY: If set non-unicode name records will be |
Ben Wagner | f5ba1fa | 2021-08-07 16:05:51 -0400 | [diff] [blame] | 62 | * retained in the subset. |
Garret Rieger | f9d8e4a | 2021-07-29 15:25:41 -0700 | [diff] [blame] | 63 | * @HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG: If set the subsetter will set the |
Ben Wagner | f5ba1fa | 2021-08-07 16:05:51 -0400 | [diff] [blame] | 64 | * OVERLAP_SIMPLE flag on each simple glyph. |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 65 | * @HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED: If set the subsetter will not |
Garret Rieger | 8ce9683 | 2021-06-23 13:55:11 -0700 | [diff] [blame] | 66 | * drop unrecognized tables and instead pass them through untouched. |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 67 | * @HB_SUBSET_FLAGS_NOTDEF_OUTLINE: If set the notdef glyph outline will be |
Ben Wagner | f5ba1fa | 2021-08-07 16:05:51 -0400 | [diff] [blame] | 68 | * retained in the final subset. |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 69 | * @HB_SUBSET_FLAGS_GLYPH_NAMES: If set the PS glyph names will be retained |
Ben Wagner | f5ba1fa | 2021-08-07 16:05:51 -0400 | [diff] [blame] | 70 | * in the final subset. |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 71 | * @HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES: If set then the unicode ranges in |
Garret Rieger | 792e2ed | 2021-07-22 12:41:48 -0700 | [diff] [blame] | 72 | * OS/2 will not be recalculated. |
Garret Rieger | 8ce9683 | 2021-06-23 13:55:11 -0700 | [diff] [blame] | 73 | * |
| 74 | * List of boolean properties that can be configured on the subset input. |
| 75 | * |
Khaled Hosny | 9aa6f8a | 2021-08-18 09:32:04 +0200 | [diff] [blame] | 76 | * Since: 2.9.0 |
Garret Rieger | 8ce9683 | 2021-06-23 13:55:11 -0700 | [diff] [blame] | 77 | **/ |
Garret Rieger | f9d8e4a | 2021-07-29 15:25:41 -0700 | [diff] [blame] | 78 | typedef enum { /*< flags >*/ |
| 79 | HB_SUBSET_FLAGS_DEFAULT = 0x00000000u, |
| 80 | HB_SUBSET_FLAGS_NO_HINTING = 0x00000001u, |
| 81 | HB_SUBSET_FLAGS_RETAIN_GIDS = 0x00000002u, |
| 82 | HB_SUBSET_FLAGS_DESUBROUTINIZE = 0x00000004u, |
| 83 | HB_SUBSET_FLAGS_NAME_LEGACY = 0x00000008u, |
| 84 | HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG = 0x00000010u, |
| 85 | HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED = 0x00000020u, |
| 86 | HB_SUBSET_FLAGS_NOTDEF_OUTLINE = 0x00000040u, |
| 87 | HB_SUBSET_FLAGS_GLYPH_NAMES = 0x00000080u, |
| 88 | HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES = 0x00000100u, |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 89 | } hb_subset_flags_t; |
Garret Rieger | 8372783 | 2021-06-09 11:09:14 -0700 | [diff] [blame] | 90 | |
Garret Rieger | e3e1ae8 | 2021-08-13 10:53:20 -0700 | [diff] [blame] | 91 | /** |
| 92 | * hb_subset_sets_t: |
Khaled Hosny | 9b7af95 | 2021-09-07 15:05:42 +0200 | [diff] [blame] | 93 | * @HB_SUBSET_SETS_GLYPH_INDEX: the set of glyph indexes to retain in the subset. |
| 94 | * @HB_SUBSET_SETS_UNICODE: the set of unicode codepoints to retain in the subset. |
Garret Rieger | e3e1ae8 | 2021-08-13 10:53:20 -0700 | [diff] [blame] | 95 | * @HB_SUBSET_SETS_NO_SUBSET_TABLE_TAG: the set of table tags which specifies tables that should not be |
| 96 | * subsetted. |
| 97 | * @HB_SUBSET_SETS_DROP_TABLE_TAG: the set of table tags which specifies tables which will be dropped |
| 98 | * in the subset. |
Garret Rieger | 5019326 | 2021-08-25 15:10:21 -0700 | [diff] [blame] | 99 | * @HB_SUBSET_SETS_NAME_ID: the set of name ids that will be retained. |
| 100 | * @HB_SUBSET_SETS_NAME_LANG_ID: the set of name lang ids that will be retained. |
| 101 | * @HB_SUBSET_SETS_LAYOUT_FEATURE_TAG: the set of layout feature tags that will be retained |
| 102 | * in the subset. |
Garret Rieger | 70e32a6 | 2022-06-30 21:00:48 +0000 | [diff] [blame] | 103 | * @HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG: the set of layout script tags that will be retained |
Garret Rieger | 216cf59 | 2022-07-05 17:49:12 +0000 | [diff] [blame] | 104 | * in the subset. Defaults to all tags. Since: REPLACEME |
Garret Rieger | e3e1ae8 | 2021-08-13 10:53:20 -0700 | [diff] [blame] | 105 | * |
| 106 | * List of sets that can be configured on the subset input. |
| 107 | * |
Khaled Hosny | 505df5a | 2021-09-07 13:46:08 +0200 | [diff] [blame] | 108 | * Since: 2.9.1 |
Garret Rieger | e3e1ae8 | 2021-08-13 10:53:20 -0700 | [diff] [blame] | 109 | **/ |
Garret Rieger | 1b5e159 | 2021-08-25 14:56:55 -0700 | [diff] [blame] | 110 | typedef enum { |
Garret Rieger | 1457c1f | 2021-08-25 15:01:28 -0700 | [diff] [blame] | 111 | HB_SUBSET_SETS_GLYPH_INDEX = 0, |
| 112 | HB_SUBSET_SETS_UNICODE, |
Garret Rieger | e3e1ae8 | 2021-08-13 10:53:20 -0700 | [diff] [blame] | 113 | HB_SUBSET_SETS_NO_SUBSET_TABLE_TAG, |
| 114 | HB_SUBSET_SETS_DROP_TABLE_TAG, |
Garret Rieger | 5019326 | 2021-08-25 15:10:21 -0700 | [diff] [blame] | 115 | HB_SUBSET_SETS_NAME_ID, |
| 116 | HB_SUBSET_SETS_NAME_LANG_ID, |
| 117 | HB_SUBSET_SETS_LAYOUT_FEATURE_TAG, |
Garret Rieger | 70e32a6 | 2022-06-30 21:00:48 +0000 | [diff] [blame] | 118 | HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG, |
Garret Rieger | e3e1ae8 | 2021-08-13 10:53:20 -0700 | [diff] [blame] | 119 | } hb_subset_sets_t; |
| 120 | |
Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 121 | HB_EXTERN hb_subset_input_t * |
Behdad Esfahbod | 9046e92 | 2018-02-13 22:07:12 -0800 | [diff] [blame] | 122 | hb_subset_input_create_or_fail (void); |
Behdad Esfahbod | d5b33f2 | 2018-02-13 13:50:50 -0800 | [diff] [blame] | 123 | |
| 124 | HB_EXTERN hb_subset_input_t * |
Garret Rieger | 1b6c1aa | 2021-06-28 12:57:39 -0700 | [diff] [blame] | 125 | hb_subset_input_reference (hb_subset_input_t *input); |
Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 126 | |
| 127 | HB_EXTERN void |
Garret Rieger | 1b6c1aa | 2021-06-28 12:57:39 -0700 | [diff] [blame] | 128 | hb_subset_input_destroy (hb_subset_input_t *input); |
Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 129 | |
Garret Rieger | 9ab751a | 2021-06-23 13:38:47 -0700 | [diff] [blame] | 130 | HB_EXTERN hb_bool_t |
| 131 | hb_subset_input_set_user_data (hb_subset_input_t *input, |
| 132 | hb_user_data_key_t *key, |
| 133 | void * data, |
| 134 | hb_destroy_func_t destroy, |
| 135 | hb_bool_t replace); |
| 136 | |
| 137 | HB_EXTERN void * |
| 138 | hb_subset_input_get_user_data (const hb_subset_input_t *input, |
Garret Rieger | ae8d373 | 2022-02-11 14:54:23 -0800 | [diff] [blame] | 139 | hb_user_data_key_t *key); |
Garret Rieger | 9ab751a | 2021-06-23 13:38:47 -0700 | [diff] [blame] | 140 | |
Behdad Esfahbod | d5b33f2 | 2018-02-13 13:50:50 -0800 | [diff] [blame] | 141 | HB_EXTERN hb_set_t * |
Garret Rieger | d700646 | 2021-09-16 11:23:09 -0700 | [diff] [blame] | 142 | hb_subset_input_unicode_set (hb_subset_input_t *input); |
| 143 | |
| 144 | HB_EXTERN hb_set_t * |
| 145 | hb_subset_input_glyph_set (hb_subset_input_t *input); |
| 146 | |
| 147 | HB_EXTERN hb_set_t * |
Garret Rieger | e3e1ae8 | 2021-08-13 10:53:20 -0700 | [diff] [blame] | 148 | hb_subset_input_set (hb_subset_input_t *input, hb_subset_sets_t set_type); |
Garret Rieger | 8372783 | 2021-06-09 11:09:14 -0700 | [diff] [blame] | 149 | |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 150 | HB_EXTERN hb_subset_flags_t |
| 151 | hb_subset_input_get_flags (hb_subset_input_t *input); |
Garret Rieger | 8372783 | 2021-06-09 11:09:14 -0700 | [diff] [blame] | 152 | |
| 153 | HB_EXTERN void |
Garret Rieger | 3d534b1 | 2021-07-29 11:52:14 -0700 | [diff] [blame] | 154 | hb_subset_input_set_flags (hb_subset_input_t *input, |
Garret Rieger | f9d8e4a | 2021-07-29 15:25:41 -0700 | [diff] [blame] | 155 | unsigned value); |
Garret Rieger | 8372783 | 2021-06-09 11:09:14 -0700 | [diff] [blame] | 156 | |
Qunxin Liu | 2a4773e | 2022-06-21 19:29:52 -0700 | [diff] [blame] | 157 | #ifdef HB_EXPERIMENTAL_API |
| 158 | #ifndef HB_NO_VAR |
| 159 | HB_EXTERN hb_bool_t |
| 160 | hb_subset_input_pin_axis_to_default (hb_subset_input_t *input, |
| 161 | hb_face_t *face, |
| 162 | hb_tag_t axis_tag); |
| 163 | |
| 164 | HB_EXTERN hb_bool_t |
| 165 | hb_subset_input_pin_axis_location (hb_subset_input_t *input, |
| 166 | hb_face_t *face, |
| 167 | hb_tag_t axis_tag, |
| 168 | float axis_value); |
| 169 | #endif |
| 170 | #endif |
| 171 | |
Garret Rieger | 668f2bd | 2021-06-09 16:33:50 -0700 | [diff] [blame] | 172 | HB_EXTERN hb_face_t * |
| 173 | hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input); |
| 174 | |
Garret Rieger | b65e48a | 2022-02-11 12:44:58 -0800 | [diff] [blame] | 175 | HB_EXTERN hb_face_t * |
Garret Rieger | ae8d373 | 2022-02-11 14:54:23 -0800 | [diff] [blame] | 176 | hb_subset_plan_execute_or_fail (hb_subset_plan_t *plan); |
Garret Rieger | b65e48a | 2022-02-11 12:44:58 -0800 | [diff] [blame] | 177 | |
| 178 | HB_EXTERN hb_subset_plan_t * |
Garret Rieger | 670ef07 | 2022-02-11 16:01:33 -0800 | [diff] [blame] | 179 | hb_subset_plan_create_or_fail (hb_face_t *face, |
| 180 | const hb_subset_input_t *input); |
Garret Rieger | b65e48a | 2022-02-11 12:44:58 -0800 | [diff] [blame] | 181 | |
| 182 | HB_EXTERN void |
| 183 | hb_subset_plan_destroy (hb_subset_plan_t *plan); |
| 184 | |
| 185 | HB_EXTERN const hb_map_t* |
| 186 | hb_subset_plan_old_to_new_glyph_mapping (const hb_subset_plan_t *plan); |
| 187 | |
| 188 | HB_EXTERN const hb_map_t* |
| 189 | hb_subset_plan_new_to_old_glyph_mapping (const hb_subset_plan_t *plan); |
| 190 | |
| 191 | HB_EXTERN const hb_map_t* |
Garret Rieger | f6071c1 | 2022-02-28 14:45:40 -0700 | [diff] [blame] | 192 | hb_subset_plan_unicode_to_old_glyph_mapping (const hb_subset_plan_t *plan); |
Garret Rieger | b65e48a | 2022-02-11 12:44:58 -0800 | [diff] [blame] | 193 | |
Garret Rieger | ae8d373 | 2022-02-11 14:54:23 -0800 | [diff] [blame] | 194 | |
| 195 | HB_EXTERN hb_subset_plan_t * |
| 196 | hb_subset_plan_reference (hb_subset_plan_t *plan); |
| 197 | |
| 198 | HB_EXTERN hb_bool_t |
| 199 | hb_subset_plan_set_user_data (hb_subset_plan_t *plan, |
| 200 | hb_user_data_key_t *key, |
| 201 | void *data, |
| 202 | hb_destroy_func_t destroy, |
| 203 | hb_bool_t replace); |
| 204 | |
| 205 | HB_EXTERN void * |
| 206 | hb_subset_plan_get_user_data (const hb_subset_plan_t *plan, |
| 207 | hb_user_data_key_t *key); |
| 208 | |
| 209 | |
Rod Sheeter | 9ccb836 | 2018-01-17 22:09:07 -0800 | [diff] [blame] | 210 | HB_END_DECLS |
| 211 | |
| 212 | #endif /* HB_SUBSET_H */ |