Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-08 08:41:48

0001 /*
0002  * Copyright © 2018  Google, Inc.
0003  *
0004  *  This is part of HarfBuzz, a text shaping library.
0005  *
0006  * Permission is hereby granted, without written agreement and without
0007  * license or royalty fees, to use, copy, modify, and distribute this
0008  * software and its documentation for any purpose, provided that the
0009  * above copyright notice and the following two paragraphs appear in
0010  * all copies of this software.
0011  *
0012  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
0013  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
0014  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
0015  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
0016  * DAMAGE.
0017  *
0018  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
0019  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
0020  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
0021  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
0022  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
0023  *
0024  * Google Author(s): Rod Sheeter
0025  */
0026 
0027 #ifndef HB_SUBSET_H
0028 #define HB_SUBSET_H
0029 
0030 #include "hb.h"
0031 #include "hb-ot.h"
0032 
0033 HB_BEGIN_DECLS
0034 
0035 /**
0036  * hb_subset_input_t:
0037  *
0038  * Things that change based on the input. Characters to keep, etc.
0039  */
0040 
0041 typedef struct hb_subset_input_t hb_subset_input_t;
0042 
0043 /**
0044  * hb_subset_plan_t:
0045  *
0046  * Contains information about how the subset operation will be executed.
0047  * Such as mappings from the old glyph ids to the new ones in the subset.
0048  */
0049 
0050 typedef struct hb_subset_plan_t hb_subset_plan_t;
0051 
0052 /**
0053  * hb_subset_flags_t:
0054  * @HB_SUBSET_FLAGS_DEFAULT: all flags at their default value of false.
0055  * @HB_SUBSET_FLAGS_NO_HINTING: If set hinting instructions will be dropped in
0056  * the produced subset. Otherwise hinting instructions will be retained.
0057  * @HB_SUBSET_FLAGS_RETAIN_GIDS: If set glyph indices will not be modified in
0058  * the produced subset. If glyphs are dropped their indices will be retained
0059  * as an empty glyph.
0060  * @HB_SUBSET_FLAGS_DESUBROUTINIZE: If set and subsetting a CFF font the
0061  * subsetter will attempt to remove subroutines from the CFF glyphs.
0062  * @HB_SUBSET_FLAGS_NAME_LEGACY: If set non-unicode name records will be
0063  * retained in the subset.
0064  * @HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG:  If set the subsetter will set the
0065  * OVERLAP_SIMPLE flag on each simple glyph.
0066  * @HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED: If set the subsetter will not
0067  * drop unrecognized tables and instead pass them through untouched.
0068  * @HB_SUBSET_FLAGS_NOTDEF_OUTLINE: If set the notdef glyph outline will be
0069  * retained in the final subset.
0070  * @HB_SUBSET_FLAGS_GLYPH_NAMES: If set the PS glyph names will be retained
0071  * in the final subset.
0072  * @HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES: If set then the unicode ranges in
0073  * OS/2 will not be recalculated.
0074  * @HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE: If set do not perform glyph closure on layout
0075  * substitution rules (GSUB). Since: 7.2.0.
0076  * @HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS: If set perform IUP delta optimization on the
0077  * remaining gvar table's deltas. Since: 8.5.0
0078  * @HB_SUBSET_FLAGS_NO_BIDI_CLOSURE: If set do not pull mirrored versions of input
0079  * codepoints into the subset. Since: 11.1.0
0080  * @HB_SUBSET_FLAGS_IFTB_REQUIREMENTS: If set enforce requirements on the output subset
0081  * to allow it to be used with incremental font transfer IFTB patches. Primarily,
0082  * this forces all outline data to use long (32 bit) offsets. Since: EXPERIMENTAL
0083  * @HB_SUBSET_FLAGS_RETAIN_NUM_GLYPHS: If this flag is set along side
0084  * HB_SUBSET_FLAGS_RETAIN_GIDS then the number of glyphs in the font won't
0085  * be reduced as a result of subsetting. If necessary empty glyphs will be
0086  * included at the end of the font to keep the number of glyphs unchanged.
0087  *
0088  * List of boolean properties that can be configured on the subset input.
0089  *
0090  * Since: 2.9.0
0091  **/
0092 typedef enum { /*< flags >*/
0093   HB_SUBSET_FLAGS_DEFAULT =          0x00000000u,
0094   HB_SUBSET_FLAGS_NO_HINTING =           0x00000001u,
0095   HB_SUBSET_FLAGS_RETAIN_GIDS =          0x00000002u,
0096   HB_SUBSET_FLAGS_DESUBROUTINIZE =       0x00000004u,
0097   HB_SUBSET_FLAGS_NAME_LEGACY =          0x00000008u,
0098   HB_SUBSET_FLAGS_SET_OVERLAPS_FLAG =        0x00000010u,
0099   HB_SUBSET_FLAGS_PASSTHROUGH_UNRECOGNIZED = 0x00000020u,
0100   HB_SUBSET_FLAGS_NOTDEF_OUTLINE =       0x00000040u,
0101   HB_SUBSET_FLAGS_GLYPH_NAMES =          0x00000080u,
0102   HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES =  0x00000100u,
0103   HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE =        0x00000200u,
0104   HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS     =  0x00000400u,
0105   HB_SUBSET_FLAGS_NO_BIDI_CLOSURE         =  0x00000800u,
0106 #ifdef HB_EXPERIMENTAL_API
0107   HB_SUBSET_FLAGS_IFTB_REQUIREMENTS       =  0x00001000u,
0108   HB_SUBSET_FLAGS_RETAIN_NUM_GLYPHS  =  0x00002000u,
0109 #endif
0110 } hb_subset_flags_t;
0111 
0112 /**
0113  * hb_subset_sets_t:
0114  * @HB_SUBSET_SETS_GLYPH_INDEX: the set of glyph indexes to retain in the subset.
0115  * @HB_SUBSET_SETS_UNICODE: the set of unicode codepoints to retain in the subset.
0116  * @HB_SUBSET_SETS_NO_SUBSET_TABLE_TAG: the set of table tags which specifies tables that should not be
0117  * subsetted.
0118  * @HB_SUBSET_SETS_DROP_TABLE_TAG: the set of table tags which specifies tables which will be dropped
0119  * in the subset.
0120  * @HB_SUBSET_SETS_NAME_ID: the set of name ids that will be retained.
0121  * @HB_SUBSET_SETS_NAME_LANG_ID: the set of name lang ids that will be retained.
0122  * @HB_SUBSET_SETS_LAYOUT_FEATURE_TAG: the set of layout feature tags that will be retained
0123  * in the subset.
0124  * @HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG: the set of layout script tags that will be retained
0125  * in the subset. Defaults to all tags. Since: 5.0.0
0126  *
0127  * List of sets that can be configured on the subset input.
0128  *
0129  * Since: 2.9.1
0130  **/
0131 typedef enum {
0132   HB_SUBSET_SETS_GLYPH_INDEX = 0,
0133   HB_SUBSET_SETS_UNICODE,
0134   HB_SUBSET_SETS_NO_SUBSET_TABLE_TAG,
0135   HB_SUBSET_SETS_DROP_TABLE_TAG,
0136   HB_SUBSET_SETS_NAME_ID,
0137   HB_SUBSET_SETS_NAME_LANG_ID,
0138   HB_SUBSET_SETS_LAYOUT_FEATURE_TAG,
0139   HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG,
0140 } hb_subset_sets_t;
0141 
0142 HB_EXTERN hb_subset_input_t *
0143 hb_subset_input_create_or_fail (void);
0144 
0145 HB_EXTERN hb_subset_input_t *
0146 hb_subset_input_reference (hb_subset_input_t *input);
0147 
0148 HB_EXTERN void
0149 hb_subset_input_destroy (hb_subset_input_t *input);
0150 
0151 HB_EXTERN hb_bool_t
0152 hb_subset_input_set_user_data (hb_subset_input_t  *input,
0153                    hb_user_data_key_t *key,
0154                    void *          data,
0155                    hb_destroy_func_t   destroy,
0156                    hb_bool_t       replace);
0157 
0158 HB_EXTERN void *
0159 hb_subset_input_get_user_data (const hb_subset_input_t *input,
0160                    hb_user_data_key_t      *key);
0161 
0162 HB_EXTERN void
0163 hb_subset_input_keep_everything (hb_subset_input_t *input);
0164 
0165 HB_EXTERN hb_set_t *
0166 hb_subset_input_unicode_set (hb_subset_input_t *input);
0167 
0168 HB_EXTERN hb_set_t *
0169 hb_subset_input_glyph_set (hb_subset_input_t *input);
0170 
0171 HB_EXTERN hb_set_t *
0172 hb_subset_input_set (hb_subset_input_t *input, hb_subset_sets_t set_type);
0173 
0174 HB_EXTERN hb_map_t*
0175 hb_subset_input_old_to_new_glyph_mapping (hb_subset_input_t *input);
0176 
0177 HB_EXTERN hb_subset_flags_t
0178 hb_subset_input_get_flags (hb_subset_input_t *input);
0179 
0180 HB_EXTERN void
0181 hb_subset_input_set_flags (hb_subset_input_t *input,
0182                unsigned value);
0183 
0184 HB_EXTERN hb_bool_t
0185 hb_subset_input_pin_all_axes_to_default (hb_subset_input_t  *input,
0186                      hb_face_t          *face);
0187 
0188 HB_EXTERN hb_bool_t
0189 hb_subset_input_pin_axis_to_default (hb_subset_input_t  *input,
0190                      hb_face_t          *face,
0191                      hb_tag_t            axis_tag);
0192 
0193 HB_EXTERN hb_bool_t
0194 hb_subset_input_pin_axis_location (hb_subset_input_t  *input,
0195                    hb_face_t          *face,
0196                    hb_tag_t            axis_tag,
0197                    float               axis_value);
0198 
0199 HB_EXTERN hb_bool_t
0200 hb_subset_input_get_axis_range (hb_subset_input_t  *input,
0201                 hb_tag_t            axis_tag,
0202                 float              *axis_min_value,
0203                 float              *axis_max_value,
0204                 float              *axis_def_value);
0205 
0206 HB_EXTERN hb_bool_t
0207 hb_subset_input_set_axis_range (hb_subset_input_t  *input,
0208                 hb_face_t          *face,
0209                 hb_tag_t            axis_tag,
0210                 float               axis_min_value,
0211                 float               axis_max_value,
0212                 float               axis_def_value);
0213 
0214 HB_EXTERN hb_bool_t
0215 hb_subset_axis_range_from_string (const char *str, int len,
0216                   float *axis_min_value,
0217                   float *axis_max_value,
0218                   float *axis_def_value);
0219 
0220 HB_EXTERN void
0221 hb_subset_axis_range_to_string (hb_subset_input_t *input,
0222                 hb_tag_t axis_tag,
0223                 char *buf,
0224                 unsigned size);
0225 
0226 #ifdef HB_EXPERIMENTAL_API
0227 HB_EXTERN hb_bool_t
0228 hb_subset_input_override_name_table (hb_subset_input_t  *input,
0229                      hb_ot_name_id_t     name_id,
0230                      unsigned            platform_id,
0231                      unsigned            encoding_id,
0232                      unsigned            language_id,
0233                      const char         *name_str,
0234                      int                 str_len);
0235 
0236 
0237 /*
0238 * Raw outline data access
0239 */
0240 
0241 HB_EXTERN hb_blob_t*
0242 hb_subset_cff_get_charstring_data (hb_face_t* face, hb_codepoint_t glyph_index);
0243 
0244 HB_EXTERN hb_blob_t*
0245 hb_subset_cff_get_charstrings_index (hb_face_t* face);
0246 
0247 HB_EXTERN hb_blob_t*
0248 hb_subset_cff2_get_charstring_data (hb_face_t* face, hb_codepoint_t glyph_index);
0249 
0250 HB_EXTERN hb_blob_t*
0251 hb_subset_cff2_get_charstrings_index (hb_face_t* face);
0252 #endif
0253 
0254 HB_EXTERN hb_face_t *
0255 hb_subset_preprocess (hb_face_t *source);
0256 
0257 HB_EXTERN hb_face_t *
0258 hb_subset_or_fail (hb_face_t *source, const hb_subset_input_t *input);
0259 
0260 HB_EXTERN hb_face_t *
0261 hb_subset_plan_execute_or_fail (hb_subset_plan_t *plan);
0262 
0263 HB_EXTERN hb_subset_plan_t *
0264 hb_subset_plan_create_or_fail (hb_face_t                 *face,
0265                                const hb_subset_input_t   *input);
0266 
0267 HB_EXTERN void
0268 hb_subset_plan_destroy (hb_subset_plan_t *plan);
0269 
0270 HB_EXTERN hb_map_t *
0271 hb_subset_plan_old_to_new_glyph_mapping (const hb_subset_plan_t *plan);
0272 
0273 HB_EXTERN hb_map_t *
0274 hb_subset_plan_new_to_old_glyph_mapping (const hb_subset_plan_t *plan);
0275 
0276 HB_EXTERN hb_map_t *
0277 hb_subset_plan_unicode_to_old_glyph_mapping (const hb_subset_plan_t *plan);
0278 
0279 
0280 HB_EXTERN hb_subset_plan_t *
0281 hb_subset_plan_reference (hb_subset_plan_t *plan);
0282 
0283 HB_EXTERN hb_bool_t
0284 hb_subset_plan_set_user_data (hb_subset_plan_t   *plan,
0285                               hb_user_data_key_t *key,
0286                               void               *data,
0287                               hb_destroy_func_t   destroy,
0288                               hb_bool_t           replace);
0289 
0290 HB_EXTERN void *
0291 hb_subset_plan_get_user_data (const hb_subset_plan_t *plan,
0292                               hb_user_data_key_t     *key);
0293 
0294 
0295 HB_END_DECLS
0296 
0297 #endif /* HB_SUBSET_H */