Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freetype: Update to version 2.13.2 #81110

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ License: OFL-1.1

Files: ./thirdparty/freetype/
Comment: The FreeType Project
Copyright: 1996-2022, David Turner, Robert Wilhelm, and Werner Lemberg.
Copyright: 1996-2023, David Turner, Robert Wilhelm, and Werner Lemberg.
License: FTL

Files: ./thirdparty/glad/
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ Files extracted from upstream source:
## freetype

- Upstream: https://www.freetype.org
- Version: 2.13.1 (e4586d960f339cf75e2e0b34aee30a0ed8353c0d, 2023)
- Version: 2.13.2 (920c5502cc3ddda88f6c7d85ee834ac611bb11cc, 2023)
- License: FreeType License (BSD-like)

Files extracted from upstream source:

- `src/` folder, minus the `dlg` and `tools` subfolders
* These files can be removed: `.dat`, `.diff`, `.mk`, `.rc`, `README*`
* In `src/gzip/`, remove zlib files (everything but `ftgzip.c` and `ftzconf.h`)
* In `src/gzip/`, keep only `ftgzip.c`
- `include/` folder, minus the `dlg` subfolder
- `LICENSE.TXT` and `docs/FTL.TXT`

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/freetype/include/freetype/freetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -5222,7 +5222,7 @@ FT_BEGIN_HEADER
*/
#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 13
#define FREETYPE_PATCH 1
#define FREETYPE_PATCH 2


/**************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/freetype/include/freetype/internal/ftcalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ FT_BEGIN_HEADER
* Based on geometric considerations we use the following inequality to
* identify a degenerate matrix.
*
* 50 * abs(xx*yy - xy*yx) < xx^2 + xy^2 + yx^2 + yy^2
* 32 * abs(xx*yy - xy*yx) < xx^2 + xy^2 + yx^2 + yy^2
*
* Value 50 is heuristic.
* Value 32 is heuristic.
*/
FT_BASE( FT_Bool )
FT_Matrix_Check( const FT_Matrix* matrix );
Expand Down
15 changes: 0 additions & 15 deletions thirdparty/freetype/include/freetype/internal/tttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1394,14 +1394,6 @@ FT_BEGIN_HEADER
* vert_metrics_offset ::
* The file offset of the 'vmtx' table.
*
* sph_found_func_flags ::
* Flags identifying special bytecode functions (used by the v38
* implementation of the bytecode interpreter).
*
* sph_compatibility_mode ::
* This flag is set if we are in ClearType backward compatibility mode
* (used by the v38 implementation of the bytecode interpreter).
*
* ebdt_start ::
* The file offset of the sbit data table (CBDT, bdat, etc.).
*
Expand Down Expand Up @@ -1597,13 +1589,6 @@ FT_BEGIN_HEADER
FT_ULong horz_metrics_offset;
FT_ULong vert_metrics_offset;

#ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* since 2.4.12 */
FT_ULong sph_found_func_flags; /* special functions found */
/* for this face */
FT_Bool sph_compatibility_mode;
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */

#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* since 2.7 */
FT_ULong ebdt_start; /* either `CBDT', `EBDT', or `bdat' */
Expand Down
6 changes: 3 additions & 3 deletions thirdparty/freetype/src/autofit/afcjk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@

stem_edge->pos = base_edge->pos + fitted_width;

