mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-05 21:45:06 +00:00
[instancer] always check and update default wght/width/slnt if necessary
Sometimes default values in original file are incorrect, and if default value for an axis is not changed, then these values won't be updated
This commit is contained in:
parent
7b5daff5eb
commit
6e49128afd
6 changed files with 31 additions and 20 deletions
|
@ -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<unsigned> (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<unsigned> (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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Binary file not shown.
Binary file not shown.
12
test/subset/data/tests/update_def_wght.tests
Normal file
12
test/subset/data/tests/update_def_wght.tests
Normal file
|
@ -0,0 +1,12 @@
|
|||
FONTS:
|
||||
SourceSerifVariable-Roman.ttf
|
||||
|
||||
PROFILES:
|
||||
no-tables-with-item-variations.txt
|
||||
|
||||
SUBSETS:
|
||||
*
|
||||
|
||||
INSTANCES:
|
||||
wght=300:600
|
||||
wght=500:800
|
|
@ -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 = [
|
||||
|
|
Loading…
Add table
Reference in a new issue