[pshinter] Fix mask merging.

We forgot to update the number of bits when merging a larger mask
into a smaller one.  This fix might have rendering effects.

* src/pshinter/pshrec.c (ps_mask_table_merge): Inherit the number
of bits from a larger mask. There is no need to zero unused bits,
already zeroed during allocation.
(ps_mask_clear_bit): Removed.
(ps_mask_ensure): Minor.
This commit is contained in:
Alexei Podtelezhnikov 2022-02-08 16:35:14 -05:00
parent 7c6b2f20b0
commit ed0e2e76d8
1 changed files with 5 additions and 21 deletions

View File

@ -131,14 +131,15 @@
FT_UInt count, FT_UInt count,
FT_Memory memory ) FT_Memory memory )
{ {
FT_UInt old_max = ( mask->max_bits + 7 ) >> 3; FT_UInt old_max = mask->max_bits >> 3;
FT_UInt new_max = ( count + 7 ) >> 3; FT_UInt new_max = ( count + 7 ) >> 3;
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
if ( new_max > old_max ) if ( new_max > old_max )
{ {
new_max = FT_PAD_CEIL( new_max, 8 ); new_max = FT_PAD_CEIL( new_max, 8 );
/* added bytes are zeroed here */
if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) ) if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) )
mask->max_bits = new_max * 8; mask->max_bits = new_max * 8;
} }
@ -158,22 +159,6 @@
} }
/* clear a given bit */
static void
ps_mask_clear_bit( PS_Mask mask,
FT_UInt idx )
{
FT_Byte* p;
if ( idx >= mask->num_bits )
return;
p = mask->bytes + ( idx >> 3 );
p[0] = (FT_Byte)( p[0] & ~( 0x80 >> ( idx & 7 ) ) );
}
/* set a given bit, possibly grow the mask */ /* set a given bit, possibly grow the mask */
static FT_Error static FT_Error
ps_mask_set_bit( PS_Mask mask, ps_mask_set_bit( PS_Mask mask,
@ -432,15 +417,14 @@
/* if "count2" is greater than "count1", we need to grow the */ /* if "count2" is greater than "count1", we need to grow the */
/* first bitset, and clear the highest bits */ /* first bitset */
if ( count2 > count1 ) if ( count2 > count1 )
{ {
error = ps_mask_ensure( mask1, count2, memory ); error = ps_mask_ensure( mask1, count2, memory );
if ( error ) if ( error )
goto Exit; goto Exit;
for ( pos = count1; pos < count2; pos++ ) mask1->num_bits = count2;
ps_mask_clear_bit( mask1, pos );
} }
/* merge (unite) the bitsets */ /* merge (unite) the bitsets */