diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh index 72cb66247..19330b9bd 100644 --- a/src/hb-ot-os2-table.hh +++ b/src/hb-ot-os2-table.hh @@ -246,24 +246,19 @@ struct OS2 } #endif - if (c->plan->user_axes_location.has (HB_TAG ('w','g','h','t')) && - !c->plan->pinned_at_default) + Triple *axis_range; + if (c->plan->user_axes_location.has (HB_TAG ('w','g','h','t'), &axis_range)) { - float weight_class = c->plan->user_axes_location.get (HB_TAG ('w','g','h','t')).middle; - if (!c->serializer->check_assign (os2_prime->usWeightClass, - roundf (hb_clamp (weight_class, 1.0f, 1000.0f)), - HB_SERIALIZE_ERROR_INT_OVERFLOW)) - return_trace (false); + unsigned weight_class = static_cast (roundf (hb_clamp (axis_range->middle, 1.0f, 1000.0f))); + if (os2_prime->usWeightClass != weight_class) + os2_prime->usWeightClass = weight_class; } - if (c->plan->user_axes_location.has (HB_TAG ('w','d','t','h')) && - !c->plan->pinned_at_default) + if (c->plan->user_axes_location.has (HB_TAG ('w','d','t','h'), &axis_range)) { - float width = c->plan->user_axes_location.get (HB_TAG ('w','d','t','h')).middle; - if (!c->serializer->check_assign (os2_prime->usWidthClass, - roundf (map_wdth_to_widthclass (width)), - HB_SERIALIZE_ERROR_INT_OVERFLOW)) - return_trace (false); + unsigned width_class = static_cast (roundf (map_wdth_to_widthclass (axis_range->middle))); + if (os2_prime->usWidthClass != width_class) + os2_prime->usWidthClass = width_class; } if (c->plan->flags & HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES) diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 761e49d11..aaecc348e 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -113,12 +113,12 @@ struct post } #endif - if (c->plan->user_axes_location.has (HB_TAG ('s','l','n','t')) && - !c->plan->pinned_at_default) + Triple *axis_range; + if (c->plan->user_axes_location.has (HB_TAG ('s','l','n','t'), &axis_range)) { - float italic_angle = c->plan->user_axes_location.get (HB_TAG ('s','l','n','t')).middle; - italic_angle = hb_max (-90.f, hb_min (italic_angle, 90.f)); - post_prime->italicAngle.set_float (italic_angle); + float italic_angle = hb_max (-90.f, hb_min (axis_range->middle, 90.f)); + if (post_prime->italicAngle.to_float () != italic_angle) + post_prime->italicAngle.set_float (italic_angle); } if (glyph_names && version.major == 2) diff --git a/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.no-tables-with-item-variations.retain-all-codepoint.wght=300-600.ttf b/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.no-tables-with-item-variations.retain-all-codepoint.wght=300-600.ttf new file mode 100644 index 000000000..5f6b2a0b4 Binary files /dev/null and b/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.no-tables-with-item-variations.retain-all-codepoint.wght=300-600.ttf differ diff --git a/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.no-tables-with-item-variations.retain-all-codepoint.wght=500-800.ttf b/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.no-tables-with-item-variations.retain-all-codepoint.wght=500-800.ttf new file mode 100644 index 000000000..edd451312 Binary files /dev/null and b/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.no-tables-with-item-variations.retain-all-codepoint.wght=500-800.ttf differ diff --git a/test/subset/data/tests/update_def_wght.tests b/test/subset/data/tests/update_def_wght.tests new file mode 100644 index 000000000..9ff5fce48 --- /dev/null +++ b/test/subset/data/tests/update_def_wght.tests @@ -0,0 +1,12 @@ +FONTS: +SourceSerifVariable-Roman.ttf + +PROFILES: +no-tables-with-item-variations.txt + +SUBSETS: +* + +INSTANCES: +wght=300:600 +wght=500:800 diff --git a/test/subset/meson.build b/test/subset/meson.build index 4b6db4120..9c994236b 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -68,7 +68,11 @@ tests = [ ] if get_option('experimental_api') - tests += ['glyf_partial_instancing', 'mvar_partial_instance'] + tests += [ + 'glyf_partial_instancing', + 'mvar_partial_instance', + 'update_def_wght', + ] endif repack_tests = [