Alexei Podtelezhnikov pushed to branch uwp_ci at FreeType / FreeType
Commits:
-
d7cf931a
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-19T22:48:13-04:00
[truetype, type1] Use FT_DUP to duplicate data.
* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Use concise FT_DUP.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): Ditto.
* src/type1/t1load.c (parse_subrs): Ditto.
-
026fd5d4
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-19T22:54:57-04:00
[cache] Use FT_DUP to duplicate data.
* src/cache/ftcsbits.c (ftc_sbit_copy_bitmap): Use concise FT_MEM_DUP.
-
b25265fe
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-19T22:58:23-04:00
[bdf] Use concise macros.
* src/bdf/bdflib.c (bdf_create_property): Use FT_STRDUP.
(bdf_parse_glyphs_, bdf_parse_start_): Use FT_DUP for brevity.
-
4ccdc9f9
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-20T18:53:57-04:00
[cff] Optimize the blend vector computations.
* src/cff/cffload.c (cff_blend_build_vector): Use FT_MulDiv and skip
multiplying by 1.
-
39f2fbf8
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-20T22:47:14-04:00
* src/truetype/ttgxvar.c (tt_var_get_item_delta): Minor refactoring.
-
347276c1
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-21T13:12:45+00:00
* src/truetype/ttgxvar.c (tt_var_get_item_delta): Align with specs.
-
99be2b31
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-21T18:26:09+00:00
[cff, truetype] Rearrange variation range checks.
This should achieve quicker results for common cases.
* src/cff/cffload.c (cff_blend_build_vector): Rearrange conditionals.
* src/truetype/ttgxvar.c (tt_var_get_item_delta): Ditto.
-
5f131cfd
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-21T16:24:43-04:00
[cff, truetype] Validate variation axes immediately.
Instead of validating variation axes in every access, OpenType specs
suggest that peak = 0 be used to tag invalid ranges. This implements
just that once during loading.
* src/cff/cffload.c (cff_blend_build_vector): Move the range checks...
(cff_vstore_load): ... here.
* src/truetype/ttgxvar.c (tt_var_get_item_delta): Ditto...
(tt_var_load_item_variation_store): ... ditto.
-
42d406ab
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-22T21:08:34-04:00
* include/freetype/internal/ftmemory.h (FT_MEM_DUP): Fix g++ error.
-
a4988736
by Alexei Podtelezhnikov (Алексей Подтележников) at 2024-05-23T03:05:59+00:00
* .gitlab-ci.yml: Disable UWP compilation.
8 changed files:
Changes:
.gitlab-ci.yml
... |
... |
@@ -54,17 +54,7 @@ variables: |
54
|
54
|
# Make sure meson is up to date so we don't need to rebuild the image
|
55
|
55
|
# with each release.
|
56
|
56
|
- pip3 install -U 'meson==0.59.*'
|
57
|
|
- - pip3 install --upgrade certifi
|
58
|
57
|
- pip3 install -U ninja
|
59
|
|
-
|
60
|
|
- # Generate a UWP cross-file in case it's used
|
61
|
|
- - $PSDefaultParameterValues['Out-File:Encoding'] = 'ASCII'
|
62
|
|
- - echo "[binaries]" > uwp-crossfile.meson
|
63
|
|
- - echo "c = 'cl'" >> uwp-crossfile.meson
|
64
|
|
- - echo "strip = ['true']" >> uwp-crossfile.meson
|
65
|
|
- - echo "[built-in options]" >> uwp-crossfile.meson
|
66
|
|
- - echo "c_args = ['-DWINAPI_FAMILY=WINAPI_FAMILY_APP', '-DUNICODE', '-D_WIN32_WINNT=0x0A00', '-we4013']" >> uwp-crossfile.meson
|
67
|
|
- - echo "c_winlibs = ['windowsapp.lib']" >> uwp-crossfile.meson
|
68
|
58
|
script:
|
69
|
59
|
# For some reason, options are separated by newlines instead of spaces,
|
70
|
60
|
# so we have to replace them first.
|
... |
... |
@@ -75,10 +65,12 @@ variables: |
75
|
65
|
# script. Environment variables substitutions is done by PowerShell
|
76
|
66
|
# before calling `cmd.exe`, that's why we use `$env:FOO` instead of
|
77
|
67
|
# `%FOO%`.
|
78
|
|
- - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH $env:VS_UWP &&
|
79
|
|
- meson setup build $env:MESON_ARGS_WINDOWS $env:MESON_ARGS_UWP &&
|
80
|
|
- meson compile --verbose -C build
|
81
|
|
- $env:MESON_WINDOWS_TESTS"
|
|
68
|
+ - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
|
|
69
|
+ meson setup build $env:MESON_ARGS_WINDOWS &&
|
|
70
|
+ meson compile --verbose -C build &&
|
|
71
|
+ meson test -C build &&
|
|
72
|
+ meson test -C build --benchmark"
|
|
73
|
+
|
82
|
74
|
|
83
|
75
|
.build windows msbuild:
|
84
|
76
|
extends: '.build windows common'
|
... |
... |
@@ -106,20 +98,11 @@ windows meson vs2019 amd64: |
106
|
98
|
extends: '.build windows meson'
|
107
|
99
|
variables:
|
108
|
100
|
ARCH: 'amd64'
|
109
|
|
- MESON_WINDOWS_TESTS: '&& meson test -C build && meson test -C build --benchmark'
|
110
|
101
|
|
111
|
102
|
windows meson vs2019 x86:
|
112
|
103
|
extends: '.build windows meson'
|
113
|
104
|
variables:
|
114
|
105
|
ARCH: 'x86'
|
115
|
|
- MESON_WINDOWS_TESTS: '&& meson test -C build && meson test -C build --benchmark'
|
116
|
|
-
|
117
|
|
-windows meson vs2019 amd64 uwp:
|
118
|
|
- extends: '.build windows meson'
|
119
|
|
- variables:
|
120
|
|
- ARCH: 'amd64'
|
121
|
|
- VS_UWP: '-app_platform=UWP'
|
122
|
|
- MESON_ARGS_UWP: '--cross-file uwp-crossfile.meson -Dc_winlibs="windowsapp.lib"'
|
123
|
106
|
|
124
|
107
|
windows msbuild vs2019 amd64:
|
125
|
108
|
extends: '.build windows msbuild'
|
include/freetype/internal/ftmemory.h
... |
... |
@@ -371,8 +371,11 @@ extern "C++" |
371
|
371
|
#define FT_STRDUP( dst, str ) \
|
372
|
372
|
FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) )
|
373
|
373
|
|
374
|
|
-#define FT_MEM_DUP( dst, address, size ) \
|
375
|
|
- (dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error )
|
|
374
|
+#define FT_MEM_DUP( dst, address, size ) \
|
|
375
|
+ FT_ASSIGNP_INNER( dst, ft_mem_dup( memory, \
|
|
376
|
+ (address), \
|
|
377
|
+ (FT_ULong)(size), \
|
|
378
|
+ &error ) )
|
376
|
379
|
|
377
|
380
|
#define FT_DUP( dst, address, size ) \
|
378
|
381
|
FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) )
|
src/bdf/bdflib.c
... |
... |
@@ -864,15 +864,9 @@ |
864
|
864
|
|
865
|
865
|
p = font->user_props + font->nuser_props;
|
866
|
866
|
|
867
|
|
- n = ft_strlen( name ) + 1;
|
868
|
|
- if ( n > FT_LONG_MAX )
|
869
|
|
- return FT_THROW( Invalid_Argument );
|
870
|
|
-
|
871
|
|
- if ( FT_QALLOC( p->name, n ) )
|
|
867
|
+ if ( FT_STRDUP( p->name, name ) )
|
872
|
868
|
goto Exit;
|
873
|
869
|
|
874
|
|
- FT_MEM_COPY( (char *)p->name, name, n );
|
875
|
|
-
|
876
|
870
|
p->format = format;
|
877
|
871
|
p->builtin = 0;
|
878
|
872
|
p->value.atom = NULL; /* nothing is ever stored here */
|
... |
... |
@@ -1442,11 +1436,9 @@ |
1442
|
1436
|
goto Exit;
|
1443
|
1437
|
}
|
1444
|
1438
|
|
1445
|
|
- if ( FT_QALLOC( p->glyph_name, slen + 1 ) )
|
|
1439
|
+ if ( FT_DUP( p->glyph_name, s, slen + 1 ) )
|
1446
|
1440
|
goto Exit;
|
1447
|
1441
|
|
1448
|
|
- FT_MEM_COPY( p->glyph_name, s, slen + 1 );
|
1449
|
|
-
|
1450
|
1442
|
p->flags |= BDF_GLYPH_;
|
1451
|
1443
|
|
1452
|
1444
|
FT_TRACE4(( DBGMSG1, lineno, s ));
|
... |
... |
@@ -2051,9 +2043,8 @@ |
2051
|
2043
|
/* Allowing multiple `FONT' lines (which is invalid) doesn't hurt... */
|
2052
|
2044
|
FT_FREE( p->font->name );
|
2053
|
2045
|
|
2054
|
|
- if ( FT_QALLOC( p->font->name, slen + 1 ) )
|
|
2046
|
+ if ( FT_DUP( p->font->name, s, slen + 1 ) )
|
2055
|
2047
|
goto Exit;
|
2056
|
|
- FT_MEM_COPY( p->font->name, s, slen + 1 );
|
2057
|
2048
|
|
2058
|
2049
|
/* If the font name is an XLFD name, set the spacing to the one in */
|
2059
|
2050
|
/* the font name. If there is no spacing fall back on the default. */
|
src/cache/ftcsbits.c
... |
... |
@@ -53,8 +53,7 @@ |
53
|
53
|
|
54
|
54
|
size = (FT_ULong)pitch * bitmap->rows;
|
55
|
55
|
|
56
|
|
- if ( !FT_QALLOC( sbit->buffer, size ) )
|
57
|
|
- FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );
|
|
56
|
+ FT_MEM_DUP( sbit->buffer, bitmap->buffer, size );
|
58
|
57
|
|
59
|
58
|
return error;
|
60
|
59
|
}
|
src/cff/cffload.c
... |
... |
@@ -1202,17 +1202,21 @@ |
1202
|
1202
|
{
|
1203
|
1203
|
CFF_AxisCoords* axis = ®ion->axisList[j];
|
1204
|
1204
|
|
1205
|
|
- FT_Int16 start14, peak14, end14;
|
|
1205
|
+ FT_Int start, peak, end;
|
1206
|
1206
|
|
1207
|
1207
|
|
1208
|
|
- if ( FT_READ_SHORT( start14 ) ||
|
1209
|
|
- FT_READ_SHORT( peak14 ) ||
|
1210
|
|
- FT_READ_SHORT( end14 ) )
|
|
1208
|
+ if ( FT_READ_SHORT( start ) ||
|
|
1209
|
+ FT_READ_SHORT( peak ) ||
|
|
1210
|
+ FT_READ_SHORT( end ) )
|
1211
|
1211
|
goto Exit;
|
1212
|
1212
|
|
1213
|
|
- axis->startCoord = FT_fdot14ToFixed( start14 );
|
1214
|
|
- axis->peakCoord = FT_fdot14ToFixed( peak14 );
|
1215
|
|
- axis->endCoord = FT_fdot14ToFixed( end14 );
|
|
1213
|
+ /* immediately tag invalid ranges with special peak = 0 */
|
|
1214
|
+ if ( ( start < 0 && end > 0 ) || start > peak || peak > end )
|
|
1215
|
+ peak = 0;
|
|
1216
|
+
|
|
1217
|
+ axis->startCoord = FT_fdot14ToFixed( start );
|
|
1218
|
+ axis->peakCoord = FT_fdot14ToFixed( peak );
|
|
1219
|
+ axis->endCoord = FT_fdot14ToFixed( end );
|
1216
|
1220
|
}
|
1217
|
1221
|
}
|
1218
|
1222
|
|
... |
... |
@@ -1495,44 +1499,31 @@ |
1495
|
1499
|
for ( j = 0; j < lenNDV; j++ )
|
1496
|
1500
|
{
|
1497
|
1501
|
CFF_AxisCoords* axis = &varRegion->axisList[j];
|
1498
|
|
- FT_Fixed axisScalar;
|
1499
|
|
-
|
1500
|
|
-
|
1501
|
|
- /* compute the scalar contribution of this axis; */
|
1502
|
|
- /* ignore invalid ranges */
|
1503
|
|
- if ( axis->startCoord > axis->peakCoord ||
|
1504
|
|
- axis->peakCoord > axis->endCoord )
|
1505
|
|
- axisScalar = FT_FIXED_ONE;
|
1506
|
1502
|
|
1507
|
|
- else if ( axis->startCoord < 0 &&
|
1508
|
|
- axis->endCoord > 0 &&
|
1509
|
|
- axis->peakCoord != 0 )
|
1510
|
|
- axisScalar = FT_FIXED_ONE;
|
1511
|
1503
|
|
1512
|
|
- /* peak of 0 means ignore this axis */
|
1513
|
|
- else if ( axis->peakCoord == 0 )
|
1514
|
|
- axisScalar = FT_FIXED_ONE;
|
|
1504
|
+ /* compute the scalar contribution of this axis */
|
|
1505
|
+ /* with peak of 0 used for invalid axes */
|
|
1506
|
+ if ( axis->peakCoord == NDV[j] ||
|
|
1507
|
+ axis->peakCoord == 0 )
|
|
1508
|
+ continue;
|
1515
|
1509
|
|
1516
|
1510
|
/* ignore this region if coords are out of range */
|
1517
|
|
- else if ( NDV[j] < axis->startCoord ||
|
1518
|
|
- NDV[j] > axis->endCoord )
|
1519
|
|
- axisScalar = 0;
|
1520
|
|
-
|
1521
|
|
- /* calculate a proportional factor */
|
1522
|
|
- else
|
|
1511
|
+ else if ( NDV[j] <= axis->startCoord ||
|
|
1512
|
+ NDV[j] >= axis->endCoord )
|
1523
|
1513
|
{
|
1524
|
|
- if ( NDV[j] == axis->peakCoord )
|
1525
|
|
- axisScalar = FT_FIXED_ONE;
|
1526
|
|
- else if ( NDV[j] < axis->peakCoord )
|
1527
|
|
- axisScalar = FT_DivFix( NDV[j] - axis->startCoord,
|
1528
|
|
- axis->peakCoord - axis->startCoord );
|
1529
|
|
- else
|
1530
|
|
- axisScalar = FT_DivFix( axis->endCoord - NDV[j],
|
1531
|
|
- axis->endCoord - axis->peakCoord );
|
|
1514
|
+ blend->BV[master] = 0;
|
|
1515
|
+ break;
|
1532
|
1516
|
}
|
1533
|
1517
|
|
1534
|
|
- /* take product of all the axis scalars */
|
1535
|
|
- blend->BV[master] = FT_MulFix( blend->BV[master], axisScalar );
|
|
1518
|
+ /* adjust proportionally */
|
|
1519
|
+ else if ( NDV[j] < axis->peakCoord )
|
|
1520
|
+ blend->BV[master] = FT_MulDiv( blend->BV[master],
|
|
1521
|
+ NDV[j] - axis->startCoord,
|
|
1522
|
+ axis->peakCoord - axis->startCoord );
|
|
1523
|
+ else /* NDV[j] > axis->peakCoord ) */
|
|
1524
|
+ blend->BV[master] = FT_MulDiv( blend->BV[master],
|
|
1525
|
+ axis->endCoord - NDV[j],
|
|
1526
|
+ axis->endCoord - axis->peakCoord );
|
1536
|
1527
|
}
|
1537
|
1528
|
|
1538
|
1529
|
FT_TRACE4(( ", %f ",
|
src/truetype/ttgload.c
... |
... |
@@ -418,11 +418,9 @@ |
418
|
418
|
/* and thus allocate the bytecode array size by ourselves */
|
419
|
419
|
if ( n_ins )
|
420
|
420
|
{
|
421
|
|
- if ( FT_QNEW_ARRAY( exec->glyphIns, n_ins ) )
|
|
421
|
+ if ( FT_DUP( exec->glyphIns, p, n_ins ) )
|
422
|
422
|
return error;
|
423
|
423
|
|
424
|
|
- FT_MEM_COPY( exec->glyphIns, p, (FT_Long)n_ins );
|
425
|
|
-
|
426
|
424
|
exec->glyphSize = n_ins;
|
427
|
425
|
}
|
428
|
426
|
}
|
src/truetype/ttgxvar.c
... |
... |
@@ -596,7 +596,7 @@ |
596
|
596
|
|
597
|
597
|
for ( j = 0; j < itemStore->axisCount; j++ )
|
598
|
598
|
{
|
599
|
|
- FT_Short start, peak, end;
|
|
599
|
+ FT_Int start, peak, end;
|
600
|
600
|
|
601
|
601
|
|
602
|
602
|
if ( FT_READ_SHORT( start ) ||
|
... |
... |
@@ -604,6 +604,10 @@ |
604
|
604
|
FT_READ_SHORT( end ) )
|
605
|
605
|
goto Exit;
|
606
|
606
|
|
|
607
|
+ /* immediately tag invalid ranges with special peak = 0 */
|
|
608
|
+ if ( ( start < 0 && end > 0 ) || start > peak || peak > end )
|
|
609
|
+ peak = 0;
|
|
610
|
+
|
607
|
611
|
axisCoords[j].startCoord = FT_fdot14ToFixed( start );
|
608
|
612
|
axisCoords[j].peakCoord = FT_fdot14ToFixed( peak );
|
609
|
613
|
axisCoords[j].endCoord = FT_fdot14ToFixed( end );
|
... |
... |
@@ -1074,43 +1078,32 @@ |
1074
|
1078
|
/* inner loop steps through axes in this region */
|
1075
|
1079
|
for ( j = 0; j < itemStore->axisCount; j++, axis++ )
|
1076
|
1080
|
{
|
1077
|
|
- /* compute the scalar contribution of this axis; */
|
1078
|
|
- /* ignore invalid ranges */
|
1079
|
|
- if ( axis->startCoord > axis->peakCoord ||
|
1080
|
|
- axis->peakCoord > axis->endCoord )
|
1081
|
|
- continue;
|
|
1081
|
+ FT_Fixed ncv = ttface->blend->normalizedcoords[j];
|
1082
|
1082
|
|
1083
|
|
- else if ( axis->startCoord < 0 &&
|
1084
|
|
- axis->endCoord > 0 &&
|
1085
|
|
- axis->peakCoord != 0 )
|
1086
|
|
- continue;
|
1087
|
1083
|
|
1088
|
|
- /* peak of 0 means ignore this axis */
|
1089
|
|
- else if ( axis->peakCoord == 0 )
|
1090
|
|
- continue;
|
1091
|
|
-
|
1092
|
|
- else if ( ttface->blend->normalizedcoords[j] == axis->peakCoord )
|
|
1084
|
+ /* compute the scalar contribution of this axis */
|
|
1085
|
+ /* with peak of 0 used for invalid axes */
|
|
1086
|
+ if ( axis->peakCoord == ncv ||
|
|
1087
|
+ axis->peakCoord == 0 )
|
1093
|
1088
|
continue;
|
1094
|
1089
|
|
1095
|
1090
|
/* ignore this region if coords are out of range */
|
1096
|
|
- else if ( ttface->blend->normalizedcoords[j] <= axis->startCoord ||
|
1097
|
|
- ttface->blend->normalizedcoords[j] >= axis->endCoord )
|
|
1091
|
+ else if ( ncv <= axis->startCoord ||
|
|
1092
|
+ ncv >= axis->endCoord )
|
1098
|
1093
|
{
|
1099
|
1094
|
scalar = 0;
|
1100
|
1095
|
break;
|
1101
|
1096
|
}
|
1102
|
1097
|
|
1103
|
1098
|
/* cumulative product of all the axis scalars */
|
1104
|
|
- else if ( ttface->blend->normalizedcoords[j] < axis->peakCoord )
|
1105
|
|
- scalar =
|
1106
|
|
- FT_MulDiv( scalar,
|
1107
|
|
- ttface->blend->normalizedcoords[j] - axis->startCoord,
|
1108
|
|
- axis->peakCoord - axis->startCoord );
|
1109
|
|
- else
|
1110
|
|
- scalar =
|
1111
|
|
- FT_MulDiv( scalar,
|
1112
|
|
- axis->endCoord - ttface->blend->normalizedcoords[j],
|
1113
|
|
- axis->endCoord - axis->peakCoord );
|
|
1099
|
+ else if ( ncv < axis->peakCoord )
|
|
1100
|
+ scalar = FT_MulDiv( scalar,
|
|
1101
|
+ ncv - axis->startCoord,
|
|
1102
|
+ axis->peakCoord - axis->startCoord );
|
|
1103
|
+ else /* ncv > axis->peakCoord */
|
|
1104
|
+ scalar = FT_MulDiv( scalar,
|
|
1105
|
+ axis->endCoord - ncv,
|
|
1106
|
+ axis->endCoord - axis->peakCoord );
|
1114
|
1107
|
|
1115
|
1108
|
} /* per-axis loop */
|
1116
|
1109
|
|
... |
... |
@@ -2722,9 +2715,8 @@ |
2722
|
2715
|
FT_UInt n;
|
2723
|
2716
|
|
2724
|
2717
|
|
2725
|
|
- if ( FT_ALLOC( mmvar, ttface->blend->mmvar_len ) )
|
|
2718
|
+ if ( FT_DUP( mmvar, ttface->blend->mmvar, ttface->blend->mmvar_len ) )
|
2726
|
2719
|
goto Exit;
|
2727
|
|
- FT_MEM_COPY( mmvar, ttface->blend->mmvar, ttface->blend->mmvar_len );
|
2728
|
2720
|
|
2729
|
2721
|
axis_flags =
|
2730
|
2722
|
(FT_UShort*)( (char*)mmvar + mmvar_size );
|
src/type1/t1load.c
... |
... |
@@ -1877,9 +1877,8 @@ |
1877
|
1877
|
}
|
1878
|
1878
|
|
1879
|
1879
|
/* t1_decrypt() shouldn't write to base -- make temporary copy */
|
1880
|
|
- if ( FT_QALLOC( temp, size ) )
|
|
1880
|
+ if ( FT_DUP( temp, base, size ) )
|
1881
|
1881
|
goto Fail;
|
1882
|
|
- FT_MEM_COPY( temp, base, size );
|
1883
|
1882
|
psaux->t1_decrypt( temp, size, 4330 );
|
1884
|
1883
|
size -= (FT_ULong)t1face->type1.private_dict.lenIV;
|
1885
|
1884
|
error = T1_Add_Table( table,
|
... |
... |
@@ -2091,9 +2090,8 @@ |
2091
|
2090
|
}
|
2092
|
2091
|
|
2093
|
2092
|
/* t1_decrypt() shouldn't write to base -- make temporary copy */
|
2094
|
|
- if ( FT_QALLOC( temp, size ) )
|
|
2093
|
+ if ( FT_DUP( temp, base, size ) )
|
2095
|
2094
|
goto Fail;
|
2096
|
|
- FT_MEM_COPY( temp, base, size );
|
2097
|
2095
|
psaux->t1_decrypt( temp, size, 4330 );
|
2098
|
2096
|
size -= (FT_ULong)t1face->type1.private_dict.lenIV;
|
2099
|
2097
|
error = T1_Add_Table( code_table,
|
|