diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index bd0de9a63..7082a55e5 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -889,6 +889,8 @@ hb_subset_input_old_to_new_glyph_mapping hb_subset_input_pin_all_axes_to_default hb_subset_input_pin_axis_location hb_subset_input_pin_axis_to_default +hb_subset_input_get_axis_range +hb_subset_input_set_axis_range hb_subset_or_fail hb_subset_plan_create_or_fail hb_subset_plan_reference @@ -909,8 +911,6 @@ hb_link_t hb_object_t hb_subset_repack_or_fail hb_subset_input_override_name_table -hb_subset_input_set_axis_range -hb_subset_input_get_axis_range
diff --git a/perf/benchmark-subset.cc b/perf/benchmark-subset.cc index 7236f3e5f..13e282dc3 100644 --- a/perf/benchmark-subset.cc +++ b/perf/benchmark-subset.cc @@ -195,9 +195,7 @@ static void BM_subset (benchmark::State &state, AddCodepoints(all_codepoints, subset_size, input); hb_set_destroy (all_codepoints); -#ifdef HB_EXPERIMENTAL_API hb_subset_input_set_flags(input, hb_subset_input_get_flags(input) | HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS); -#endif for (unsigned i = 0; i < test_input.num_instance_opts; i++) hb_subset_input_pin_axis_location (input, face, diff --git a/src/gen-def.py b/src/gen-def.py index f199d7f31..6011817bc 100755 --- a/src/gen-def.py +++ b/src/gen-def.py @@ -22,8 +22,6 @@ if '--experimental-api' not in sys.argv: """hb_shape_justify hb_subset_repack_or_fail hb_subset_input_override_name_table -hb_subset_input_set_axis_range -hb_subset_input_get_axis_range """.splitlines () symbols = [x for x in symbols if x not in experimental_symbols] symbols = "\n".join (symbols) diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 259f81153..caa3ec5d2 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -1031,7 +1031,7 @@ struct tuple_delta_t bool optimize (const contour_point_vector_t& contour_points, bool is_composite, - float tolerance = 0.5f) + double tolerance = 0.5) { unsigned count = contour_points.length; if (deltas_x.length != count || diff --git a/src/hb-ot-var-gvar-table.hh b/src/hb-ot-var-gvar-table.hh index 59aad57e3..d713084fa 100644 --- a/src/hb-ot-var-gvar-table.hh +++ b/src/hb-ot-var-gvar-table.hh @@ -102,9 +102,8 @@ struct glyph_variations_t } bool is_composite_glyph = false; -#ifdef HB_EXPERIMENTAL_API is_composite_glyph = plan->composite_new_gids.has (new_gid); -#endif + if (!p->decompile_tuple_variations (all_contour_points->length, true /* is_gvar */, iterator, &(plan->axes_old_index_tag_map), shared_indices, shared_tuples, @@ -120,9 +119,7 @@ struct glyph_variations_t { unsigned count = plan->new_to_old_gid_list.length; bool iup_optimize = false; -#ifdef HB_EXPERIMENTAL_API iup_optimize = plan->flags & HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS; -#endif for (unsigned i = 0; i < count; i++) { hb_codepoint_t new_gid = plan->new_to_old_gid_list[i].first; diff --git a/src/hb-subset-input.cc b/src/hb-subset-input.cc index 68a3e7778..89753cdd1 100644 --- a/src/hb-subset-input.cc +++ b/src/hb-subset-input.cc @@ -515,7 +515,6 @@ hb_subset_input_pin_axis_location (hb_subset_input_t *input, return input->axes_location.set (axis_tag, Triple (val, val, val)); } -#ifdef HB_EXPERIMENTAL_API /** * hb_subset_input_set_axis_range: (skip) * @input: a #hb_subset_input_t object. @@ -538,7 +537,7 @@ hb_subset_input_pin_axis_location (hb_subset_input_t *input, * * Return value: `true` if success, `false` otherwise * - * XSince: EXPERIMENTAL + * XSince: REPLACEME **/ HB_EXTERN hb_bool_t hb_subset_input_set_axis_range (hb_subset_input_t *input, @@ -577,7 +576,7 @@ hb_subset_input_set_axis_range (hb_subset_input_t *input, * * Return value: `true` if a range has been set for this axis tag, `false` otherwise. * - * XSince: EXPERIMENTAL + * XSince: REPLACEME **/ HB_EXTERN hb_bool_t hb_subset_input_get_axis_range (hb_subset_input_t *input, @@ -598,7 +597,6 @@ hb_subset_input_get_axis_range (hb_subset_input_t *input, return true; } #endif -#endif /** * hb_subset_preprocess: @@ -746,5 +744,4 @@ hb_subset_input_override_name_table (hb_subset_input_t *input, input->name_table_overrides.set (hb_ot_name_record_ids_t (platform_id, encoding_id, language_id, name_id), name_bytes); return true; } - #endif diff --git a/src/hb-subset-instancer-iup.cc b/src/hb-subset-instancer-iup.cc index 35a964d08..aa0cd89fd 100644 --- a/src/hb-subset-instancer-iup.cc +++ b/src/hb-subset-instancer-iup.cc @@ -38,7 +38,7 @@ static void _iup_contour_bound_forced_set (const hb_array_t x_deltas, const hb_array_t y_deltas, hb_set_t& forced_set, /* OUT */ - float tolerance = 0.f) + double tolerance = 0.0) { unsigned len = contour_points.length; unsigned next_i = 0; @@ -47,7 +47,7 @@ static void _iup_contour_bound_forced_set (const hb_array_t contour_points const contour_point_t& p1, const contour_point_t& p2, int p1_dx, int p2_dx, int p1_dy, int p2_dy, - hb_vector_t& interp_x_deltas, /* OUT */ - hb_vector_t& interp_y_deltas /* OUT */) + hb_vector_t& interp_x_deltas, /* OUT */ + hb_vector_t& interp_y_deltas /* OUT */) { unsigned n = contour_points.length; if (unlikely (!interp_x_deltas.resize (n, false) || @@ -190,8 +190,8 @@ static bool _iup_segment (const hb_array_t contour_points for (unsigned j = 0; j < 2; j++) { - float x1, x2, d1, d2; - float *out; + double x1, x2, d1, d2; + double *out; if (j == 0) { x1 = p1.x; @@ -219,7 +219,7 @@ static bool _iup_segment (const hb_array_t contour_points else { for (unsigned i = 0; i < n; i++) - out[i] = 0.f; + out[i] = 0.0; } continue; } @@ -230,11 +230,11 @@ static bool _iup_segment (const hb_array_t contour_points hb_swap (d1, d2); } - float scale = (d2 - d1) / (x2 - x1); + double scale = (d2 - d1) / (x2 - x1); for (unsigned i = 0; i < n; i++) { - float x = j == 0 ? contour_points.arrayZ[i].x : contour_points.arrayZ[i].y; - float d; + double x = (j == 0 ? contour_points.arrayZ[i].x : contour_points.arrayZ[i].y); + double d; if (x <= x1) d = d1; else if (x >= x2) @@ -254,9 +254,9 @@ static bool _can_iup_in_between (const hb_array_t contour const contour_point_t& p1, const contour_point_t& p2, int p1_dx, int p2_dx, int p1_dy, int p2_dy, - float tolerance) + double tolerance) { - hb_vector_t interp_x_deltas, interp_y_deltas; + hb_vector_t interp_x_deltas, interp_y_deltas; if (!_iup_segment (contour_points, x_deltas, y_deltas, p1, p2, p1_dx, p2_dx, p1_dy, p2_dy, interp_x_deltas, interp_y_deltas)) @@ -266,10 +266,10 @@ static bool _can_iup_in_between (const hb_array_t contour for (unsigned i = 0; i < num; i++) { - float dx = x_deltas.arrayZ[i] - interp_x_deltas.arrayZ[i]; - float dy = y_deltas.arrayZ[i] - interp_y_deltas.arrayZ[i]; + double dx = x_deltas.arrayZ[i] - interp_x_deltas.arrayZ[i]; + double dy = y_deltas.arrayZ[i] - interp_y_deltas.arrayZ[i]; - if (sqrtf ((float)dx * dx + (float)dy * dy) > tolerance) + if (sqrt ((double)dx * dx + (double)dy * dy) > tolerance) return false; } return true; @@ -279,7 +279,7 @@ static bool _iup_contour_optimize_dp (const contour_point_vector_t& contour_poin const hb_vector_t& x_deltas, const hb_vector_t& y_deltas, const hb_set_t& forced_set, - float tolerance, + double tolerance, unsigned lookback, hb_vector_t& costs, /* OUT */ hb_vector_t& chain /* OUT */) @@ -333,7 +333,7 @@ static bool _iup_contour_optimize (const hb_array_t conto const hb_array_t x_deltas, const hb_array_t y_deltas, hb_array_t opt_indices, /* OUT */ - float tolerance = 0.f) + double tolerance = 0.0) { unsigned n = contour_points.length; if (opt_indices.length != n || @@ -346,7 +346,7 @@ static bool _iup_contour_optimize (const hb_array_t conto { int dx = x_deltas.arrayZ[i]; int dy = y_deltas.arrayZ[i]; - if (sqrtf ((float)dx * dx + (float)dy * dy) > tolerance) + if (sqrt ((double) dx * dx + (double) dy * dy) > tolerance) { all_within_tolerance = false; break; @@ -443,11 +443,11 @@ static bool _iup_contour_optimize (const hb_array_t conto unsigned contour_point_size = hb_static_size (contour_point_t); for (unsigned i = 0; i < n; i++) { - hb_memcpy ((void *) repeat_x_deltas.arrayZ, (const void *) x_deltas.arrayZ, n * sizeof (float)); - hb_memcpy ((void *) (repeat_x_deltas.arrayZ + n), (const void *) x_deltas.arrayZ, n * sizeof (float)); + hb_memcpy ((void *) repeat_x_deltas.arrayZ, (const void *) x_deltas.arrayZ, n * sizeof (repeat_x_deltas[0])); + hb_memcpy ((void *) (repeat_x_deltas.arrayZ + n), (const void *) x_deltas.arrayZ, n * sizeof (repeat_x_deltas[0])); - hb_memcpy ((void *) repeat_y_deltas.arrayZ, (const void *) y_deltas.arrayZ, n * sizeof (float)); - hb_memcpy ((void *) (repeat_y_deltas.arrayZ + n), (const void *) y_deltas.arrayZ, n * sizeof (float)); + hb_memcpy ((void *) repeat_y_deltas.arrayZ, (const void *) y_deltas.arrayZ, n * sizeof (repeat_x_deltas[0])); + hb_memcpy ((void *) (repeat_y_deltas.arrayZ + n), (const void *) y_deltas.arrayZ, n * sizeof (repeat_x_deltas[0])); hb_memcpy ((void *) repeat_points.arrayZ, (const void *) contour_points.arrayZ, n * contour_point_size); hb_memcpy ((void *) (repeat_points.arrayZ + n), (const void *) contour_points.arrayZ, n * contour_point_size); @@ -496,7 +496,7 @@ bool iup_delta_optimize (const contour_point_vector_t& contour_points, const hb_vector_t& x_deltas, const hb_vector_t& y_deltas, hb_vector_t& opt_indices, /* OUT */ - float tolerance) + double tolerance) { if (!opt_indices.resize (contour_points.length)) return false; diff --git a/src/hb-subset-instancer-iup.hh b/src/hb-subset-instancer-iup.hh index 7eac5935a..01987bd25 100644 --- a/src/hb-subset-instancer-iup.hh +++ b/src/hb-subset-instancer-iup.hh @@ -32,6 +32,6 @@ HB_INTERNAL bool iup_delta_optimize (const contour_point_vector_t& contour_point const hb_vector_t& x_deltas, const hb_vector_t& y_deltas, hb_vector_t& opt_indices, /* OUT */ - float tolerance = 0.f); + double tolerance = 0.0); #endif /* HB_SUBSET_INSTANCER_IUP_HH */ diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 1d032ec4d..a84062025 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -1171,11 +1171,9 @@ _get_instance_glyphs_contour_points (hb_subset_plan_t *plan) if (unlikely (!plan->new_gid_contour_points_map.set (new_gid, all_points))) return false; -#ifdef HB_EXPERIMENTAL_API /* composite new gids are only needed by iup delta optimization */ if ((plan->flags & HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS) && glyph.is_composite ()) plan->composite_new_gids.add (new_gid); -#endif } return true; } diff --git a/src/hb-subset.h b/src/hb-subset.h index 73dcae466..856521bae 100644 --- a/src/hb-subset.h +++ b/src/hb-subset.h @@ -73,11 +73,11 @@ typedef struct hb_subset_plan_t hb_subset_plan_t; * OS/2 will not be recalculated. * @HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE: If set don't perform glyph closure on layout * substitution rules (GSUB). Since: 7.2.0. + * @HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS: If set perform IUP delta optimization on the + * remaining gvar table's deltas. XSince: REPLACEME * @HB_SUBSET_FLAGS_IFTB_REQUIREMENTS: 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 - * @HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS: If set perform IUP delta optimization on the - * remaining gvar table's deltas. Since: EXPERIMENTAL * * List of boolean properties that can be configured on the subset input. * @@ -95,9 +95,9 @@ typedef enum { /*< flags >*/ HB_SUBSET_FLAGS_GLYPH_NAMES = 0x00000080u, HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES = 0x00000100u, HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE = 0x00000200u, + HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS = 0x00000400u, #ifdef HB_EXPERIMENTAL_API - HB_SUBSET_FLAGS_IFTB_REQUIREMENTS = 0x00000400u, - HB_SUBSET_FLAGS_OPTIMIZE_IUP_DELTAS = 0x00000800u, + HB_SUBSET_FLAGS_IFTB_REQUIREMENTS = 0x00000800u, #endif } hb_subset_flags_t; @@ -188,7 +188,6 @@ hb_subset_input_pin_axis_location (hb_subset_input_t *input, hb_tag_t axis_tag, float axis_value); -#ifdef HB_EXPERIMENTAL_API HB_EXTERN hb_bool_t hb_subset_input_get_axis_range (hb_subset_input_t *input, hb_tag_t axis_tag, @@ -204,6 +203,7 @@ hb_subset_input_set_axis_range (hb_subset_input_t *input, float axis_max_value, float axis_def_value); +#ifdef HB_EXPERIMENTAL_API HB_EXTERN hb_bool_t hb_subset_input_override_name_table (hb_subset_input_t *input, hb_ot_name_id_t name_id, @@ -212,7 +212,6 @@ hb_subset_input_override_name_table (hb_subset_input_t *input, unsigned language_id, const char *name_str, int str_len); - #endif HB_EXTERN hb_face_t * diff --git a/test/subset/meson.build b/test/subset/meson.build index 7cfa06c8d..b197da23b 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -68,21 +68,28 @@ tests = [ 'instantiate_colrv1', 'instantiate_cff2_update_metrics', 'layout.empty_ligature_offset', + 'glyf_partial_instancing', + 'mvar_partial_instance', + 'update_def_wght', + 'feature_variations_partial_instance', + 'gdef_partial_instance', + 'value_format_partial_instance', + 'feature_variation_instance_collect_lookups', + 'sync_vmetrics', ] +if host_machine.cpu_family() != 'x86' + # These tests exhibit some inconsequential rounding differences on 32bit machines in IUP + # optimization that causes the tests to fail, so only include them on non-32bit. + tests += [ + 'empty_region_vardata', + ] +endif + if get_option('experimental_api') tests += [ - 'glyf_partial_instancing', - 'mvar_partial_instance', - 'update_def_wght', - 'empty_region_vardata', - 'feature_variations_partial_instance', - 'gdef_partial_instance', - 'value_format_partial_instance', - 'feature_variation_instance_collect_lookups', 'iftb_requirements', - 'sync_vmetrics', - ] + ] endif repack_tests = [ diff --git a/util/hb-subset.cc b/util/hb-subset.cc index 73d00368d..624bb1f75 100644 --- a/util/hb-subset.cc +++ b/util/hb-subset.cc @@ -926,9 +926,6 @@ subset_main_t::add_options () "(Partially|Fully) Instantiate a variable font. A location consists of the tag " "of a variation axis, followed by '=', followed by a number or the literal " "string 'drop'. For example: --variations=\"wdth=100 wght=200\" or --variations=\"wdth=drop\"" -#ifndef HB_EXPERIMENTAL_API - "\n\nNote: currently only full instancing is supported unless this util has been compiled with experimental api enabled." -#endif , "list of comma separated axis-locations." }, @@ -963,8 +960,8 @@ subset_main_t::add_options () "If set preprocesses the face with the add accelerator option before actually subsetting.", nullptr}, #ifdef HB_EXPERIMENTAL_API {"iftb-requirements", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Enforce requirements needed to use the subset with incremental font transfer IFTB patches.", nullptr}, - {"optimize", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Perform IUP delta optimization on the resulting gvar table's deltas", nullptr}, #endif + {"optimize", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) &set_flag, "Perform IUP delta optimization on the resulting gvar table's deltas", nullptr}, {nullptr} }; add_group (flag_entries, diff --git a/util/helper-subset.hh b/util/helper-subset.hh index 15acf7d28..a050d713d 100644 --- a/util/helper-subset.hh +++ b/util/helper-subset.hh @@ -198,7 +198,6 @@ parse_instancing_spec (const char *arg, continue; } -#ifdef HB_EXPERIMENTAL_API if (!hb_subset_input_set_axis_range (input, face, axis_tag, min, max, def)) @@ -208,7 +207,6 @@ parse_instancing_spec (const char *arg, return false; } continue; -#endif g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, "Partial instancing is not supported.");