FT_TRACE5(( " CJKLINK: edge %ld @%d (opos=%.2f) linked to %.2f,"
FT_TRACE5(( " CJKLINK: edge %td @%d (opos=%.2f) linked to %.2f,"
" dist was %.2f, now %.2f\n",
stem_edge - hints->axis[dim].edges, stem_edge->fpos,
(double)stem_edge->opos / 64,
Expand Down Expand Up @@ -1858,7 +1858,7 @@
continue;

#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " CJKBLUE: edge %ld @%d (opos=%.2f) snapped to %.2f,"
FT_TRACE5(( " CJKBLUE: edge %td @%d (opos=%.2f) snapped to %.2f,"
" was %.2f\n",
edge1 - edges, edge1->fpos, (double)edge1->opos / 64,
(double)blue->fit / 64, (double)edge1->pos / 64 ));
Expand Down Expand Up @@ -1922,7 +1922,7 @@
/* this should not happen, but it's better to be safe */
if ( edge2->blue_edge )
{
FT_TRACE5(( "ASSERTION FAILED for edge %ld\n", edge2-edges ));
FT_TRACE5(( "ASSERTION FAILED for edge %td\n", edge2 - edges ));

af_cjk_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
Expand Down
38 changes: 19 additions & 19 deletions thirdparty/freetype/src/autofit/aflatin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@
{
*a = *b;
FT_TRACE5(( "blue zone overlap:"
" adjusting %s %ld to %ld\n",
" adjusting %s %td to %ld\n",
a_is_top ? "overshoot" : "reference",
blue_sorted[i] - axis->blues,
*a ));
Expand Down Expand Up @@ -2960,7 +2960,7 @@

stem_edge->pos = base_edge->pos + fitted_width;

FT_TRACE5(( " LINK: edge %ld (opos=%.2f) linked to %.2f,"
FT_TRACE5(( " LINK: edge %td (opos=%.2f) linked to %.2f,"
" dist was %.2f, now %.2f\n",
stem_edge - hints->axis[dim].edges,
(double)stem_edge->opos / 64, (double)stem_edge->pos / 64,
Expand Down Expand Up @@ -3085,13 +3085,13 @@

#ifdef FT_DEBUG_LEVEL_TRACE
if ( !anchor )
FT_TRACE5(( " BLUE_ANCHOR: edge %ld (opos=%.2f) snapped to %.2f,"
" was %.2f (anchor=edge %ld)\n",
FT_TRACE5(( " BLUE_ANCHOR: edge %td (opos=%.2f) snapped to %.2f,"
" was %.2f (anchor=edge %td)\n",
edge1 - edges,
(double)edge1->opos / 64, (double)blue->fit / 64,
(double)edge1->pos / 64, edge - edges ));
else
FT_TRACE5(( " BLUE: edge %ld (opos=%.2f) snapped to %.2f,"
FT_TRACE5(( " BLUE: edge %td (opos=%.2f) snapped to %.2f,"
" was %.2f\n",
edge1 - edges,
(double)edge1->opos / 64, (double)blue->fit / 64,
Expand Down Expand Up @@ -3141,7 +3141,7 @@
/* this should not happen, but it's better to be safe */
if ( edge2->blue_edge )
{
FT_TRACE5(( " ASSERTION FAILED for edge %ld\n", edge2 - edges ));
FT_TRACE5(( " ASSERTION FAILED for edge %td\n", edge2 - edges ));

af_latin_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
Expand Down Expand Up @@ -3209,7 +3209,7 @@
anchor = edge;
edge->flags |= AF_EDGE_DONE;

FT_TRACE5(( " ANCHOR: edge %ld (opos=%.2f) and %ld (opos=%.2f)"
FT_TRACE5(( " ANCHOR: edge %td (opos=%.2f) and %td (opos=%.2f)"
" snapped to %.2f and %.2f\n",
edge - edges, (double)edge->opos / 64,
edge2 - edges, (double)edge2->opos / 64,
Expand Down Expand Up @@ -3238,7 +3238,7 @@

if ( edge2->flags & AF_EDGE_DONE )
{
FT_TRACE5(( " ADJUST: edge %ld (pos=%.2f) moved to %.2f\n",
FT_TRACE5(( " ADJUST: edge %td (pos=%.2f) moved to %.2f\n",
edge - edges, (double)edge->pos / 64,
(double)( edge2->pos - cur_len ) / 64 ));

Expand Down Expand Up @@ -3279,7 +3279,7 @@
edge->pos = cur_pos1 - cur_len / 2;
edge2->pos = cur_pos1 + cur_len / 2;

FT_TRACE5(( " STEM: edge %ld (opos=%.2f) linked to %ld (opos=%.2f)"
FT_TRACE5(( " STEM: edge %td (opos=%.2f) linked to %td (opos=%.2f)"
" snapped to %.2f and %.2f\n",
edge - edges, (double)edge->opos / 64,
edge2 - edges, (double)edge2->opos / 64,
Expand Down Expand Up @@ -3310,7 +3310,7 @@
edge->pos = ( delta1 < delta2 ) ? cur_pos1 : cur_pos2;
edge2->pos = edge->pos + cur_len;

FT_TRACE5(( " STEM: edge %ld (opos=%.2f) linked to %ld (opos=%.2f)"
FT_TRACE5(( " STEM: edge %td (opos=%.2f) linked to %td (opos=%.2f)"
" snapped to %.2f and %.2f\n",
edge - edges, (double)edge->opos / 64,
edge2 - edges, (double)edge2->opos / 64,
Expand All @@ -3333,7 +3333,7 @@
if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " BOUND: edge %ld (pos=%.2f) moved to %.2f\n",
FT_TRACE5(( " BOUND: edge %td (pos=%.2f) moved to %.2f\n",
edge - edges,
(double)edge->pos / 64,
(double)edge[-1].pos / 64 ));
Expand Down Expand Up @@ -3435,7 +3435,7 @@
if ( delta < 64 + 16 )
{
af_latin_align_serif_edge( hints, edge->serif, edge );
FT_TRACE5(( " SERIF: edge %ld (opos=%.2f) serif to %ld (opos=%.2f)"
FT_TRACE5(( " SERIF: edge %td (opos=%.2f) serif to %td (opos=%.2f)"
" aligned to %.2f\n",
edge - edges, (double)edge->opos / 64,
edge->serif - edges, (double)edge->serif->opos / 64,
Expand All @@ -3445,9 +3445,9 @@
{
edge->pos = FT_PIX_ROUND( edge->opos );
anchor = edge;
FT_TRACE5(( " SERIF_ANCHOR: edge %ld (opos=%.2f)"
FT_TRACE5(( " SERIF_ANCHOR: edge %td (opos=%.2f)"
" snapped to %.2f\n",
edge-edges,
edge - edges,
(double)edge->opos / 64, (double)edge->pos / 64 ));
}
else
Expand All @@ -3474,8 +3474,8 @@
after->pos - before->pos,
after->opos - before->opos );

FT_TRACE5(( " SERIF_LINK1: edge %ld (opos=%.2f) snapped to %.2f"
" from %ld (opos=%.2f)\n",
FT_TRACE5(( " SERIF_LINK1: edge %td (opos=%.2f) snapped to %.2f"
" from %td (opos=%.2f)\n",
edge - edges, (double)edge->opos / 64,
(double)edge->pos / 64,
before - edges, (double)before->opos / 64 ));
Expand All @@ -3484,7 +3484,7 @@
{
edge->pos = anchor->pos +
( ( edge->opos - anchor->opos + 16 ) & ~31 );
FT_TRACE5(( " SERIF_LINK2: edge %ld (opos=%.2f)"
FT_TRACE5(( " SERIF_LINK2: edge %td (opos=%.2f)"
" snapped to %.2f\n",
edge - edges,
(double)edge->opos / 64, (double)edge->pos / 64 ));
Expand All @@ -3505,7 +3505,7 @@
if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " BOUND: edge %ld (pos=%.2f) moved to %.2f\n",
FT_TRACE5(( " BOUND: edge %td (pos=%.2f) moved to %.2f\n",
edge - edges,
(double)edge->pos / 64,
(double)edge[-1].pos / 64 ));
Expand All @@ -3526,7 +3526,7 @@
if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " BOUND: edge %ld (pos=%.2f) moved to %.2f\n",
FT_TRACE5(( " BOUND: edge %td (pos=%.2f) moved to %.2f\n",
edge - edges,
(double)edge->pos / 64,
(double)edge[1].pos / 64 ));
Expand Down
82 changes: 27 additions & 55 deletions thirdparty/freetype/src/base/ftcalc.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,65 +749,43 @@
FT_BASE_DEF( FT_Bool )
FT_Matrix_Check( const FT_Matrix* matrix )
{
FT_Matrix m;
FT_Fixed val[4];
FT_Fixed nonzero_minval, maxval;
FT_Fixed temp1, temp2;
FT_UInt i;
FT_Fixed xx, xy, yx, yy;
FT_Fixed val;
FT_Int shift;
FT_ULong temp1, temp2;


if ( !matrix )
return 0;

val[0] = FT_ABS( matrix->xx );
val[1] = FT_ABS( matrix->xy );
val[2] = FT_ABS( matrix->yx );
val[3] = FT_ABS( matrix->yy );
xx = matrix->xx;
xy = matrix->xy;
yx = matrix->yx;
yy = matrix->yy;
val = FT_ABS( xx ) | FT_ABS( xy ) | FT_ABS( yx ) | FT_ABS( yy );

/*
* To avoid overflow, we ensure that each value is not larger than
*
* int(sqrt(2^31 / 4)) = 23170 ;
*
* we also check that no value becomes zero if we have to scale.
*/

maxval = 0;
nonzero_minval = FT_LONG_MAX;

for ( i = 0; i < 4; i++ )
{
if ( val[i] > maxval )
maxval = val[i];
if ( val[i] && val[i] < nonzero_minval )
nonzero_minval = val[i];
}

/* we only handle 32bit values */
if ( maxval > 0x7FFFFFFFL )
/* we only handle non-zero 32-bit values */
if ( !val || val > 0x7FFFFFFFL )
return 0;

if ( maxval > 23170 )
{
FT_Fixed scale = FT_DivFix( maxval, 23170 );

/* Scale matrix to avoid the temp1 overflow, which is */
/* more stringent than avoiding the temp2 overflow. */

if ( !FT_DivFix( nonzero_minval, scale ) )
return 0; /* value range too large */
shift = FT_MSB( val ) - 12;

m.xx = FT_DivFix( matrix->xx, scale );
m.xy = FT_DivFix( matrix->xy, scale );
m.yx = FT_DivFix( matrix->yx, scale );
m.yy = FT_DivFix( matrix->yy, scale );
if ( shift > 0 )
{
xx >>= shift;
xy >>= shift;
yx >>= shift;
yy >>= shift;
}
else
m = *matrix;

temp1 = FT_ABS( m.xx * m.yy - m.xy * m.yx );
temp2 = m.xx * m.xx + m.xy * m.xy + m.yx * m.yx + m.yy * m.yy;
temp1 = 32U * (FT_ULong)FT_ABS( xx * yy - xy * yx );
temp2 = (FT_ULong)( xx * xx ) + (FT_ULong)( xy * xy ) +
(FT_ULong)( yx * yx ) + (FT_ULong)( yy * yy );

if ( temp1 == 0 ||
temp2 / temp1 > 50 )
if ( temp1 <= temp2 )
return 0;

return 1;
Expand Down Expand Up @@ -1092,9 +1070,6 @@
{
FT_UInt i;
FT_Int64 temp;
#ifndef FT_INT64
FT_Int64 halfUnit;
#endif


#ifdef FT_INT64
Expand Down Expand Up @@ -1139,13 +1114,10 @@
FT_Add64( &temp, &multResult, &temp );
}

/* Round value. */
halfUnit.hi = 0;
halfUnit.lo = 0x8000;
FT_Add64( &temp, &halfUnit, &temp );
/* Shift and round value. */
return (FT_Int32)( ( ( temp.hi << 16 ) | ( temp.lo >> 16 ) )
+ ( 1 & ( temp.lo >> 15 ) ) );

return (FT_Int32)( ( (FT_Int32)( temp.hi & 0xFFFF ) << 16 ) |
( temp.lo >> 16 ) );

#endif /* !FT_INT64 */

Expand Down
3 changes: 2 additions & 1 deletion thirdparty/freetype/src/base/ftobjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,8 @@
FT_Memory memory = library->memory;


args.flags = 0;
args.driver = NULL;
args.flags = 0;

if ( driver_name )
{
Expand Down
8 changes: 6 additions & 2 deletions thirdparty/freetype/src/base/ftstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@
if ( read_bytes > count )
read_bytes = count;

FT_MEM_COPY( buffer, stream->base + pos, read_bytes );
/* Allow "reading" zero bytes without UB even if buffer is NULL */
if ( count )
FT_MEM_COPY( buffer, stream->base + pos, read_bytes );
}

stream->pos = pos + read_bytes;
Expand Down Expand Up @@ -178,7 +180,9 @@
if ( read_bytes > count )
read_bytes = count;

FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes );
/* Allow "reading" zero bytes without UB even if buffer is NULL */
if ( count )
FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes );
}

stream->pos += read_bytes;
Expand Down
Loading