blob: f4346c70c4ce183b68aaeb0c68e46446fe68e2ab [file] [log] [blame]
Rod Sheeter9ccb8362018-01-17 22:09:07 -08001/*
Behdad Esfahbodbfa87162018-02-10 13:37:28 -06002 * Copyright © 2018 Google, Inc.
Rod Sheeter9ccb8362018-01-17 22:09:07 -08003 *
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 Sheeter9ccb8362018-01-17 22:09:07 -080027#ifndef HB_SUBSET_H
28#define HB_SUBSET_H
29
Behdad Esfahbod0ff007d2018-02-04 20:22:07 -050030#include "hb.h"
Rod Sheeter9ccb8362018-01-17 22:09:07 -080031
32HB_BEGIN_DECLS
33
Khaled Hosnyacc71002021-07-26 02:13:49 +020034/**
35 * hb_subset_input_t:
Behdad Esfahbodd5b33f22018-02-13 13:50:50 -080036 *
Rod Sheeter9ccb8362018-01-17 22:09:07 -080037 * Things that change based on the input. Characters to keep, etc.
38 */
39
40typedef struct hb_subset_input_t hb_subset_input_t;
41
Garret Rieger8ce96832021-06-23 13:55:11 -070042/**
Garret Riegerb65e48a2022-02-11 12:44:58 -080043 * 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
49typedef struct hb_subset_plan_t hb_subset_plan_t;
50
51/**
Garret Rieger3d534b12021-07-29 11:52:14 -070052 * hb_subset_flags_t:
Ben Wagnerf5ba1fa2021-08-07 16:05:51 -040053 * @HB_SUBSET_FLAGS_DEFAULT: all flags at their default value of false.
Garret Rieger3d534b12021-07-29 11:52:14 -070054 * @HB_SUBSET_FLAGS_NO_HINTING: If set hinting instructions will be dropped in
55 * the produced subset. Otherwise hinting instructions will be retained.
Garret Rieger3d534b12021-07-29 11:52:14 -070056 * @HB_SUBSET_FLAGS_RETAIN_GIDS: If set glyph indices will not be modified in
Garret Rieger8ce96832021-06-23 13:55:11 -070057 * the produced subset. If glyphs are dropped their indices will be retained
Ben Wagnerf5ba1fa2021-08-07 16:05:51 -040058 * as an empty glyph.
Garret Rieger3d534b12021-07-29 11:52:14 -070059 * @HB_SUBSET_FLAGS_DESUBROUTINIZE: If set and subsetting a CFF font the
Garret Rieger8ce96832021-06-23 13:55:11 -070060 * subsetter will attempt to remove subroutines from the CFF glyphs.
Garret Rieger3d534b12021-07-29 11:52:14 -070061 * @HB_SUBSET_FLAGS_NAME_LEGACY: If set non-unicode name records will be
Ben Wagnerf5ba1fa2021-08-07 16:05:51 -040062 * retained in the subset.
Garret Riegerf9d8e4a2021-07-29 15:25:41 -070063 * @HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG: If set the subsetter will set the
Ben Wagnerf5ba1fa2021-08-07 16:05:51 -040064 * OVERLAP_SIMPLE flag on each simple glyph.
Garret Rieger3d534b12021-07-29 11:52:14 -070065 * @HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED: If set the subsetter will not
Garret Rieger8ce96832021-06-23 13:55:11 -070066 * drop unrecognized tables and instead pass them through untouched.
Garret Rieger3d534b12021-07-29 11:52:14 -070067 * @HB_SUBSET_FLAGS_NOTDEF_OUTLINE: If set the notdef glyph outline will be
Ben Wagnerf5ba1fa2021-08-07 16:05:51 -040068 * retained in the final subset.
Garret Rieger3d534b12021-07-29 11:52:14 -070069 * @HB_SUBSET_FLAGS_GLYPH_NAMES: If set the PS glyph names will be retained
Ben Wagnerf5ba1fa2021-08-07 16:05:51 -040070 * in the final subset.
Garret Rieger3d534b12021-07-29 11:52:14 -070071 * @HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES: If set then the unicode ranges in
Garret Rieger792e2ed2021-07-22 12:41:48 -070072 * OS/2 will not be recalculated.
Garret Rieger8ce96832021-06-23 13:55:11 -070073 *
74 * List of boolean properties that can be configured on the subset input.
75 *
Khaled Hosny9aa6f8a2021-08-18 09:32:04 +020076 * Since: 2.9.0
Garret Rieger8ce96832021-06-23 13:55:11 -070077 **/
Garret Riegerf9d8e4a2021-07-29 15:25:41 -070078typedef 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 Rieger3d534b12021-07-29 11:52:14 -070089} hb_subset_flags_t;
Garret Rieger83727832021-06-09 11:09:14 -070090
Garret Riegere3e1ae82021-08-13 10:53:20 -070091/**
92 * hb_subset_sets_t:
Khaled Hosny9b7af952021-09-07 15:05:42 +020093 * @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 Riegere3e1ae82021-08-13 10:53:20 -070095 * @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 Rieger50193262021-08-25 15:10:21 -070099 * @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 Rieger70e32a62022-06-30 21:00:48 +0000103 * @HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG: the set of layout script tags that will be retained
Garret Rieger216cf592022-07-05 17:49:12 +0000104 * in the subset. Defaults to all tags. Since: REPLACEME
Garret Riegere3e1ae82021-08-13 10:53:20 -0700105 *
106 * List of sets that can be configured on the subset input.
107 *
Khaled Hosny505df5a2021-09-07 13:46:08 +0200108 * Since: 2.9.1
Garret Riegere3e1ae82021-08-13 10:53:20 -0700109 **/
Garret Rieger1b5e1592021-08-25 14:56:55 -0700110typedef enum {
Garret Rieger1457c1f2021-08-25 15:01:28 -0700111 HB_SUBSET_SETS_GLYPH_INDEX = 0,
112 HB_SUBSET_SETS_UNICODE,
Garret Riegere3e1ae82021-08-13 10:53:20 -0700113 HB_SUBSET_SETS_NO_SUBSET_TABLE_TAG,
114 HB_SUBSET_SETS_DROP_TABLE_TAG,
Garret Rieger50193262021-08-25 15:10:21 -0700115 HB_SUBSET_SETS_NAME_ID,
116 HB_SUBSET_SETS_NAME_LANG_ID,
117 HB_SUBSET_SETS_LAYOUT_FEATURE_TAG,
Garret Rieger70e32a62022-06-30 21:00:48 +0000118 HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG,
Garret Riegere3e1ae82021-08-13 10:53:20 -0700119} hb_subset_sets_t;
120
Rod Sheeter9ccb8362018-01-17 22:09:07 -0800121HB_EXTERN hb_subset_input_t *
Behdad Esfahbod9046e922018-02-13 22:07:12 -0800122hb_subset_input_create_or_fail (void);
Behdad Esfahbodd5b33f22018-02-13 13:50:50 -0800123
124HB_EXTERN hb_subset_input_t *
Garret Rieger1b6c1aa2021-06-28 12:57:39 -0700125hb_subset_input_reference (hb_subset_input_t *input);
Rod Sheeter9ccb8362018-01-17 22:09:07 -0800126
127HB_EXTERN void
Garret Rieger1b6c1aa2021-06-28 12:57:39 -0700128hb_subset_input_destroy (hb_subset_input_t *input);
Rod Sheeter9ccb8362018-01-17 22:09:07 -0800129
Garret Rieger9ab751a2021-06-23 13:38:47 -0700130HB_EXTERN hb_bool_t
131hb_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
137HB_EXTERN void *
138hb_subset_input_get_user_data (const hb_subset_input_t *input,
Garret Riegerae8d3732022-02-11 14:54:23 -0800139 hb_user_data_key_t *key);
Garret Rieger9ab751a2021-06-23 13:38:47 -0700140
Behdad Esfahbodd5b33f22018-02-13 13:50:50 -0800141HB_EXTERN hb_set_t *
Garret Riegerd7006462021-09-16 11:23:09 -0700142hb_subset_input_unicode_set (hb_subset_input_t *input);
143
144HB_EXTERN hb_set_t *
145hb_subset_input_glyph_set (hb_subset_input_t *input);
146
147HB_EXTERN hb_set_t *
Garret Riegere3e1ae82021-08-13 10:53:20 -0700148hb_subset_input_set (hb_subset_input_t *input, hb_subset_sets_t set_type);
Garret Rieger83727832021-06-09 11:09:14 -0700149
Garret Rieger3d534b12021-07-29 11:52:14 -0700150HB_EXTERN hb_subset_flags_t
151hb_subset_input_get_flags (hb_subset_input_t *input);
Garret Rieger83727832021-06-09 11:09:14 -0700152
153HB_EXTERN void
Garret Rieger3d534b12021-07-29 11:52:14 -0700154hb_subset_input_set_flags (hb_subset_input_t *input,
Garret Riegerf9d8e4a2021-07-29 15:25:41 -0700155 unsigned value);
Garret Rieger83727832021-06-09 11:09:14 -0700156
Qunxin Liu2a4773e2022-06-21 19:29:52 -0700157#ifdef HB_EXPERIMENTAL_API
158#ifndef HB_NO_VAR
159HB_EXTERN hb_bool_t
160hb_subset_input_pin_axis_to_default (hb_subset_input_t *input,
161 hb_face_t *face,
162 hb_tag_t axis_tag);
163
164HB_EXTERN hb_bool_t
165hb_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 Rieger668f2bd2021-06-09 16:33:50 -0700172HB_EXTERN hb_face_t *
173hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input);
174
Garret Riegerb65e48a2022-02-11 12:44:58 -0800175HB_EXTERN hb_face_t *
Garret Riegerae8d3732022-02-11 14:54:23 -0800176hb_subset_plan_execute_or_fail (hb_subset_plan_t *plan);
Garret Riegerb65e48a2022-02-11 12:44:58 -0800177
178HB_EXTERN hb_subset_plan_t *
Garret Rieger670ef072022-02-11 16:01:33 -0800179hb_subset_plan_create_or_fail (hb_face_t *face,
180 const hb_subset_input_t *input);
Garret Riegerb65e48a2022-02-11 12:44:58 -0800181
182HB_EXTERN void
183hb_subset_plan_destroy (hb_subset_plan_t *plan);
184
185HB_EXTERN const hb_map_t*
186hb_subset_plan_old_to_new_glyph_mapping (const hb_subset_plan_t *plan);
187
188HB_EXTERN const hb_map_t*
189hb_subset_plan_new_to_old_glyph_mapping (const hb_subset_plan_t *plan);
190
191HB_EXTERN const hb_map_t*
Garret Riegerf6071c12022-02-28 14:45:40 -0700192hb_subset_plan_unicode_to_old_glyph_mapping (const hb_subset_plan_t *plan);
Garret Riegerb65e48a2022-02-11 12:44:58 -0800193
Garret Riegerae8d3732022-02-11 14:54:23 -0800194
195HB_EXTERN hb_subset_plan_t *
196hb_subset_plan_reference (hb_subset_plan_t *plan);
197
198HB_EXTERN hb_bool_t
199hb_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
205HB_EXTERN void *
206hb_subset_plan_get_user_data (const hb_subset_plan_t *plan,
207 hb_user_data_key_t *key);
208
209
Rod Sheeter9ccb8362018-01-17 22:09:07 -0800210HB_END_DECLS
211
212#endif /* HB_SUBSET_H */