summaryrefslogtreecommitdiff
path: root/src/sfnt/sfwoff2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sfnt/sfwoff2.c')
-rw-r--r--src/sfnt/sfwoff2.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/sfnt/sfwoff2.c b/src/sfnt/sfwoff2.c
index a599ae505..6e2ff040f 100644
--- a/src/sfnt/sfwoff2.c
+++ b/src/sfnt/sfwoff2.c
@@ -2092,7 +2092,22 @@
/* This is what we normally expect. */
/* Initially trust `totalSfntSize' and change later as required. */
if ( woff2.totalSfntSize > sfnt_size )
- sfnt_size = woff2.totalSfntSize;
+ {
+ /* However, adjust the value to something reasonable. */
+
+ /* Factor 64 is heuristic. */
+ if ( ( woff2.totalSfntSize >> 6 ) > sfnt_size )
+ sfnt_size <<= 6;
+ else
+ sfnt_size = woff2.totalSfntSize;
+
+ /* Value 1<<26 = 67108864 is heuristic. */
+ if (sfnt_size >= (1 << 26))
+ sfnt_size = 1 << 26;
+
+ FT_TRACE4(( "adjusting estimate of uncompressed font size to %lu\n",
+ sfnt_size ));
+ }
/* Write sfnt header. */
if ( FT_ALLOC( sfnt, sfnt_size ) ||