summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c')
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c
index 6982c717aba..71db75ae1f5 100644
--- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c
+++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttpload.c
@@ -4,7 +4,7 @@
*
* TrueType-specific tables loader (body).
*
- * Copyright (C) 1996-2022 by
+ * Copyright (C) 1996-2021 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
@@ -498,14 +498,6 @@
}
- FT_COMPARE_DEF( int )
- compare_ppem( const void* a,
- const void* b )
- {
- return **(FT_Byte**)a - **(FT_Byte**)b;
- }
-
-
/**************************************************************************
*
* @Function:
@@ -582,20 +574,19 @@
goto Fail;
}
- if ( FT_QNEW_ARRAY( face->hdmx_records, num_records ) )
+ if ( FT_QNEW_ARRAY( face->hdmx_record_sizes, num_records ) )
goto Fail;
+ /* XXX: We do not check if the records are sorted by ppem */
+ /* and cannot use binary search later. */
for ( nn = 0; nn < num_records; nn++ )
{
if ( p + record_size > limit )
break;
- face->hdmx_records[nn] = p;
- p += record_size;
- }
- /* The records must be already sorted by ppem but it does not */
- /* hurt to make sure so that the binary search works later. */
- ft_qsort( face->hdmx_records, nn, sizeof ( FT_Byte* ), compare_ppem );
+ face->hdmx_record_sizes[nn] = p[0];
+ p += record_size;
+ }
face->hdmx_record_count = nn;
face->hdmx_table_size = table_size;
@@ -620,7 +611,7 @@
FT_Memory memory = stream->memory;
- FT_FREE( face->hdmx_records );
+ FT_FREE( face->hdmx_record_sizes );
FT_FRAME_RELEASE( face->hdmx_table );
}
@@ -628,34 +619,27 @@
/**************************************************************************
*
* Return the advance width table for a given pixel size if it is found
- * in the font's `hdmx' table (if any). The records must be sorted for
- * the binary search to work properly.
+ * in the font's `hdmx' table (if any).
*/
FT_LOCAL_DEF( FT_Byte* )
tt_face_get_device_metrics( TT_Face face,
FT_UInt ppem,
FT_UInt gindex )
{
- FT_UInt min = 0;
- FT_UInt max = face->hdmx_record_count;
- FT_UInt mid;
- FT_Byte* result = NULL;
-
+ FT_UInt nn;
+ FT_Byte* result = NULL;
+ FT_ULong record_size = face->hdmx_record_size;
+ FT_Byte* record = FT_OFFSET( face->hdmx_table, 8 );
- while ( min < max )
- {
- mid = ( min + max ) >> 1;
- if ( face->hdmx_records[mid][0] > ppem )
- max = mid;
- else if ( face->hdmx_records[mid][0] < ppem )
- min = mid + 1;
- else
+ for ( nn = 0; nn < face->hdmx_record_count; nn++ )
+ if ( face->hdmx_record_sizes[nn] == ppem )
{
- result = face->hdmx_records[mid] + 2 + gindex;
+ gindex += 2;
+ if ( gindex < record_size )
+ result = record + nn * record_size + gindex;
break;
}
- }
return result;
}