Alexei Podtelezhnikov pushed to branch clean-gxvar
at FreeType / FreeType
Commits:
-
f7daf9d2
by Ben Wagner
at 2022-06-18T12:58:23-04:00
[stream] Fix reading s32 when long is s64
`FT_READ_LONG`, `FT_GET_LONG`, and related macros did not return
negative values when `long` is more than 32 bits. `FT_Stream_ReadULong`
would read four bytes into the LSB of an `FT_ULong` and return that.
Since this can never set the MSb of the `FT_ULong` when `FT_ULong` is
more than 32 bits the cast to `FT_Long` never resulted in a negative
value.
Fix this by modifying `FT_Stream_Read*` to return a type of the same
size as the bytes it is reading and changing the `FT_READ_*` and
`FT_GET_*` macros to cast to the same type returned by `FT_Stream_Read*`
but with the correctly signed type (instead of casting to what is
assumed to be the type of `var` which will happen automatically anyway).
There exist a few cases like with the `OFF3` variants where there isn't
generally a type with the correct size. `FT_PEEK_OFF3` works around this
loading the bytes into the three most significant bits and then doing a
signed shift down. `FT_NEXT_OFF3` also already worked correctly by
casting this signed value to another signed type. `FT_Stream_GetUOffset`
works correctly but one must be careful not to attempt to cast the
returned value to a signed type. Fortunately there is only
`FT_GET_UOFF3` and no `FT_GET_OFF3`.
All of these cases are handled correctly when reading values through
`FT_Stream_ReadFields` since it generically computes the signed value
through an `FT_Int32`. This change is essentially doing the same for
these macros.
* include/freetype/internal/ftstream.h (FT_NEXT_*, FT_GET_*, FT_READ*):
Update macros and return types to use fixed size types for fixed size
values.
* src/base/ftstream.c (FT_StreamGet*, FT_StreamRead*): Dito.
Issue: #1161
-
705f4161
by Alexei Podtelezhnikov
at 2022-06-18T23:02:26-04:00
[truetype/GX] Clean up phantom point adjustment.
This moves phantom point and advance variation adjustment next to
calculations. The logic stays the same, HVAR and VVAR take priority.
* src/truetype/ttgload.c (load_truetype_glyph): Move it from here...
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): ... to here
and check for HVAR and VVAR presence outside the main loop.
-
47103b2f
by Alexei Podtelezhnikov
at 2022-06-18T23:09:17-04:00
[truetype] Clean up phantom point accounting.
This formalizes that the phantom points appended in the outline
do not increase its point count, nor are they tagged or included
in any additional contours. Only their coordinates are stored.
They are counted in the glyph zone, however.
* src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Infer `n_points`
from the outline size plus four phantom points.
* src/truetype/ttgxvar.h (TT_Vary_Apply_Glyph_Deltas): Remove this
argument.
* src/truetype/ttgload.c (tt_prepare_zone): Add phantom four.
(TT_Process_Simple_Glyph, load_truetype_glyph): Update all callers.
5 changed files:
Changes:
include/freetype/internal/ftstream.h
... |
... |
@@ -238,42 +238,42 @@ FT_BEGIN_HEADER |
238
|
238
|
#define FT_NEXT_BYTE( buffer ) \
|
239
|
239
|
( (unsigned char)*buffer++ )
|
240
|
240
|
|
241
|
|
-#define FT_NEXT_SHORT( buffer ) \
|
242
|
|
- ( (short)( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) ) )
|
|
241
|
+#define FT_NEXT_SHORT( buffer ) \
|
|
242
|
+ ( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) )
|
243
|
243
|
|
244
|
|
-#define FT_NEXT_USHORT( buffer ) \
|
245
|
|
- ( (unsigned short)( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) ) )
|
|
244
|
+#define FT_NEXT_USHORT( buffer ) \
|
|
245
|
+ ( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) )
|
246
|
246
|
|
247
|
|
-#define FT_NEXT_OFF3( buffer ) \
|
248
|
|
- ( (long)( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) ) )
|
|
247
|
+#define FT_NEXT_OFF3( buffer ) \
|
|
248
|
+ ( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) )
|
249
|
249
|
|
250
|
|
-#define FT_NEXT_UOFF3( buffer ) \
|
251
|
|
- ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) ) )
|
|
250
|
+#define FT_NEXT_UOFF3( buffer ) \
|
|
251
|
+ ( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) )
|
252
|
252
|
|
253
|
|
-#define FT_NEXT_LONG( buffer ) \
|
254
|
|
- ( (long)( buffer += 4, FT_PEEK_LONG( buffer - 4 ) ) )
|
|
253
|
+#define FT_NEXT_LONG( buffer ) \
|
|
254
|
+ ( buffer += 4, FT_PEEK_LONG( buffer - 4 ) )
|
255
|
255
|
|
256
|
|
-#define FT_NEXT_ULONG( buffer ) \
|
257
|
|
- ( (unsigned long)( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) ) )
|
|
256
|
+#define FT_NEXT_ULONG( buffer ) \
|
|
257
|
+ ( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) )
|
258
|
258
|
|
259
|
259
|
|
260
|
|
-#define FT_NEXT_SHORT_LE( buffer ) \
|
261
|
|
- ( (short)( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) ) )
|
|
260
|
+#define FT_NEXT_SHORT_LE( buffer ) \
|
|
261
|
+ ( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) )
|
262
|
262
|
|
263
|
|
-#define FT_NEXT_USHORT_LE( buffer ) \
|
264
|
|
- ( (unsigned short)( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) ) )
|
|
263
|
+#define FT_NEXT_USHORT_LE( buffer ) \
|
|
264
|
+ ( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) )
|
265
|
265
|
|
266
|
|
-#define FT_NEXT_OFF3_LE( buffer ) \
|
267
|
|
- ( (long)( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) ) )
|
|
266
|
+#define FT_NEXT_OFF3_LE( buffer ) \
|
|
267
|
+ ( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) )
|
268
|
268
|
|
269
|
|
-#define FT_NEXT_UOFF3_LE( buffer ) \
|
270
|
|
- ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) ) )
|
|
269
|
+#define FT_NEXT_UOFF3_LE( buffer ) \
|
|
270
|
+ ( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) )
|
271
|
271
|
|
272
|
|
-#define FT_NEXT_LONG_LE( buffer ) \
|
273
|
|
- ( (long)( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) ) )
|
|
272
|
+#define FT_NEXT_LONG_LE( buffer ) \
|
|
273
|
+ ( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) )
|
274
|
274
|
|
275
|
|
-#define FT_NEXT_ULONG_LE( buffer ) \
|
276
|
|
- ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) )
|
|
275
|
+#define FT_NEXT_ULONG_LE( buffer ) \
|
|
276
|
+ ( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) )
|
277
|
277
|
|
278
|
278
|
|
279
|
279
|
/**************************************************************************
|
... |
... |
@@ -307,17 +307,17 @@ FT_BEGIN_HEADER |
307
|
307
|
|
308
|
308
|
#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetByte, FT_Char )
|
309
|
309
|
#define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetByte, FT_Byte )
|
310
|
|
-#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Short )
|
311
|
|
-#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UShort )
|
312
|
|
-#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_ULong )
|
313
|
|
-#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Long )
|
314
|
|
-#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong )
|
315
|
|
-#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong )
|
316
|
|
-
|
317
|
|
-#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Short )
|
318
|
|
-#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UShort )
|
319
|
|
-#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Long )
|
320
|
|
-#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_ULong )
|
|
310
|
+#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Int16 )
|
|
311
|
+#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UInt16 )
|
|
312
|
+#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_UInt32 )
|
|
313
|
+#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Int32 )
|
|
314
|
+#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_UInt32 )
|
|
315
|
+#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_UInt32 )
|
|
316
|
+
|
|
317
|
+#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Int32 )
|
|
318
|
+#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UInt32 )
|
|
319
|
+#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Int32 )
|
|
320
|
+#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_UInt32 )
|
321
|
321
|
#endif
|
322
|
322
|
|
323
|
323
|
|
... |
... |
@@ -334,16 +334,16 @@ FT_BEGIN_HEADER |
334
|
334
|
*/
|
335
|
335
|
#define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadByte, FT_Byte, var )
|
336
|
336
|
#define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadByte, FT_Char, var )
|
337
|
|
-#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Short, var )
|
338
|
|
-#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UShort, var )
|
339
|
|
-#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_ULong, var )
|
340
|
|
-#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Long, var )
|
341
|
|
-#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_ULong, var )
|
|
337
|
+#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Int16, var )
|
|
338
|
+#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UInt16, var )
|
|
339
|
+#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_UInt32, var )
|
|
340
|
+#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Int32, var )
|
|
341
|
+#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_UInt32, var )
|
342
|
342
|
|
343
|
|
-#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Short, var )
|
344
|
|
-#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UShort, var )
|
345
|
|
-#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Long, var )
|
346
|
|
-#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_ULong, var )
|
|
343
|
+#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Int16, var )
|
|
344
|
+#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UInt16, var )
|
|
345
|
+#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Int32, var )
|
|
346
|
+#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_UInt32, var )
|
347
|
347
|
|
348
|
348
|
|
349
|
349
|
#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
|
... |
... |
@@ -459,23 +459,23 @@ FT_BEGIN_HEADER |
459
|
459
|
FT_Stream_GetByte( FT_Stream stream );
|
460
|
460
|
|
461
|
461
|
/* read a 16-bit big-endian unsigned integer from an entered frame */
|
462
|
|
- FT_BASE( FT_UShort )
|
|
462
|
+ FT_BASE( FT_UInt16 )
|
463
|
463
|
FT_Stream_GetUShort( FT_Stream stream );
|
464
|
464
|
|
465
|
465
|
/* read a 24-bit big-endian unsigned integer from an entered frame */
|
466
|
|
- FT_BASE( FT_ULong )
|
|
466
|
+ FT_BASE( FT_UInt32 )
|
467
|
467
|
FT_Stream_GetUOffset( FT_Stream stream );
|
468
|
468
|
|
469
|
469
|
/* read a 32-bit big-endian unsigned integer from an entered frame */
|
470
|
|
- FT_BASE( FT_ULong )
|
|
470
|
+ FT_BASE( FT_UInt32 )
|
471
|
471
|
FT_Stream_GetULong( FT_Stream stream );
|
472
|
472
|
|
473
|
473
|
/* read a 16-bit little-endian unsigned integer from an entered frame */
|
474
|
|
- FT_BASE( FT_UShort )
|
|
474
|
+ FT_BASE( FT_UInt16 )
|
475
|
475
|
FT_Stream_GetUShortLE( FT_Stream stream );
|
476
|
476
|
|
477
|
477
|
/* read a 32-bit little-endian unsigned integer from an entered frame */
|
478
|
|
- FT_BASE( FT_ULong )
|
|
478
|
+ FT_BASE( FT_UInt32 )
|
479
|
479
|
FT_Stream_GetULongLE( FT_Stream stream );
|
480
|
480
|
|
481
|
481
|
|
... |
... |
@@ -485,7 +485,7 @@ FT_BEGIN_HEADER |
485
|
485
|
FT_Error* error );
|
486
|
486
|
|
487
|
487
|
/* read a 16-bit big-endian unsigned integer from a stream */
|
488
|
|
- FT_BASE( FT_UShort )
|
|
488
|
+ FT_BASE( FT_UInt16 )
|
489
|
489
|
FT_Stream_ReadUShort( FT_Stream stream,
|
490
|
490
|
FT_Error* error );
|
491
|
491
|
|
... |
... |
@@ -495,17 +495,17 @@ FT_BEGIN_HEADER |
495
|
495
|
FT_Error* error );
|
496
|
496
|
|
497
|
497
|
/* read a 32-bit big-endian integer from a stream */
|
498
|
|
- FT_BASE( FT_ULong )
|
|
498
|
+ FT_BASE( FT_UInt32 )
|
499
|
499
|
FT_Stream_ReadULong( FT_Stream stream,
|
500
|
500
|
FT_Error* error );
|
501
|
501
|
|
502
|
502
|
/* read a 16-bit little-endian unsigned integer from a stream */
|
503
|
|
- FT_BASE( FT_UShort )
|
|
503
|
+ FT_BASE( FT_UInt16 )
|
504
|
504
|
FT_Stream_ReadUShortLE( FT_Stream stream,
|
505
|
505
|
FT_Error* error );
|
506
|
506
|
|
507
|
507
|
/* read a 32-bit little-endian unsigned integer from a stream */
|
508
|
|
- FT_BASE( FT_ULong )
|
|
508
|
+ FT_BASE( FT_UInt32 )
|
509
|
509
|
FT_Stream_ReadULongLE( FT_Stream stream,
|
510
|
510
|
FT_Error* error );
|
511
|
511
|
|
src/base/ftstream.c
... |
... |
@@ -363,11 +363,11 @@ |
363
|
363
|
}
|
364
|
364
|
|
365
|
365
|
|
366
|
|
- FT_BASE_DEF( FT_UShort )
|
|
366
|
+ FT_BASE_DEF( FT_UInt16 )
|
367
|
367
|
FT_Stream_GetUShort( FT_Stream stream )
|
368
|
368
|
{
|
369
|
369
|
FT_Byte* p;
|
370
|
|
- FT_UShort result;
|
|
370
|
+ FT_UInt16 result;
|
371
|
371
|
|
372
|
372
|
|
373
|
373
|
FT_ASSERT( stream && stream->cursor );
|
... |
... |
@@ -382,11 +382,11 @@ |
382
|
382
|
}
|
383
|
383
|
|
384
|
384
|
|
385
|
|
- FT_BASE_DEF( FT_UShort )
|
|
385
|
+ FT_BASE_DEF( FT_UInt16 )
|
386
|
386
|
FT_Stream_GetUShortLE( FT_Stream stream )
|
387
|
387
|
{
|
388
|
388
|
FT_Byte* p;
|
389
|
|
- FT_UShort result;
|
|
389
|
+ FT_UInt16 result;
|
390
|
390
|
|
391
|
391
|
|
392
|
392
|
FT_ASSERT( stream && stream->cursor );
|
... |
... |
@@ -401,11 +401,11 @@ |
401
|
401
|
}
|
402
|
402
|
|
403
|
403
|
|
404
|
|
- FT_BASE_DEF( FT_ULong )
|
|
404
|
+ FT_BASE_DEF( FT_UInt32 )
|
405
|
405
|
FT_Stream_GetUOffset( FT_Stream stream )
|
406
|
406
|
{
|
407
|
407
|
FT_Byte* p;
|
408
|
|
- FT_ULong result;
|
|
408
|
+ FT_UInt32 result;
|
409
|
409
|
|
410
|
410
|
|
411
|
411
|
FT_ASSERT( stream && stream->cursor );
|
... |
... |
@@ -419,11 +419,11 @@ |
419
|
419
|
}
|
420
|
420
|
|
421
|
421
|
|
422
|
|
- FT_BASE_DEF( FT_ULong )
|
|
422
|
+ FT_BASE_DEF( FT_UInt32 )
|
423
|
423
|
FT_Stream_GetULong( FT_Stream stream )
|
424
|
424
|
{
|
425
|
425
|
FT_Byte* p;
|
426
|
|
- FT_ULong result;
|
|
426
|
+ FT_UInt32 result;
|
427
|
427
|
|
428
|
428
|
|
429
|
429
|
FT_ASSERT( stream && stream->cursor );
|
... |
... |
@@ -437,11 +437,11 @@ |
437
|
437
|
}
|
438
|
438
|
|
439
|
439
|
|
440
|
|
- FT_BASE_DEF( FT_ULong )
|
|
440
|
+ FT_BASE_DEF( FT_UInt32 )
|
441
|
441
|
FT_Stream_GetULongLE( FT_Stream stream )
|
442
|
442
|
{
|
443
|
443
|
FT_Byte* p;
|
444
|
|
- FT_ULong result;
|
|
444
|
+ FT_UInt32 result;
|
445
|
445
|
|
446
|
446
|
|
447
|
447
|
FT_ASSERT( stream && stream->cursor );
|
... |
... |
@@ -493,13 +493,13 @@ |
493
|
493
|
}
|
494
|
494
|
|
495
|
495
|
|
496
|
|
- FT_BASE_DEF( FT_UShort )
|
|
496
|
+ FT_BASE_DEF( FT_UInt16 )
|
497
|
497
|
FT_Stream_ReadUShort( FT_Stream stream,
|
498
|
498
|
FT_Error* error )
|
499
|
499
|
{
|
500
|
500
|
FT_Byte reads[2];
|
501
|
501
|
FT_Byte* p;
|
502
|
|
- FT_UShort result = 0;
|
|
502
|
+ FT_UInt16 result = 0;
|
503
|
503
|
|
504
|
504
|
|
505
|
505
|
FT_ASSERT( stream );
|
... |
... |
@@ -538,13 +538,13 @@ |
538
|
538
|
}
|
539
|
539
|
|
540
|
540
|
|
541
|
|
- FT_BASE_DEF( FT_UShort )
|
|
541
|
+ FT_BASE_DEF( FT_UInt16 )
|
542
|
542
|
FT_Stream_ReadUShortLE( FT_Stream stream,
|
543
|
543
|
FT_Error* error )
|
544
|
544
|
{
|
545
|
545
|
FT_Byte reads[2];
|
546
|
546
|
FT_Byte* p;
|
547
|
|
- FT_UShort result = 0;
|
|
547
|
+ FT_UInt16 result = 0;
|
548
|
548
|
|
549
|
549
|
|
550
|
550
|
FT_ASSERT( stream );
|
... |
... |
@@ -628,13 +628,13 @@ |
628
|
628
|
}
|
629
|
629
|
|
630
|
630
|
|
631
|
|
- FT_BASE_DEF( FT_ULong )
|
|
631
|
+ FT_BASE_DEF( FT_UInt32 )
|
632
|
632
|
FT_Stream_ReadULong( FT_Stream stream,
|
633
|
633
|
FT_Error* error )
|
634
|
634
|
{
|
635
|
635
|
FT_Byte reads[4];
|
636
|
636
|
FT_Byte* p;
|
637
|
|
- FT_ULong result = 0;
|
|
637
|
+ FT_UInt32 result = 0;
|
638
|
638
|
|
639
|
639
|
|
640
|
640
|
FT_ASSERT( stream );
|
... |
... |
@@ -673,13 +673,13 @@ |
673
|
673
|
}
|
674
|
674
|
|
675
|
675
|
|
676
|
|
- FT_BASE_DEF( FT_ULong )
|
|
676
|
+ FT_BASE_DEF( FT_UInt32 )
|
677
|
677
|
FT_Stream_ReadULongLE( FT_Stream stream,
|
678
|
678
|
FT_Error* error )
|
679
|
679
|
{
|
680
|
680
|
FT_Byte reads[4];
|
681
|
681
|
FT_Byte* p;
|
682
|
|
- FT_ULong result = 0;
|
|
682
|
+ FT_UInt32 result = 0;
|
683
|
683
|
|
684
|
684
|
|
685
|
685
|
FT_ASSERT( stream );
|
src/truetype/ttgload.c
... |
... |
@@ -801,7 +801,7 @@ |
801
|
801
|
FT_UInt start_point,
|
802
|
802
|
FT_UInt start_contour )
|
803
|
803
|
{
|
804
|
|
- zone->n_points = (FT_UShort)load->outline.n_points -
|
|
804
|
+ zone->n_points = (FT_UShort)load->outline.n_points + 4 -
|
805
|
805
|
(FT_UShort)start_point;
|
806
|
806
|
zone->n_contours = load->outline.n_contours -
|
807
|
807
|
(FT_Short)start_contour;
|
... |
... |
@@ -970,11 +970,6 @@ |
970
|
970
|
outline->points[n_points + 2] = loader->pp3;
|
971
|
971
|
outline->points[n_points + 3] = loader->pp4;
|
972
|
972
|
|
973
|
|
- outline->tags[n_points ] = 0;
|
974
|
|
- outline->tags[n_points + 1] = 0;
|
975
|
|
- outline->tags[n_points + 2] = 0;
|
976
|
|
- outline->tags[n_points + 3] = 0;
|
977
|
|
-
|
978
|
973
|
n_points += 4;
|
979
|
974
|
|
980
|
975
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
... |
... |
@@ -987,8 +982,7 @@ |
987
|
982
|
/* Deltas apply to the unscaled data. */
|
988
|
983
|
error = TT_Vary_Apply_Glyph_Deltas( loader,
|
989
|
984
|
outline,
|
990
|
|
- unrounded,
|
991
|
|
- (FT_UInt)n_points );
|
|
985
|
+ unrounded );
|
992
|
986
|
if ( error )
|
993
|
987
|
goto Exit;
|
994
|
988
|
}
|
... |
... |
@@ -1000,7 +994,7 @@ |
1000
|
994
|
tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
|
1001
|
995
|
|
1002
|
996
|
FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
|
1003
|
|
- loader->zone.n_points + 4 );
|
|
997
|
+ loader->zone.n_points );
|
1004
|
998
|
}
|
1005
|
999
|
|
1006
|
1000
|
{
|
... |
... |
@@ -1142,11 +1136,7 @@ |
1142
|
1136
|
}
|
1143
|
1137
|
|
1144
|
1138
|
if ( IS_HINTED( loader->load_flags ) )
|
1145
|
|
- {
|
1146
|
|
- loader->zone.n_points += 4;
|
1147
|
|
-
|
1148
|
1139
|
error = TT_Hint_Glyph( loader, 0 );
|
1149
|
|
- }
|
1150
|
1140
|
|
1151
|
1141
|
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
1152
|
1142
|
Exit:
|
... |
... |
@@ -1359,11 +1349,6 @@ |
1359
|
1349
|
outline->points[outline->n_points + 2] = loader->pp3;
|
1360
|
1350
|
outline->points[outline->n_points + 3] = loader->pp4;
|
1361
|
1351
|
|
1362
|
|
- outline->tags[outline->n_points ] = 0;
|
1363
|
|
- outline->tags[outline->n_points + 1] = 0;
|
1364
|
|
- outline->tags[outline->n_points + 2] = 0;
|
1365
|
|
- outline->tags[outline->n_points + 3] = 0;
|
1366
|
|
-
|
1367
|
1352
|
#ifdef TT_USE_BYTECODE_INTERPRETER
|
1368
|
1353
|
|
1369
|
1354
|
{
|
... |
... |
@@ -1422,11 +1407,9 @@ |
1422
|
1407
|
|
1423
|
1408
|
/* Some points are likely touched during execution of */
|
1424
|
1409
|
/* instructions on components. So let's untouch them. */
|
1425
|
|
- for ( i = 0; i < loader->zone.n_points; i++ )
|
|
1410
|
+ for ( i = 0; i < loader->zone.n_points - 4; i++ )
|
1426
|
1411
|
loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
|
1427
|
1412
|
|
1428
|
|
- loader->zone.n_points += 4;
|
1429
|
|
-
|
1430
|
1413
|
return TT_Hint_Glyph( loader, 1 );
|
1431
|
1414
|
}
|
1432
|
1415
|
|
... |
... |
@@ -1747,47 +1730,29 @@ |
1747
|
1730
|
/* a small outline structure with four elements for */
|
1748
|
1731
|
/* communication with `TT_Vary_Apply_Glyph_Deltas' */
|
1749
|
1732
|
FT_Vector points[4];
|
1750
|
|
- char tags[4] = { 1, 1, 1, 1 };
|
1751
|
|
- short contours[4] = { 0, 1, 2, 3 };
|
1752
|
1733
|
FT_Outline outline;
|
1753
|
1734
|
|
1754
|
1735
|
/* unrounded values */
|
1755
|
1736
|
FT_Vector unrounded[4] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} };
|
1756
|
1737
|
|
1757
|
1738
|
|
1758
|
|
- points[0].x = loader->pp1.x;
|
1759
|
|
- points[0].y = loader->pp1.y;
|
1760
|
|
- points[1].x = loader->pp2.x;
|
1761
|
|
- points[1].y = loader->pp2.y;
|
|
1739
|
+ points[0] = loader->pp1;
|
|
1740
|
+ points[1] = loader->pp2;
|
|
1741
|
+ points[2] = loader->pp3;
|
|
1742
|
+ points[3] = loader->pp4;
|
1762
|
1743
|
|
1763
|
|
- points[2].x = loader->pp3.x;
|
1764
|
|
- points[2].y = loader->pp3.y;
|
1765
|
|
- points[3].x = loader->pp4.x;
|
1766
|
|
- points[3].y = loader->pp4.y;
|
1767
|
|
-
|
1768
|
|
- outline.n_points = 4;
|
1769
|
|
- outline.n_contours = 4;
|
|
1744
|
+ outline.n_points = 0;
|
|
1745
|
+ outline.n_contours = 0;
|
1770
|
1746
|
outline.points = points;
|
1771
|
|
- outline.tags = tags;
|
1772
|
|
- outline.contours = contours;
|
|
1747
|
+ outline.tags = NULL;
|
|
1748
|
+ outline.contours = NULL;
|
1773
|
1749
|
|
1774
|
1750
|
/* this must be done before scaling */
|
1775
|
1751
|
error = TT_Vary_Apply_Glyph_Deltas( loader,
|
1776
|
1752
|
&outline,
|
1777
|
|
- unrounded,
|
1778
|
|
- (FT_UInt)outline.n_points );
|
|
1753
|
+ unrounded );
|
1779
|
1754
|
if ( error )
|
1780
|
1755
|
goto Exit;
|
1781
|
|
-
|
1782
|
|
- loader->pp1.x = points[0].x;
|
1783
|
|
- loader->pp1.y = points[0].y;
|
1784
|
|
- loader->pp2.x = points[1].x;
|
1785
|
|
- loader->pp2.y = points[1].y;
|
1786
|
|
-
|
1787
|
|
- loader->pp3.x = points[2].x;
|
1788
|
|
- loader->pp3.y = points[2].y;
|
1789
|
|
- loader->pp4.x = points[3].x;
|
1790
|
|
- loader->pp4.y = points[3].y;
|
1791
|
1756
|
}
|
1792
|
1757
|
|
1793
|
1758
|
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
|
... |
... |
@@ -1935,17 +1900,16 @@ |
1935
|
1900
|
|
1936
|
1901
|
/* construct an outline structure for */
|
1937
|
1902
|
/* communication with `TT_Vary_Apply_Glyph_Deltas' */
|
1938
|
|
- outline.n_points = (short)( gloader->current.num_subglyphs + 4 );
|
1939
|
|
- outline.n_contours = outline.n_points;
|
|
1903
|
+ outline.n_contours = outline.n_points = limit;
|
1940
|
1904
|
|
1941
|
1905
|
outline.points = NULL;
|
1942
|
1906
|
outline.tags = NULL;
|
1943
|
1907
|
outline.contours = NULL;
|
1944
|
1908
|
|
1945
|
|
- if ( FT_NEW_ARRAY( points, outline.n_points ) ||
|
1946
|
|
- FT_NEW_ARRAY( tags, outline.n_points ) ||
|
1947
|
|
- FT_NEW_ARRAY( contours, outline.n_points ) ||
|
1948
|
|
- FT_NEW_ARRAY( unrounded, outline.n_points ) )
|
|
1909
|
+ if ( FT_NEW_ARRAY( points, limit + 4 ) ||
|
|
1910
|
+ FT_NEW_ARRAY( tags, limit + 4 ) ||
|
|
1911
|
+ FT_NEW_ARRAY( contours, limit + 4 ) ||
|
|
1912
|
+ FT_NEW_ARRAY( unrounded, limit + 4 ) )
|
1949
|
1913
|
goto Exit1;
|
1950
|
1914
|
|
1951
|
1915
|
subglyph = gloader->current.subglyphs;
|
... |
... |
@@ -1961,28 +1925,10 @@ |
1961
|
1925
|
contours[i] = i;
|
1962
|
1926
|
}
|
1963
|
1927
|
|
1964
|
|
- points[i].x = loader->pp1.x;
|
1965
|
|
- points[i].y = loader->pp1.y;
|
1966
|
|
- tags[i] = 1;
|
1967
|
|
- contours[i] = i;
|
1968
|
|
-
|
1969
|
|
- i++;
|
1970
|
|
- points[i].x = loader->pp2.x;
|
1971
|
|
- points[i].y = loader->pp2.y;
|
1972
|
|
- tags[i] = 1;
|
1973
|
|
- contours[i] = i;
|
1974
|
|
-
|
1975
|
|
- i++;
|
1976
|
|
- points[i].x = loader->pp3.x;
|
1977
|
|
- points[i].y = loader->pp3.y;
|
1978
|
|
- tags[i] = 1;
|
1979
|
|
- contours[i] = i;
|
1980
|
|
-
|
1981
|
|
- i++;
|
1982
|
|
- points[i].x = loader->pp4.x;
|
1983
|
|
- points[i].y = loader->pp4.y;
|
1984
|
|
- tags[i] = 1;
|
1985
|
|
- contours[i] = i;
|
|
1928
|
+ points[i++] = loader->pp1;
|
|
1929
|
+ points[i++] = loader->pp2;
|
|
1930
|
+ points[i++] = loader->pp3;
|
|
1931
|
+ points[i ] = loader->pp4;
|
1986
|
1932
|
|
1987
|
1933
|
outline.points = points;
|
1988
|
1934
|
outline.tags = tags;
|
... |
... |
@@ -1990,11 +1936,9 @@ |
1990
|
1936
|
|
1991
|
1937
|
/* this call provides additional offsets */
|
1992
|
1938
|
/* for each component's translation */
|
1993
|
|
- if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas(
|
1994
|
|
- loader,
|
1995
|
|
- &outline,
|
1996
|
|
- unrounded,
|
1997
|
|
- (FT_UInt)outline.n_points ) ) )
|
|
1939
|
+ if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas( loader,
|
|
1940
|
+ &outline,
|
|
1941
|
+ unrounded ) ) )
|
1998
|
1942
|
goto Exit1;
|
1999
|
1943
|
|
2000
|
1944
|
subglyph = gloader->current.subglyphs;
|
... |
... |
@@ -2008,16 +1952,6 @@ |
2008
|
1952
|
}
|
2009
|
1953
|
}
|
2010
|
1954
|
|
2011
|
|
- loader->pp1.x = points[i + 0].x;
|
2012
|
|
- loader->pp1.y = points[i + 0].y;
|
2013
|
|
- loader->pp2.x = points[i + 1].x;
|
2014
|
|
- loader->pp2.y = points[i + 1].y;
|
2015
|
|
-
|
2016
|
|
- loader->pp3.x = points[i + 2].x;
|
2017
|
|
- loader->pp3.y = points[i + 2].y;
|
2018
|
|
- loader->pp4.x = points[i + 3].x;
|
2019
|
|
- loader->pp4.y = points[i + 3].y;
|
2020
|
|
-
|
2021
|
1955
|
Exit1:
|
2022
|
1956
|
FT_FREE( outline.points );
|
2023
|
1957
|
FT_FREE( outline.tags );
|
src/truetype/ttgxvar.c
... |
... |
@@ -3839,25 +3839,20 @@ |
3839
|
3839
|
* An array with `n_points' elements that is filled with unrounded
|
3840
|
3840
|
* point coordinates (in 26.6 format).
|
3841
|
3841
|
*
|
3842
|
|
- * @Input
|
3843
|
|
- * n_points ::
|
3844
|
|
- * The number of the points in the glyph, including
|
3845
|
|
- * phantom points.
|
3846
|
|
- *
|
3847
|
3842
|
* @Return:
|
3848
|
3843
|
* FreeType error code. 0 means success.
|
3849
|
3844
|
*/
|
3850
|
3845
|
FT_LOCAL_DEF( FT_Error )
|
3851
|
3846
|
TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
|
3852
|
3847
|
FT_Outline* outline,
|
3853
|
|
- FT_Vector* unrounded,
|
3854
|
|
- FT_UInt n_points )
|
|
3848
|
+ FT_Vector* unrounded )
|
3855
|
3849
|
{
|
3856
|
3850
|
FT_Error error;
|
3857
|
3851
|
TT_Face face = loader->face;
|
3858
|
3852
|
FT_Stream stream = face->root.stream;
|
3859
|
3853
|
FT_Memory memory = stream->memory;
|
3860
|
3854
|
FT_UInt glyph_index = loader->glyph_index;
|
|
3855
|
+ FT_UInt n_points = (FT_UInt)outline->n_points + 4;
|
3861
|
3856
|
|
3862
|
3857
|
FT_Vector* points_org = NULL; /* coordinates in 16.16 format */
|
3863
|
3858
|
FT_Vector* points_out = NULL; /* coordinates in 16.16 format */
|
... |
... |
@@ -4075,36 +4070,8 @@ |
4075
|
4070
|
FT_Fixed point_delta_y = FT_MulFix( deltas_y[j], apply );
|
4076
|
4071
|
|
4077
|
4072
|
|
4078
|
|
- if ( j < n_points - 4 )
|
4079
|
|
- {
|
4080
|
|
- point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
4081
|
|
- point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
4082
|
|
- }
|
4083
|
|
- else
|
4084
|
|
- {
|
4085
|
|
- /* To avoid double adjustment of advance width or height, */
|
4086
|
|
- /* adjust phantom points only if there is no HVAR or VVAR */
|
4087
|
|
- /* support, respectively. */
|
4088
|
|
- if ( j == ( n_points - 4 ) &&
|
4089
|
|
- !( face->variation_support &
|
4090
|
|
- TT_FACE_FLAG_VAR_LSB ) )
|
4091
|
|
- point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
4092
|
|
-
|
4093
|
|
- else if ( j == ( n_points - 3 ) &&
|
4094
|
|
- !( face->variation_support &
|
4095
|
|
- TT_FACE_FLAG_VAR_HADVANCE ) )
|
4096
|
|
- point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
4097
|
|
-
|
4098
|
|
- else if ( j == ( n_points - 2 ) &&
|
4099
|
|
- !( face->variation_support &
|
4100
|
|
- TT_FACE_FLAG_VAR_TSB ) )
|
4101
|
|
- point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
4102
|
|
-
|
4103
|
|
- else if ( j == ( n_points - 1 ) &&
|
4104
|
|
- !( face->variation_support &
|
4105
|
|
- TT_FACE_FLAG_VAR_VADVANCE ) )
|
4106
|
|
- point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
4107
|
|
- }
|
|
4073
|
+ point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
|
4074
|
+ point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
4108
|
4075
|
|
4109
|
4076
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
4110
|
4077
|
if ( point_delta_x || point_delta_y )
|
... |
... |
@@ -4177,36 +4144,8 @@ |
4177
|
4144
|
FT_Pos point_delta_y = points_out[j].y - points_org[j].y;
|
4178
|
4145
|
|
4179
|
4146
|
|
4180
|
|
- if ( j < n_points - 4 )
|
4181
|
|
- {
|
4182
|
|
- point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
4183
|
|
- point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
4184
|
|
- }
|
4185
|
|
- else
|
4186
|
|
- {
|
4187
|
|
- /* To avoid double adjustment of advance width or height, */
|
4188
|
|
- /* adjust phantom points only if there is no HVAR or VVAR */
|
4189
|
|
- /* support, respectively. */
|
4190
|
|
- if ( j == ( n_points - 4 ) &&
|
4191
|
|
- !( face->variation_support &
|
4192
|
|
- TT_FACE_FLAG_VAR_LSB ) )
|
4193
|
|
- point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
4194
|
|
-
|
4195
|
|
- else if ( j == ( n_points - 3 ) &&
|
4196
|
|
- !( face->variation_support &
|
4197
|
|
- TT_FACE_FLAG_VAR_HADVANCE ) )
|
4198
|
|
- point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
4199
|
|
-
|
4200
|
|
- else if ( j == ( n_points - 2 ) &&
|
4201
|
|
- !( face->variation_support &
|
4202
|
|
- TT_FACE_FLAG_VAR_TSB ) )
|
4203
|
|
- point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
4204
|
|
-
|
4205
|
|
- else if ( j == ( n_points - 1 ) &&
|
4206
|
|
- !( face->variation_support &
|
4207
|
|
- TT_FACE_FLAG_VAR_VADVANCE ) )
|
4208
|
|
- point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
4209
|
|
- }
|
|
4147
|
+ point_deltas_x[j] = old_point_delta_x + point_delta_x;
|
|
4148
|
+ point_deltas_y[j] = old_point_delta_y + point_delta_y;
|
4210
|
4149
|
|
4211
|
4150
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
4212
|
4151
|
if ( point_delta_x || point_delta_y )
|
... |
... |
@@ -4244,6 +4183,24 @@ |
4244
|
4183
|
|
4245
|
4184
|
FT_TRACE5(( "\n" ));
|
4246
|
4185
|
|
|
4186
|
+ /* To avoid double adjustment of advance width or height, */
|
|
4187
|
+ /* do not move phantom points if there is HVAR or VVAR */
|
|
4188
|
+ /* support, respectively. */
|
|
4189
|
+ if ( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE )
|
|
4190
|
+ {
|
|
4191
|
+ point_deltas_x[n_points - 4] = 0;
|
|
4192
|
+ point_deltas_y[n_points - 4] = 0;
|
|
4193
|
+ point_deltas_x[n_points - 3] = 0;
|
|
4194
|
+ point_deltas_y[n_points - 3] = 0;
|
|
4195
|
+ }
|
|
4196
|
+ if ( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE )
|
|
4197
|
+ {
|
|
4198
|
+ point_deltas_x[n_points - 2] = 0;
|
|
4199
|
+ point_deltas_y[n_points - 2] = 0;
|
|
4200
|
+ point_deltas_x[n_points - 1] = 0;
|
|
4201
|
+ point_deltas_y[n_points - 1] = 0;
|
|
4202
|
+ }
|
|
4203
|
+
|
4247
|
4204
|
for ( i = 0; i < n_points; i++ )
|
4248
|
4205
|
{
|
4249
|
4206
|
unrounded[i].x += FT_fixedToFdot6( point_deltas_x[i] );
|
... |
... |
@@ -4253,14 +4210,23 @@ |
4253
|
4210
|
outline->points[i].y += FT_fixedToInt( point_deltas_y[i] );
|
4254
|
4211
|
}
|
4255
|
4212
|
|
4256
|
|
- /* recalculate linear horizontal and vertical advances */
|
4257
|
|
- /* if we don't have HVAR and VVAR, respectively */
|
|
4213
|
+ /* To avoid double adjustment of advance width or height, */
|
|
4214
|
+ /* adjust phantom points only if there is no HVAR or VVAR */
|
|
4215
|
+ /* support, respectively. */
|
4258
|
4216
|
if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
|
|
4217
|
+ {
|
|
4218
|
+ loader->pp1 = outline->points[n_points - 4];
|
|
4219
|
+ loader->pp2 = outline->points[n_points - 3];
|
4259
|
4220
|
loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x -
|
4260
|
4221
|
unrounded[n_points - 4].x ) / 64;
|
|
4222
|
+ }
|
4261
|
4223
|
if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
|
|
4224
|
+ {
|
|
4225
|
+ loader->pp3 = outline->points[n_points - 2];
|
|
4226
|
+ loader->pp4 = outline->points[n_points - 1];
|
4262
|
4227
|
loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].y -
|
4263
|
4228
|
unrounded[n_points - 2].y ) / 64;
|
|
4229
|
+ }
|
4264
|
4230
|
|
4265
|
4231
|
Fail3:
|
4266
|
4232
|
FT_FREE( point_deltas_x );
|
src/truetype/ttgxvar.h
... |
... |
@@ -363,8 +363,7 @@ FT_BEGIN_HEADER |
363
|
363
|
FT_LOCAL( FT_Error )
|
364
|
364
|
TT_Vary_Apply_Glyph_Deltas( TT_Loader loader,
|
365
|
365
|
FT_Outline* outline,
|
366
|
|
- FT_Vector* unrounded,
|
367
|
|
- FT_UInt n_points );
|
|
366
|
+ FT_Vector* unrounded );
|
368
|
367
|
|
369
|
368
|
FT_LOCAL( FT_Error )
|
370
|
369
|
tt_hadvance_adjust( TT_Face face,
|
|