From d3f77e4433435b9770afc3a615e22b7ac219867c Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 22 Dec 2021 10:25:52 +0000 Subject: [PATCH] add a sniffer for TTF since TTF files can be caught by the almost unfixably overgenerous TGA sniffer see https://github.com/libvips/php-vips/issues/127 --- ChangeLog | 1 + libvips/foreign/magick.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 85e15346..6c7b1130 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ - fix a crash with 0 length vectors - change default frame delay for GIFs from 1s to 0.1s - remove stray trailing comma from iiif3 dirnames [whalehub] +- fix TTF load [chregu] 21/11/21 started 8.12.1 - fix insert [chregu] diff --git a/libvips/foreign/magick.c b/libvips/foreign/magick.c index a942d7e7..1866843d 100644 --- a/libvips/foreign/magick.c +++ b/libvips/foreign/magick.c @@ -82,6 +82,14 @@ magick_sniff( const unsigned char *bytes, size_t length ) bytes[3] == 0 ) return( "ICO" ); + if( length >= 5 && + bytes[0] == 0 && + bytes[1] == 1 && + bytes[2] == 0 && + bytes[3] == 0 && + bytes[4] == 0 ) + return( "TTF" ); + if( length >= 18 && (bytes[1] == 0 || bytes[1] == 1) &&