Top |
enum | hb_subset_flags_t |
typedef | hb_subset_input_t |
enum | hb_subset_sets_t |
typedef | hb_subset_plan_t |
Subsetting reduces the codepoint coverage of font files and removes all data that is no longer needed. A subset input describes the desired subset. The input is provided along with a font to the subsetting operation. Output is a new font file containing only the data specified in the input.
Currently most outline and bitmap tables are supported: glyf, CFF, CFF2, sbix, COLR, and CBDT/CBLC. This also includes fonts with variable outlines via OpenType variations. Notably EBDT/EBLC and SVG are not supported. Layout subsetting is supported only for OpenType Layout tables (GSUB, GPOS, GDEF). Notably subsetting of graphite or AAT tables is not yet supported.
Fonts with graphite or AAT tables may still be subsetted but will likely need to use the retain glyph ids option and configure the subset to pass through the layout tables untouched.
hb_subset_input_t *
hb_subset_input_create_or_fail (void
);
Creates a new subset input object.
New subset input, or NULL
if failed. Destroy
with hb_subset_input_destroy()
.
[transfer full]
Since: 1.8.0
hb_subset_input_t *
hb_subset_input_reference (hb_subset_input_t *input
);
Increases the reference count on input
.
[skip]
Since: 1.8.0
void
hb_subset_input_destroy (hb_subset_input_t *input
);
Decreases the reference count on input
, and if it reaches zero, destroys
input
, freeing all memory.
Since: 1.8.0
hb_bool_t hb_subset_input_set_user_data (hb_subset_input_t *input
,hb_user_data_key_t *key
,void *data
,hb_destroy_func_t destroy
,hb_bool_t replace
);
Attaches a user-data key/data pair to the given subset input object.
[skip]
input |
a hb_subset_input_t object. |
|
key |
The user-data key to set |
|
data |
A pointer to the user data |
|
destroy |
A callback to call when |
[nullable] |
replace |
Whether to replace an existing data with the same key |
Since: 2.9.0
void * hb_subset_input_get_user_data (const hb_subset_input_t *input
,hb_user_data_key_t *key
);
Fetches the user data associated with the specified key, attached to the specified subset input object.
[skip]
Since: 2.9.0
void
hb_subset_input_keep_everything (hb_subset_input_t *input
);
Configure input object to keep everything in the font face. That is, all Unicodes, glyphs, names, layout items, glyph names, etc.
The input can be tailored afterwards by the caller.
Since: 7.0.0
void hb_subset_input_set_flags (hb_subset_input_t *input
,unsigned value
);
Sets all of the flags in the input object to the values specified by the bit field.
Since: 2.9.0
hb_subset_flags_t
hb_subset_input_get_flags (hb_subset_input_t *input
);
Gets all of the subsetting flags in the input object.
Since: 2.9.0
hb_set_t *
hb_subset_input_unicode_set (hb_subset_input_t *input
);
Gets the set of Unicode code points to retain, the caller should modify the set as needed.
Since: 1.8.0
hb_set_t *
hb_subset_input_glyph_set (hb_subset_input_t *input
);
Gets the set of glyph IDs to retain, the caller should modify the set as needed.
Since: 1.8.0
hb_set_t * hb_subset_input_set (hb_subset_input_t *input
,hb_subset_sets_t set_type
);
Gets the set of the specified type.
Since: 2.9.1
hb_map_t *
hb_subset_input_old_to_new_glyph_mapping
(hb_subset_input_t *input
);
Returns a map which can be used to provide an explicit mapping from old to new glyph id's in the produced subset. The caller should populate the map as desired. If this map is left empty then glyph ids will be automatically mapped to new values by the subsetter. If populated, the mapping must be unique. That is no two original glyph ids can be mapped to the same new id. Additionally, if a mapping is provided then the retain gids option cannot be enabled.
Any glyphs that are retained in the subset which are not specified in this mapping will be assigned glyph ids after the highest glyph id in the mapping.
Note: this will accept and apply non-monotonic mappings, however this may result in unsorted Coverage tables. Such fonts may not work for all use cases (for example ots will reject unsorted coverage tables). So it's recommended, if possible, to supply a monotonic mapping.
Since: 7.3.0
hb_bool_t hb_subset_input_pin_all_axes_to_default (hb_subset_input_t *input
,hb_face_t *face
);
Pin all axes to default locations in the given subset input object.
All axes in a font must be pinned. Additionally, CFF2
table, if present,
will be de-subroutinized.
[skip]
Since: 8.3.1
hb_bool_t hb_subset_input_pin_axis_location (hb_subset_input_t *input
,hb_face_t *face
,hb_tag_t axis_tag
,float axis_value
);
Pin an axis to a fixed location in the given subset input object.
All axes in a font must be pinned. Additionally, CFF2
table, if present,
will be de-subroutinized.
[skip]
input |
a hb_subset_input_t object. |
|
face |
a hb_face_t object. |
|
axis_tag |
Tag of the axis to be pinned |
|
axis_value |
Location on the axis to be pinned at |
Since: 6.0.0
hb_bool_t hb_subset_input_pin_axis_to_default (hb_subset_input_t *input
,hb_face_t *face
,hb_tag_t axis_tag
);
Pin an axis to its default location in the given subset input object.
All axes in a font must be pinned. Additionally, CFF2
table, if present,
will be de-subroutinized.
[skip]
input |
a hb_subset_input_t object. |
|
face |
a hb_face_t object. |
|
axis_tag |
Tag of the axis to be pinned |
Since: 6.0.0
hb_bool_t hb_subset_input_get_axis_range (hb_subset_input_t *input
,hb_tag_t axis_tag
,float *axis_min_value
,float *axis_max_value
,float *axis_def_value
);
Gets the axis range assigned by previous calls to hb_subset_input_set_axis_range.
[skip]
input |
a hb_subset_input_t object. |
|
axis_tag |
Tag of the axis |
|
axis_min_value |
Set to the previously configured minimum value of the axis variation range. |
|
axis_max_value |
Set to the previously configured maximum value of the axis variation range. |
|
axis_def_value |
Set to the previously configured default value of the axis variation range. |
Since: 8.5.0
hb_bool_t hb_subset_input_set_axis_range (hb_subset_input_t *input
,hb_face_t *face
,hb_tag_t axis_tag
,float axis_min_value
,float axis_max_value
,float axis_def_value
);
Restricting the range of variation on an axis in the given subset input object. New min/default/max values will be clamped if they're not within the fvar axis range.
If the fvar axis default value is not within the new range, the new default value will be changed to the new min or max value, whichever is closer to the fvar axis default.
Note: input min value can not be bigger than input max value. If the input default value is not within the new min/max range, it'll be clamped. Note: currently it supports gvar and cvar tables only.
[skip]
input |
a hb_subset_input_t object. |
|
face |
a hb_face_t object. |
|
axis_tag |
Tag of the axis |
|
axis_min_value |
Minimum value of the axis variation range to set, if NaN the existing min will be used. |
|
axis_max_value |
Maximum value of the axis variation range to set if NaN the existing max will be used. |
|
axis_def_value |
Default value of the axis variation range to set, if NaN the existing default will be used. |
Since: 8.5.0
hb_face_t * hb_subset_or_fail (hb_face_t *source
,const hb_subset_input_t *input
);
Subsets a font according to provided input. Returns nullptr if the subset operation fails or the face has no glyphs.
Since: 2.9.0
hb_subset_plan_t * hb_subset_plan_create_or_fail (hb_face_t *face
,const hb_subset_input_t *input
);
Computes a plan for subsetting the supplied face according to a provided input. The plan describes which tables and glyphs should be retained.
New subset plan. Destroy with
hb_subset_plan_destroy()
. If there is a failure creating the plan
nullptr will be returned.
[transfer full]
Since: 4.0.0
hb_subset_plan_t *
hb_subset_plan_reference (hb_subset_plan_t *plan
);
Increases the reference count on plan
.
[skip]
Since: 4.0.0
void
hb_subset_plan_destroy (hb_subset_plan_t *plan
);
Decreases the reference count on plan
, and if it reaches zero, destroys
plan
, freeing all memory.
Since: 4.0.0
hb_bool_t hb_subset_plan_set_user_data (hb_subset_plan_t *plan
,hb_user_data_key_t *key
,void *data
,hb_destroy_func_t destroy
,hb_bool_t replace
);
Attaches a user-data key/data pair to the given subset plan object.
[skip]
plan |
a hb_subset_plan_t object. |
|
key |
The user-data key to set |
|
data |
A pointer to the user data |
|
destroy |
A callback to call when |
[nullable] |
replace |
Whether to replace an existing data with the same key |
Since: 4.0.0
void * hb_subset_plan_get_user_data (const hb_subset_plan_t *plan
,hb_user_data_key_t *key
);
Fetches the user data associated with the specified key, attached to the specified subset plan object.
[skip]
Since: 4.0.0
hb_face_t *
hb_subset_plan_execute_or_fail (hb_subset_plan_t *plan
);
Executes the provided subsetting plan
.
on success returns a reference to generated font subset. If the subsetting operation fails returns nullptr.
Since: 4.0.0
hb_map_t *
hb_subset_plan_unicode_to_old_glyph_mapping
(const hb_subset_plan_t *plan
);
Returns the mapping between codepoints in the original font and the associated glyph id in the original font.
Since: 4.0.0
hb_map_t *
hb_subset_plan_new_to_old_glyph_mapping
(const hb_subset_plan_t *plan
);
Returns the mapping between glyphs in the subset that will be produced by
plan
and the glyph in the original font.
Since: 4.0.0
hb_map_t *
hb_subset_plan_old_to_new_glyph_mapping
(const hb_subset_plan_t *plan
);
Returns the mapping between glyphs in the original font to glyphs in the
subset that will be produced by plan
Since: 4.0.0
hb_face_t *
hb_subset_preprocess (hb_face_t *source
);
Preprocesses the face and attaches data that will be needed by the subsetter. Future subsetting operations can then use the precomputed data to speed up the subsetting operation.
See subset-preprocessing for more information.
Note: the preprocessed face may contain sub-blobs that reference the memory backing the source hb_face_t. Therefore in the case that this memory is not owned by the source face you will need to ensure that memory lives as long as the returned hb_face_t.
Since: 6.0.0
List of boolean properties that can be configured on the subset input.
all flags at their default value of false. |
||
If set hinting instructions will be dropped in the produced subset. Otherwise hinting instructions will be retained. |
||
If set glyph indices will not be modified in the produced subset. If glyphs are dropped their indices will be retained as an empty glyph. |
||
If set and subsetting a CFF font the subsetter will attempt to remove subroutines from the CFF glyphs. |
||
If set non-unicode name records will be retained in the subset. |
||
If set the subsetter will set the OVERLAP_SIMPLE flag on each simple glyph. |
||
If set the subsetter will not drop unrecognized tables and instead pass them through untouched. |
||
If set the notdef glyph outline will be retained in the final subset. |
||
If set the PS glyph names will be retained in the final subset. |
||
If set then the unicode ranges in OS/2 will not be recalculated. |
||
If set don't perform glyph closure on layout substitution rules (GSUB). Since: 7.2.0. |
||
If set perform IUP delta optimization on the remaining gvar table's deltas. Since: 8.5.0 |
||
If set enforce requirements on the output subset to allow it to be used with incremental font transfer IFTB patches. Primarily, this forces all outline data to use long (32 bit) offsets. Since: EXPERIMENTAL |
Since: 2.9.0
typedef struct hb_subset_input_t hb_subset_input_t;
Things that change based on the input. Characters to keep, etc.
List of sets that can be configured on the subset input.
the set of glyph indexes to retain in the subset. |
||
the set of unicode codepoints to retain in the subset. |
||
the set of table tags which specifies tables that should not be subsetted. |
||
the set of table tags which specifies tables which will be dropped in the subset. |
||
the set of name ids that will be retained. |
||
the set of name lang ids that will be retained. |
||
the set of layout feature tags that will be retained in the subset. |
||
the set of layout script tags that will be retained in the subset. Defaults to all tags. Since: 5.0.0 |
Since: 2.9.1