... |
... |
@@ -30,10 +30,15 @@ |
30
|
30
|
#include <freetype/internal/ftcalc.h>
|
31
|
31
|
#include <freetype/internal/ftdebug.h>
|
32
|
32
|
#include <freetype/internal/ftstream.h>
|
|
33
|
+#include <freetype/internal/services/svmm.h>
|
33
|
34
|
#include <freetype/tttags.h>
|
34
|
35
|
#include <freetype/ftcolor.h>
|
35
|
36
|
#include <freetype/config/integer-types.h>
|
36
|
37
|
|
|
38
|
+ /* the next code line is a temporary hack, to be removed together with */
|
|
39
|
+ /* `VARIABLE_COLRV1_ENABLED` and related code */
|
|
40
|
+#include "../truetype/ttobjs.h"
|
|
41
|
+
|
37
|
42
|
|
38
|
43
|
#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
|
39
|
44
|
|
... |
... |
@@ -50,6 +55,10 @@ |
50
|
55
|
#define COLR_HEADER_SIZE 14U
|
51
|
56
|
|
52
|
57
|
|
|
58
|
+#define VARIABLE_COLRV1_ENABLED \
|
|
59
|
+ ( ((TT_Driver)FT_FACE_DRIVER( face ))->enable_variable_colrv1 )
|
|
60
|
+
|
|
61
|
+
|
53
|
62
|
typedef enum FT_PaintFormat_Internal_
|
54
|
63
|
{
|
55
|
64
|
FT_COLR_PAINTFORMAT_INTERNAL_SCALE_CENTER = 18,
|
... |
... |
@@ -104,6 +113,10 @@ |
104
|
113
|
*/
|
105
|
114
|
FT_Byte* paints_start_v1;
|
106
|
115
|
|
|
116
|
+ /* Item Variation Store for variable 'COLR' v1. */
|
|
117
|
+ GX_ItemVarStoreRec var_store;
|
|
118
|
+ GX_DeltaSetIdxMapRec delta_set_idx_map;
|
|
119
|
+
|
107
|
120
|
/* The memory that backs up the `COLR' table. */
|
108
|
121
|
void* table;
|
109
|
122
|
FT_ULong table_size;
|
... |
... |
@@ -138,7 +151,9 @@ |
138
|
151
|
FT_ULong base_glyph_offset, layer_offset;
|
139
|
152
|
FT_ULong base_glyphs_offset_v1, num_base_glyphs_v1;
|
140
|
153
|
FT_ULong layer_offset_v1, num_layers_v1, clip_list_offset;
|
|
154
|
+ FT_ULong var_idx_map_offset, var_store_offset;
|
141
|
155
|
FT_ULong table_size;
|
|
156
|
+ FT_ULong colr_offset_in_stream;
|
142
|
157
|
|
143
|
158
|
|
144
|
159
|
/* `COLR' always needs `CPAL' */
|
... |
... |
@@ -149,6 +164,8 @@ |
149
|
164
|
if ( error )
|
150
|
165
|
goto NoColr;
|
151
|
166
|
|
|
167
|
+ colr_offset_in_stream = FT_STREAM_POS();
|
|
168
|
+
|
152
|
169
|
if ( table_size < COLR_HEADER_SIZE )
|
153
|
170
|
goto InvalidTable;
|
154
|
171
|
|
... |
... |
@@ -239,6 +256,64 @@ |
239
|
256
|
colr->clip_list = (FT_Byte*)( table + clip_list_offset );
|
240
|
257
|
else
|
241
|
258
|
colr->clip_list = 0;
|
|
259
|
+
|
|
260
|
+ colr->var_store.dataCount = 0;
|
|
261
|
+ colr->var_store.varData = NULL;
|
|
262
|
+ colr->var_store.axisCount = 0;
|
|
263
|
+ colr->var_store.regionCount = 0;
|
|
264
|
+ colr->var_store.varRegionList = 0;
|
|
265
|
+
|
|
266
|
+ colr->delta_set_idx_map.mapCount = 0;
|
|
267
|
+ colr->delta_set_idx_map.outerIndex = NULL;
|
|
268
|
+ colr->delta_set_idx_map.innerIndex = NULL;
|
|
269
|
+
|
|
270
|
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
271
|
+ if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR &&
|
|
272
|
+ VARIABLE_COLRV1_ENABLED )
|
|
273
|
+ {
|
|
274
|
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+ var_idx_map_offset = FT_NEXT_ULONG( p );
|
|
278
|
+
|
|
279
|
+ if ( var_idx_map_offset >= table_size )
|
|
280
|
+ goto InvalidTable;
|
|
281
|
+
|
|
282
|
+ var_store_offset = FT_NEXT_ULONG( p );
|
|
283
|
+ if ( var_store_offset >= table_size )
|
|
284
|
+ goto InvalidTable;
|
|
285
|
+
|
|
286
|
+ if ( var_store_offset )
|
|
287
|
+ {
|
|
288
|
+ /* If variation info has not been initialized yet, try doing so, */
|
|
289
|
+ /* otherwise loading the variation store will fail as it */
|
|
290
|
+ /* requires access to `blend` for checking the number of axes. */
|
|
291
|
+ if ( !face->blend )
|
|
292
|
+ if ( mm->get_mm_var( FT_FACE( face ), NULL ) )
|
|
293
|
+ goto InvalidTable;
|
|
294
|
+
|
|
295
|
+ /* Try loading `VarIdxMap` and `VarStore`. */
|
|
296
|
+ error = mm->load_item_var_store(
|
|
297
|
+ FT_FACE( face ),
|
|
298
|
+ colr_offset_in_stream + var_store_offset,
|
|
299
|
+ &colr->var_store );
|
|
300
|
+ if ( error != FT_Err_Ok )
|
|
301
|
+ goto InvalidTable;
|
|
302
|
+ }
|
|
303
|
+
|
|
304
|
+ if ( colr->var_store.axisCount && var_idx_map_offset )
|
|
305
|
+ {
|
|
306
|
+ error = mm->load_delta_set_idx_map(
|
|
307
|
+ FT_FACE( face ),
|
|
308
|
+ colr_offset_in_stream + var_idx_map_offset,
|
|
309
|
+ &colr->delta_set_idx_map,
|
|
310
|
+ &colr->var_store,
|
|
311
|
+ table_size );
|
|
312
|
+ if ( error != FT_Err_Ok )
|
|
313
|
+ goto InvalidTable;
|
|
314
|
+ }
|
|
315
|
+ }
|
|
316
|
+#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
|
242
|
317
|
}
|
243
|
318
|
|
244
|
319
|
colr->base_glyphs = (FT_Byte*)( table + base_glyph_offset );
|
... |
... |
@@ -251,6 +326,19 @@ |
251
|
326
|
return FT_Err_Ok;
|
252
|
327
|
|
253
|
328
|
InvalidTable:
|
|
329
|
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
330
|
+ if ( VARIABLE_COLRV1_ENABLED )
|
|
331
|
+ {
|
|
332
|
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+ mm->done_delta_set_idx_map( FT_FACE( face ),
|
|
336
|
+ &colr->delta_set_idx_map );
|
|
337
|
+ mm->done_item_var_store( FT_FACE( face ),
|
|
338
|
+ &colr->var_store );
|
|
339
|
+ }
|
|
340
|
+#endif
|
|
341
|
+
|
254
|
342
|
error = FT_THROW( Invalid_Table );
|
255
|
343
|
|
256
|
344
|
NoColr:
|
... |
... |
@@ -272,6 +360,18 @@ |
272
|
360
|
|
273
|
361
|
if ( colr )
|
274
|
362
|
{
|
|
363
|
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
|
364
|
+ if ( VARIABLE_COLRV1_ENABLED )
|
|
365
|
+ {
|
|
366
|
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+ mm->done_delta_set_idx_map( FT_FACE( face ),
|
|
370
|
+ &colr->delta_set_idx_map );
|
|
371
|
+ mm->done_item_var_store( FT_FACE( face ),
|
|
372
|
+ &colr->var_store );
|
|
373
|
+ }
|
|
374
|
+#endif
|
275
|
375
|
FT_FRAME_RELEASE( colr->table );
|
276
|
376
|
FT_FREE( colr );
|
277
|
377
|
}
|