forked from minhngoc25a/freetype2
[truetype] Support reading 32bit/16bit VarStore deltas
* include/freetype/internal/ftmmtypes.h (FT_ItemVarDelta): Define type to be used for delta arrays, upgrade to FT_long. * src/truetype/ttgxvar.c: Adhere to long_words bit and read either Short/Byte pairs or Long/Short pairs, as defined by spec. For better readability, define macro for repetitive read code.
This commit is contained in:
parent
9aa99f2262
commit
7838c78f53
|
@ -24,13 +24,15 @@
|
||||||
FT_BEGIN_HEADER
|
FT_BEGIN_HEADER
|
||||||
|
|
||||||
|
|
||||||
|
typedef FT_Long FT_ItemVarDelta;
|
||||||
|
|
||||||
typedef struct GX_ItemVarDataRec_
|
typedef struct GX_ItemVarDataRec_
|
||||||
{
|
{
|
||||||
FT_UInt itemCount; /* number of delta sets per item */
|
FT_UInt itemCount; /* number of delta sets per item */
|
||||||
FT_UInt regionIdxCount; /* number of region indices in this data */
|
FT_UInt regionIdxCount; /* number of region indices */
|
||||||
FT_UInt* regionIndices; /* array of `regionCount' indices; */
|
FT_UInt* regionIndices; /* array of `regionCount' indices; */
|
||||||
/* these index `varRegionList' */
|
/* these index `varRegionList' */
|
||||||
FT_Short* deltaSet; /* array of `itemCount' deltas */
|
FT_ItemVarDelta* deltaSet; /* array of `itemCount' deltas */
|
||||||
/* use `innerIndex' for this array */
|
/* use `innerIndex' for this array */
|
||||||
|
|
||||||
} GX_ItemVarDataRec, *GX_ItemVarData;
|
} GX_ItemVarDataRec, *GX_ItemVarData;
|
||||||
|
|
|
@ -631,44 +631,25 @@
|
||||||
varData->regionIdxCount * varData->itemCount ) )
|
varData->regionIdxCount * varData->itemCount ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
/* the delta set is stored as a 2-dimensional array of shorts */
|
for ( j = 0; j < varData->itemCount * varData->regionIdxCount; )
|
||||||
|
{
|
||||||
if ( long_words )
|
if ( long_words )
|
||||||
{
|
{
|
||||||
/* new in OpenType 1.9, currently for 'COLR' table only; */
|
for ( k = 0; k < wordDeltaCount; k++, j++ )
|
||||||
/* the deltas are interpreted as 16.16 fixed-point scaling values */
|
if ( FT_READ_LONG( varData->deltaSet[j] ) )
|
||||||
|
goto Exit;
|
||||||
/* not supported yet */
|
for ( ; k < varData->regionIdxCount; k++, j++ )
|
||||||
|
if ( FT_READ_SHORT( varData->deltaSet[j] ) )
|
||||||
error = FT_THROW( Invalid_Table );
|
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
for ( j = 0; j < varData->itemCount * varData->regionIdxCount; )
|
|
||||||
{
|
{
|
||||||
for ( k = 0; k < wordDeltaCount; k++, j++ )
|
for ( k = 0; k < wordDeltaCount; k++, j++ )
|
||||||
{
|
if ( FT_READ_SHORT( varData->deltaSet[j] ) )
|
||||||
/* read the short deltas */
|
|
||||||
FT_Short delta;
|
|
||||||
|
|
||||||
|
|
||||||
if ( FT_READ_SHORT( delta ) )
|
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
varData->deltaSet[j] = delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( ; k < varData->regionIdxCount; k++, j++ )
|
for ( ; k < varData->regionIdxCount; k++, j++ )
|
||||||
{
|
if ( FT_READ_CHAR( varData->deltaSet[j] ) )
|
||||||
/* read the (signed) byte deltas */
|
|
||||||
FT_Char delta;
|
|
||||||
|
|
||||||
|
|
||||||
if ( FT_READ_CHAR( delta ) )
|
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
varData->deltaSet[j] = delta;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -965,7 +946,7 @@
|
||||||
FT_UInt innerIndex )
|
FT_UInt innerIndex )
|
||||||
{
|
{
|
||||||
GX_ItemVarData varData;
|
GX_ItemVarData varData;
|
||||||
FT_Short* deltaSet;
|
FT_ItemVarDelta* deltaSet;
|
||||||
|
|
||||||
FT_UInt master, j;
|
FT_UInt master, j;
|
||||||
FT_Fixed netAdjustment = 0; /* accumulated adjustment */
|
FT_Fixed netAdjustment = 0; /* accumulated adjustment */
|
||||||
|
|
Loading…
Reference in New Issue