[truetype] More generalization of GX stuff.
We need this later on for MVAR also. * src/truetype/ttgxvar.c (ft_var_load_delta_set_index_mapping): Add parameters for delta-set index mapping and item variation store. (ft_var_load_item_variation_store): Add parameter for item variation store. s/hvarData/varData/. Move allocation of `hvar_table' to... (ft_var_load_hvar): ...this function. Updated.
This commit is contained in:
parent
0bd0112f4e
commit
fb90f00cbd
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2017-01-06 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
|
[truetype] More generalization of GX stuff.
|
||||||
|
|
||||||
|
We need this later on for MVAR also.
|
||||||
|
|
||||||
|
* src/truetype/ttgxvar.c (ft_var_load_delta_set_index_mapping): Add
|
||||||
|
parameters for delta-set index mapping and item variation store.
|
||||||
|
(ft_var_load_item_variation_store): Add parameter for item variation
|
||||||
|
store.
|
||||||
|
s/hvarData/varData/.
|
||||||
|
Move allocation of `hvar_table' to...
|
||||||
|
(ft_var_load_hvar): ...this function.
|
||||||
|
Updated.
|
||||||
|
|
||||||
2017-01-06 Werner Lemberg <wl@gnu.org>
|
2017-01-06 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
[truetype] Some GX structure renames for generalization.
|
[truetype] Some GX structure renames for generalization.
|
||||||
|
|
|
@ -405,8 +405,9 @@
|
||||||
|
|
||||||
|
|
||||||
static FT_Error
|
static FT_Error
|
||||||
ft_var_load_item_variation_store( TT_Face face,
|
ft_var_load_item_variation_store( TT_Face face,
|
||||||
FT_ULong offset )
|
FT_ULong offset,
|
||||||
|
GX_ItemVarStore itemStore )
|
||||||
{
|
{
|
||||||
FT_Stream stream = FT_FACE_STREAM( face );
|
FT_Stream stream = FT_FACE_STREAM( face );
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
@ -417,10 +418,8 @@
|
||||||
FT_UInt i, j, k;
|
FT_UInt i, j, k;
|
||||||
FT_UInt shortDeltaCount;
|
FT_UInt shortDeltaCount;
|
||||||
|
|
||||||
GX_Blend blend = face->blend;
|
GX_Blend blend = face->blend;
|
||||||
GX_ItemVarStore itemStore;
|
GX_ItemVarData varData;
|
||||||
GX_HVarTable hvarTable;
|
|
||||||
GX_ItemVarData hvarData;
|
|
||||||
|
|
||||||
FT_ULong* dataOffsetArray = NULL;
|
FT_ULong* dataOffsetArray = NULL;
|
||||||
|
|
||||||
|
@ -436,12 +435,6 @@
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( FT_NEW( blend->hvar_table ) ) /* allocate table at top level */
|
|
||||||
goto Exit;
|
|
||||||
|
|
||||||
hvarTable = blend->hvar_table;
|
|
||||||
itemStore = &hvarTable->itemStore;
|
|
||||||
|
|
||||||
/* read top level fields */
|
/* read top level fields */
|
||||||
if ( FT_READ_ULONG( region_offset ) ||
|
if ( FT_READ_ULONG( region_offset ) ||
|
||||||
FT_READ_USHORT( itemStore->dataCount ) )
|
FT_READ_USHORT( itemStore->dataCount ) )
|
||||||
|
@ -469,9 +462,9 @@
|
||||||
if ( itemStore->axisCount != (FT_Long)blend->mmvar->num_axis )
|
if ( itemStore->axisCount != (FT_Long)blend->mmvar->num_axis )
|
||||||
{
|
{
|
||||||
FT_TRACE2(( "ft_var_load_item_variation_store:"
|
FT_TRACE2(( "ft_var_load_item_variation_store:"
|
||||||
" number of axes in `hvar' and `fvar'\n"
|
" number of axes in item variation store\n"
|
||||||
" "
|
" "
|
||||||
" table are different\n" ));
|
" and `fvar' table are different\n" ));
|
||||||
error = FT_THROW( Invalid_Table );
|
error = FT_THROW( Invalid_Table );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
@ -514,49 +507,49 @@
|
||||||
|
|
||||||
for ( i = 0; i < itemStore->dataCount; i++ )
|
for ( i = 0; i < itemStore->dataCount; i++ )
|
||||||
{
|
{
|
||||||
hvarData = &itemStore->varData[i];
|
varData = &itemStore->varData[i];
|
||||||
|
|
||||||
if ( FT_STREAM_SEEK( offset + dataOffsetArray[i] ) )
|
if ( FT_STREAM_SEEK( offset + dataOffsetArray[i] ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
if ( FT_READ_USHORT( hvarData->itemCount ) ||
|
if ( FT_READ_USHORT( varData->itemCount ) ||
|
||||||
FT_READ_USHORT( shortDeltaCount ) ||
|
FT_READ_USHORT( shortDeltaCount ) ||
|
||||||
FT_READ_USHORT( hvarData->regionIdxCount ) )
|
FT_READ_USHORT( varData->regionIdxCount ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
/* check some data consistency */
|
/* check some data consistency */
|
||||||
if ( shortDeltaCount > hvarData->regionIdxCount )
|
if ( shortDeltaCount > varData->regionIdxCount )
|
||||||
{
|
{
|
||||||
FT_TRACE2(( "bad short count %d or region count %d\n",
|
FT_TRACE2(( "bad short count %d or region count %d\n",
|
||||||
shortDeltaCount,
|
shortDeltaCount,
|
||||||
hvarData->regionIdxCount ));
|
varData->regionIdxCount ));
|
||||||
error = FT_THROW( Invalid_Table );
|
error = FT_THROW( Invalid_Table );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hvarData->regionIdxCount > itemStore->regionCount )
|
if ( varData->regionIdxCount > itemStore->regionCount )
|
||||||
{
|
{
|
||||||
FT_TRACE2(( "inconsistent regionCount %d in varData[%d]\n",
|
FT_TRACE2(( "inconsistent regionCount %d in varData[%d]\n",
|
||||||
hvarData->regionIdxCount,
|
varData->regionIdxCount,
|
||||||
i ));
|
i ));
|
||||||
error = FT_THROW( Invalid_Table );
|
error = FT_THROW( Invalid_Table );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse region indices */
|
/* parse region indices */
|
||||||
if ( FT_NEW_ARRAY( hvarData->regionIndices,
|
if ( FT_NEW_ARRAY( varData->regionIndices,
|
||||||
hvarData->regionIdxCount ) )
|
varData->regionIdxCount ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
for ( j = 0; j < hvarData->regionIdxCount; j++ )
|
for ( j = 0; j < varData->regionIdxCount; j++ )
|
||||||
{
|
{
|
||||||
if ( FT_READ_USHORT( hvarData->regionIndices[j] ) )
|
if ( FT_READ_USHORT( varData->regionIndices[j] ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
if ( hvarData->regionIndices[j] >= itemStore->regionCount )
|
if ( varData->regionIndices[j] >= itemStore->regionCount )
|
||||||
{
|
{
|
||||||
FT_TRACE2(( "bad region index %d\n",
|
FT_TRACE2(( "bad region index %d\n",
|
||||||
hvarData->regionIndices[j] ));
|
varData->regionIndices[j] ));
|
||||||
error = FT_THROW( Invalid_Table );
|
error = FT_THROW( Invalid_Table );
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
@ -567,13 +560,13 @@
|
||||||
/* On input, deltas are (shortDeltaCount + regionIdxCount) bytes */
|
/* On input, deltas are (shortDeltaCount + regionIdxCount) bytes */
|
||||||
/* each; on output, deltas are expanded to `regionIdxCount' shorts */
|
/* each; on output, deltas are expanded to `regionIdxCount' shorts */
|
||||||
/* each. */
|
/* each. */
|
||||||
if ( FT_NEW_ARRAY( hvarData->deltaSet,
|
if ( FT_NEW_ARRAY( varData->deltaSet,
|
||||||
hvarData->regionIdxCount * hvarData->itemCount ) )
|
varData->regionIdxCount * varData->itemCount ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
/* the delta set is stored as a 2-dimensional array of shorts; */
|
/* the delta set is stored as a 2-dimensional array of shorts; */
|
||||||
/* sign-extend signed bytes to signed shorts */
|
/* sign-extend signed bytes to signed shorts */
|
||||||
for ( j = 0; j < hvarData->itemCount * hvarData->regionIdxCount; )
|
for ( j = 0; j < varData->itemCount * varData->regionIdxCount; )
|
||||||
{
|
{
|
||||||
for ( k = 0; k < shortDeltaCount; k++, j++ )
|
for ( k = 0; k < shortDeltaCount; k++, j++ )
|
||||||
{
|
{
|
||||||
|
@ -584,10 +577,10 @@
|
||||||
if ( FT_READ_SHORT( delta ) )
|
if ( FT_READ_SHORT( delta ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
hvarData->deltaSet[j] = delta;
|
varData->deltaSet[j] = delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; k < hvarData->regionIdxCount; k++, j++ )
|
for ( ; k < varData->regionIdxCount; k++, j++ )
|
||||||
{
|
{
|
||||||
/* read the (signed) byte deltas */
|
/* read the (signed) byte deltas */
|
||||||
FT_Char delta;
|
FT_Char delta;
|
||||||
|
@ -596,7 +589,7 @@
|
||||||
if ( FT_READ_CHAR( delta ) )
|
if ( FT_READ_CHAR( delta ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
hvarData->deltaSet[j] = delta;
|
varData->deltaSet[j] = delta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,17 +602,16 @@
|
||||||
|
|
||||||
|
|
||||||
static FT_Error
|
static FT_Error
|
||||||
ft_var_load_delta_set_index_mapping( TT_Face face,
|
ft_var_load_delta_set_index_mapping( TT_Face face,
|
||||||
FT_ULong offset )
|
FT_ULong offset,
|
||||||
|
GX_DeltaSetIdxMap map,
|
||||||
|
GX_ItemVarStore itemStore )
|
||||||
{
|
{
|
||||||
FT_Stream stream = FT_FACE_STREAM( face );
|
FT_Stream stream = FT_FACE_STREAM( face );
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
|
|
||||||
GX_Blend blend = face->blend;
|
|
||||||
GX_DeltaSetIdxMap widthMap;
|
|
||||||
|
|
||||||
FT_UShort format;
|
FT_UShort format;
|
||||||
FT_UInt entrySize;
|
FT_UInt entrySize;
|
||||||
FT_UInt innerBitCount;
|
FT_UInt innerBitCount;
|
||||||
|
@ -627,11 +619,9 @@
|
||||||
FT_UInt i, j;
|
FT_UInt i, j;
|
||||||
|
|
||||||
|
|
||||||
widthMap = &blend->hvar_table->widthMap;
|
if ( FT_STREAM_SEEK( offset ) ||
|
||||||
|
FT_READ_USHORT( format ) ||
|
||||||
if ( FT_STREAM_SEEK( offset ) ||
|
FT_READ_USHORT( map->mapCount ) )
|
||||||
FT_READ_USHORT( format ) ||
|
|
||||||
FT_READ_USHORT( widthMap->mapCount ) )
|
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
if ( format & 0xFFC0 )
|
if ( format & 0xFFC0 )
|
||||||
|
@ -646,13 +636,13 @@
|
||||||
innerBitCount = ( format & 0x000F ) + 1;
|
innerBitCount = ( format & 0x000F ) + 1;
|
||||||
innerIndexMask = ( 1 << innerBitCount ) - 1;
|
innerIndexMask = ( 1 << innerBitCount ) - 1;
|
||||||
|
|
||||||
if ( FT_NEW_ARRAY( widthMap->innerIndex, widthMap->mapCount ) )
|
if ( FT_NEW_ARRAY( map->innerIndex, map->mapCount ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
if ( FT_NEW_ARRAY( widthMap->outerIndex, widthMap->mapCount ) )
|
if ( FT_NEW_ARRAY( map->outerIndex, map->mapCount ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
for ( i = 0; i < widthMap->mapCount; i++ )
|
for ( i = 0; i < map->mapCount; i++ )
|
||||||
{
|
{
|
||||||
FT_UInt mapData = 0;
|
FT_UInt mapData = 0;
|
||||||
FT_UInt outerIndex, innerIndex;
|
FT_UInt outerIndex, innerIndex;
|
||||||
|
@ -672,7 +662,7 @@
|
||||||
|
|
||||||
outerIndex = mapData >> innerBitCount;
|
outerIndex = mapData >> innerBitCount;
|
||||||
|
|
||||||
if ( outerIndex >= blend->hvar_table->itemStore.dataCount )
|
if ( outerIndex >= itemStore->dataCount )
|
||||||
{
|
{
|
||||||
FT_TRACE2(( "outerIndex[%d] == %d out of range\n",
|
FT_TRACE2(( "outerIndex[%d] == %d out of range\n",
|
||||||
i,
|
i,
|
||||||
|
@ -681,12 +671,11 @@
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
widthMap->outerIndex[i] = outerIndex;
|
map->outerIndex[i] = outerIndex;
|
||||||
|
|
||||||
innerIndex = mapData & innerIndexMask;
|
innerIndex = mapData & innerIndexMask;
|
||||||
|
|
||||||
if ( innerIndex >=
|
if ( innerIndex >= itemStore->varData[outerIndex].itemCount )
|
||||||
blend->hvar_table->itemStore.varData[outerIndex].itemCount )
|
|
||||||
{
|
{
|
||||||
FT_TRACE2(( "innerIndex[%d] == %d out of range\n",
|
FT_TRACE2(( "innerIndex[%d] == %d out of range\n",
|
||||||
i,
|
i,
|
||||||
|
@ -695,7 +684,7 @@
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
widthMap->innerIndex[i] = innerIndex;
|
map->innerIndex[i] = innerIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
|
@ -726,6 +715,7 @@
|
||||||
ft_var_load_hvar( TT_Face face )
|
ft_var_load_hvar( TT_Face face )
|
||||||
{
|
{
|
||||||
FT_Stream stream = FT_FACE_STREAM( face );
|
FT_Stream stream = FT_FACE_STREAM( face );
|
||||||
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
GX_Blend blend = face->blend;
|
GX_Blend blend = face->blend;
|
||||||
|
|
||||||
|
@ -765,9 +755,13 @@
|
||||||
FT_READ_ULONG( widthMap_offset ) )
|
FT_READ_ULONG( widthMap_offset ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
if ( FT_NEW( blend->hvar_table ) )
|
||||||
|
goto Exit;
|
||||||
|
|
||||||
error = ft_var_load_item_variation_store(
|
error = ft_var_load_item_variation_store(
|
||||||
face,
|
face,
|
||||||
table_offset + store_offset );
|
table_offset + store_offset,
|
||||||
|
&blend->hvar_table->itemStore );
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
@ -775,7 +769,9 @@
|
||||||
{
|
{
|
||||||
error = ft_var_load_delta_set_index_mapping(
|
error = ft_var_load_delta_set_index_mapping(
|
||||||
face,
|
face,
|
||||||
table_offset + widthMap_offset );
|
table_offset + widthMap_offset,
|
||||||
|
&blend->hvar_table->widthMap,
|
||||||
|
&blend->hvar_table->itemStore );
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue