[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
diff --git a/ChangeLog b/ChangeLog
index d4a1d6b..e8ec2c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
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>
+
[truetype] Some GX structure renames for generalization.
We need this later on for MVAR also.
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index d00f874..6840784 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -405,8 +405,9 @@
static FT_Error
- ft_var_load_item_variation_store( TT_Face face,
- FT_ULong offset )
+ ft_var_load_item_variation_store( TT_Face face,
+ FT_ULong offset,
+ GX_ItemVarStore itemStore )
{
FT_Stream stream = FT_FACE_STREAM( face );
FT_Memory memory = stream->memory;
@@ -417,10 +418,8 @@
FT_UInt i, j, k;
FT_UInt shortDeltaCount;
- GX_Blend blend = face->blend;
- GX_ItemVarStore itemStore;
- GX_HVarTable hvarTable;
- GX_ItemVarData hvarData;
+ GX_Blend blend = face->blend;
+ GX_ItemVarData varData;
FT_ULong* dataOffsetArray = NULL;
@@ -436,12 +435,6 @@
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 */
if ( FT_READ_ULONG( region_offset ) ||
FT_READ_USHORT( itemStore->dataCount ) )
@@ -469,9 +462,9 @@
if ( itemStore->axisCount != (FT_Long)blend->mmvar->num_axis )
{
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 );
goto Exit;
}
@@ -514,49 +507,49 @@
for ( i = 0; i < itemStore->dataCount; i++ )
{
- hvarData = &itemStore->varData[i];
+ varData = &itemStore->varData[i];
if ( FT_STREAM_SEEK( offset + dataOffsetArray[i] ) )
goto Exit;
- if ( FT_READ_USHORT( hvarData->itemCount ) ||
- FT_READ_USHORT( shortDeltaCount ) ||
- FT_READ_USHORT( hvarData->regionIdxCount ) )
+ if ( FT_READ_USHORT( varData->itemCount ) ||
+ FT_READ_USHORT( shortDeltaCount ) ||
+ FT_READ_USHORT( varData->regionIdxCount ) )
goto Exit;
/* check some data consistency */
- if ( shortDeltaCount > hvarData->regionIdxCount )
+ if ( shortDeltaCount > varData->regionIdxCount )
{
FT_TRACE2(( "bad short count %d or region count %d\n",
shortDeltaCount,
- hvarData->regionIdxCount ));
+ varData->regionIdxCount ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
- if ( hvarData->regionIdxCount > itemStore->regionCount )
+ if ( varData->regionIdxCount > itemStore->regionCount )
{
FT_TRACE2(( "inconsistent regionCount %d in varData[%d]\n",
- hvarData->regionIdxCount,
+ varData->regionIdxCount,
i ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* parse region indices */
- if ( FT_NEW_ARRAY( hvarData->regionIndices,
- hvarData->regionIdxCount ) )
+ if ( FT_NEW_ARRAY( varData->regionIndices,
+ varData->regionIdxCount ) )
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;
- if ( hvarData->regionIndices[j] >= itemStore->regionCount )
+ if ( varData->regionIndices[j] >= itemStore->regionCount )
{
FT_TRACE2(( "bad region index %d\n",
- hvarData->regionIndices[j] ));
+ varData->regionIndices[j] ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
@@ -567,13 +560,13 @@
/* On input, deltas are (shortDeltaCount + regionIdxCount) bytes */
/* each; on output, deltas are expanded to `regionIdxCount' shorts */
/* each. */
- if ( FT_NEW_ARRAY( hvarData->deltaSet,
- hvarData->regionIdxCount * hvarData->itemCount ) )
+ if ( FT_NEW_ARRAY( varData->deltaSet,
+ varData->regionIdxCount * varData->itemCount ) )
goto Exit;
/* the delta set is stored as a 2-dimensional array of 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++ )
{
@@ -584,10 +577,10 @@
if ( FT_READ_SHORT( delta ) )
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 */
FT_Char delta;
@@ -596,7 +589,7 @@
if ( FT_READ_CHAR( delta ) )
goto Exit;
- hvarData->deltaSet[j] = delta;
+ varData->deltaSet[j] = delta;
}
}
}
@@ -609,17 +602,16 @@
static FT_Error
- ft_var_load_delta_set_index_mapping( TT_Face face,
- FT_ULong offset )
+ ft_var_load_delta_set_index_mapping( TT_Face face,
+ FT_ULong offset,
+ GX_DeltaSetIdxMap map,
+ GX_ItemVarStore itemStore )
{
FT_Stream stream = FT_FACE_STREAM( face );
FT_Memory memory = stream->memory;
FT_Error error;
- GX_Blend blend = face->blend;
- GX_DeltaSetIdxMap widthMap;
-
FT_UShort format;
FT_UInt entrySize;
FT_UInt innerBitCount;
@@ -627,11 +619,9 @@
FT_UInt i, j;
- widthMap = &blend->hvar_table->widthMap;
-
- if ( FT_STREAM_SEEK( offset ) ||
- FT_READ_USHORT( format ) ||
- FT_READ_USHORT( widthMap->mapCount ) )
+ if ( FT_STREAM_SEEK( offset ) ||
+ FT_READ_USHORT( format ) ||
+ FT_READ_USHORT( map->mapCount ) )
goto Exit;
if ( format & 0xFFC0 )
@@ -646,13 +636,13 @@
innerBitCount = ( format & 0x000F ) + 1;
innerIndexMask = ( 1 << innerBitCount ) - 1;
- if ( FT_NEW_ARRAY( widthMap->innerIndex, widthMap->mapCount ) )
+ if ( FT_NEW_ARRAY( map->innerIndex, map->mapCount ) )
goto Exit;
- if ( FT_NEW_ARRAY( widthMap->outerIndex, widthMap->mapCount ) )
+ if ( FT_NEW_ARRAY( map->outerIndex, map->mapCount ) )
goto Exit;
- for ( i = 0; i < widthMap->mapCount; i++ )
+ for ( i = 0; i < map->mapCount; i++ )
{
FT_UInt mapData = 0;
FT_UInt outerIndex, innerIndex;
@@ -672,7 +662,7 @@
outerIndex = mapData >> innerBitCount;
- if ( outerIndex >= blend->hvar_table->itemStore.dataCount )
+ if ( outerIndex >= itemStore->dataCount )
{
FT_TRACE2(( "outerIndex[%d] == %d out of range\n",
i,
@@ -681,12 +671,11 @@
goto Exit;
}
- widthMap->outerIndex[i] = outerIndex;
+ map->outerIndex[i] = outerIndex;
innerIndex = mapData & innerIndexMask;
- if ( innerIndex >=
- blend->hvar_table->itemStore.varData[outerIndex].itemCount )
+ if ( innerIndex >= itemStore->varData[outerIndex].itemCount )
{
FT_TRACE2(( "innerIndex[%d] == %d out of range\n",
i,
@@ -695,7 +684,7 @@
goto Exit;
}
- widthMap->innerIndex[i] = innerIndex;
+ map->innerIndex[i] = innerIndex;
}
Exit:
@@ -726,6 +715,7 @@
ft_var_load_hvar( TT_Face face )
{
FT_Stream stream = FT_FACE_STREAM( face );
+ FT_Memory memory = stream->memory;
GX_Blend blend = face->blend;
@@ -765,9 +755,13 @@
FT_READ_ULONG( widthMap_offset ) )
goto Exit;
+ if ( FT_NEW( blend->hvar_table ) )
+ goto Exit;
+
error = ft_var_load_item_variation_store(
face,
- table_offset + store_offset );
+ table_offset + store_offset,
+ &blend->hvar_table->itemStore );
if ( error )
goto Exit;
@@ -775,7 +769,9 @@
{
error = ft_var_load_delta_set_index_mapping(
face,
- table_offset + widthMap_offset );
+ table_offset + widthMap_offset,
+ &blend->hvar_table->widthMap,
+ &blend->hvar_table->itemStore );
if ( error )
goto Exit;
}