[truetype] Refactor compensation color.

* src/truetype/ttinterp.h (TT_Round_Func): Change the last argument.
* src/truetype/ttinterp.c (Ins_ROUND, Ins_NROUND, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Move compensation retrieval from here...
(Round_*): ... to here.
* src/truetype/ttobjs.c (tt_size_init_bytecode): Reserve zero
compensation at color index 3.
This commit is contained in:
Alexei Podtelezhnikov 2020-09-01 21:49:52 -04:00
parent 16ee2a22ab
commit e6c7e4b42b
4 changed files with 62 additions and 88 deletions

View File

@ -1,4 +1,15 @@
2020-08-25 Alexei Podtelezhnikov <apodtele@gmail.com>
2020-09-01 Alexei Podtelezhnikov <apodtele@gmail.com>
[truetype] Refactor compensation color.
* src/truetype/ttinterp.h (TT_Round_Func): Change the last argument.
* src/truetype/ttinterp.c (Ins_ROUND, Ins_NROUND, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Move compensation retrieval from here...
(Round_*): ... to here.
* src/truetype/ttobjs.c (tt_size_init_bytecode): Reserve zero
compensation at color index 3.
2020-08-28 Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth] Don't set target in direct mode.

View File

@ -1955,8 +1955,8 @@
* distance ::
* The distance (not) to round.
*
* compensation ::
* The engine compensation.
* color ::
* The engine compensation color.
*
* @Return:
* The compensated distance.
@ -1964,12 +1964,11 @@
static FT_F26Dot6
Round_None( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
FT_Int color )
{
FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
FT_UNUSED( exc );
if ( distance >= 0 )
{
@ -1999,8 +1998,8 @@
* distance ::
* The distance to round.
*
* compensation ::
* The engine compensation.
* color ::
* The engine compensation color.
*
* @Return:
* Rounded distance.
@ -2008,12 +2007,11 @@
static FT_F26Dot6
Round_To_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
FT_Int color )
{
FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
FT_UNUSED( exc );
if ( distance >= 0 )
{
@ -2045,8 +2043,8 @@
* distance ::
* The distance to round.
*
* compensation ::
* The engine compensation.
* color ::
* The engine compensation color.
*
* @Return:
* Rounded distance.
@ -2054,12 +2052,11 @@
static FT_F26Dot6
Round_To_Half_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
FT_Int color )
{
FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
FT_UNUSED( exc );
if ( distance >= 0 )
{
@ -2093,8 +2090,8 @@
* distance ::
* The distance to round.
*
* compensation ::
* The engine compensation.
* color ::
* The engine compensation color.
*
* @Return:
* Rounded distance.
@ -2102,12 +2099,11 @@
static FT_F26Dot6
Round_Down_To_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
FT_Int color )
{
FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
FT_UNUSED( exc );
if ( distance >= 0 )
{
@ -2138,8 +2134,8 @@
* distance ::
* The distance to round.
*
* compensation ::
* The engine compensation.
* color ::
* The engine compensation color.
*
* @Return:
* Rounded distance.
@ -2147,12 +2143,11 @@
static FT_F26Dot6
Round_Up_To_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
FT_Int color )
{
FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
FT_UNUSED( exc );
if ( distance >= 0 )
{
@ -2184,8 +2179,8 @@
* distance ::
* The distance to round.
*
* compensation ::
* The engine compensation.
* color ::
* The engine compensation color.
*
* @Return:
* Rounded distance.
@ -2193,12 +2188,11 @@
static FT_F26Dot6
Round_To_Double_Grid( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
FT_Int color )
{
FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
FT_UNUSED( exc );
if ( distance >= 0 )
{
@ -2230,8 +2224,8 @@
* distance ::
* The distance to round.
*
* compensation ::
* The engine compensation.
* color ::
* The engine compensation color.
*
* @Return:
* Rounded distance.
@ -2245,8 +2239,9 @@
static FT_F26Dot6
Round_Super( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
FT_Int color )
{
FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
@ -2285,8 +2280,8 @@
* distance ::
* The distance to round.
*
* compensation ::
* The engine compensation.
* color ::
* The engine compensation color.
*
* @Return:
* Rounded distance.
@ -2298,8 +2293,9 @@
static FT_F26Dot6
Round_Super_45( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation )
FT_Int color )
{
FT_F26Dot6 compensation = exc->tt_metrics.compensations[color];
FT_F26Dot6 val;
@ -2898,7 +2894,7 @@
Ins_ODD( TT_ExecContext exc,
FT_Long* args )
{
args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 64 );
args[0] = ( ( exc->func_round( exc, args[0], 3 ) & 127 ) == 64 );
}
@ -2912,7 +2908,7 @@
Ins_EVEN( TT_ExecContext exc,
FT_Long* args )
{
args[0] = ( ( exc->func_round( exc, args[0], 0 ) & 127 ) == 0 );
args[0] = ( ( exc->func_round( exc, args[0], 3 ) & 127 ) == 0 );
}
@ -3242,10 +3238,7 @@
Ins_ROUND( TT_ExecContext exc,
FT_Long* args )
{
args[0] = exc->func_round(
exc,
args[0],
exc->tt_metrics.compensations[exc->opcode - 0x68] );
args[0] = exc->func_round( exc, args[0], exc->opcode & 3 );
}
@ -3259,10 +3252,7 @@
Ins_NROUND( TT_ExecContext exc,
FT_Long* args )
{
args[0] = Round_None(
exc,
args[0],
exc->tt_metrics.compensations[exc->opcode - 0x6C] );
args[0] = Round_None( exc, args[0], exc->opcode & 3 );
}
@ -5986,18 +5976,10 @@
if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->GS.freeVector.x != 0 )
distance = SUB_LONG(
Round_None( exc,
cur_dist,
exc->tt_metrics.compensations[0] ),
cur_dist );
distance = SUB_LONG( Round_None( exc, cur_dist, 3 ), cur_dist );
else
#endif
distance = SUB_LONG(
exc->func_round( exc,
cur_dist,
exc->tt_metrics.compensations[0] ),
cur_dist );
distance = SUB_LONG( exc->func_round( exc, cur_dist, 3 ), cur_dist );
}
else
distance = 0;
@ -6111,14 +6093,10 @@
if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->GS.freeVector.x != 0 )
distance = Round_None( exc,
distance,
exc->tt_metrics.compensations[0] );
distance = Round_None( exc, distance, 3 );
else
#endif
distance = exc->func_round( exc,
distance,
exc->tt_metrics.compensations[0] );
distance = exc->func_round( exc, distance, 3 );
}
exc->func_move( exc, &exc->zp0, point, SUB_LONG( distance, org_dist ) );
@ -6225,22 +6203,13 @@
if ( SUBPIXEL_HINTING_INFINALITY &&
exc->ignore_x_mode &&
exc->GS.freeVector.x != 0 )
distance = Round_None(
exc,
org_dist,
exc->tt_metrics.compensations[exc->opcode & 3] );
distance = Round_None( exc, org_dist, exc->opcode & 3 );
else
#endif
distance = exc->func_round(
exc,
org_dist,
exc->tt_metrics.compensations[exc->opcode & 3] );
distance = exc->func_round( exc, org_dist, exc->opcode & 3 );
}
else
distance = Round_None(
exc,
org_dist,
exc->tt_metrics.compensations[exc->opcode & 3] );
distance = Round_None( exc, org_dist, exc->opcode & 3 );
/* minimum distance flag */
@ -6412,10 +6381,7 @@
cvt_dist = org_dist;
}
distance = exc->func_round(
exc,
cvt_dist,
exc->tt_metrics.compensations[exc->opcode & 3] );
distance = exc->func_round( exc, cvt_dist, exc->opcode & 3 );
}
else
{
@ -6435,10 +6401,7 @@
}
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
distance = Round_None(
exc,
cvt_dist,
exc->tt_metrics.compensations[exc->opcode & 3] );
distance = Round_None( exc, cvt_dist, exc->opcode & 3 );
}
/* minimum distance test */

View File

@ -51,7 +51,7 @@ FT_BEGIN_HEADER
typedef FT_F26Dot6
(*TT_Round_Func)( TT_ExecContext exc,
FT_F26Dot6 distance,
FT_F26Dot6 compensation );
FT_Int color );
/* Point displacement along the freedom vector routine */
typedef void

View File

@ -1115,10 +1115,10 @@
/* The Apple specification says that the compensation for */
/* `gray' is always zero. FreeType doesn't do any */
/* compensation at all. */
tt_metrics->compensations[0] = 0; /* gray */
tt_metrics->compensations[1] = 0; /* black */
tt_metrics->compensations[2] = 0; /* white */
tt_metrics->compensations[3] = 0; /* the same as gray */
tt_metrics->compensations[0] = 0; /* gray */
tt_metrics->compensations[1] = 0; /* black */
tt_metrics->compensations[2] = 0; /* white */
tt_metrics->compensations[3] = 0; /* zero */
}
/* allocate function defs, instruction defs, cvt, and storage area */