From 427b176893c0d7770d9e712eff688472288d4242 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Thu, 21 Nov 2013 13:10:56 +0100 Subject: [PATCH] [truetype] Improve handling of buggy embedded bitmap strikes. We are now able to successfully load `AppleMyoungJo.ttf'. Problem reported by Hin-Tak Leung . * src/sfnt/ttsbit.c (tt_sbit_decoder_load_bitmap): Don't trust glyph format. --- ChangeLog | 10 ++++++++++ src/sfnt/ttsbit.c | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d58c429a4..6f1db9f5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2013-11-21 Werner Lemberg + + [truetype] Improve handling of buggy embedded bitmap strikes. + + We are now able to successfully load `AppleMyoungJo.ttf'. + Problem reported by Hin-Tak Leung . + + * src/sfnt/ttsbit.c (tt_sbit_decoder_load_bitmap): Don't trust glyph + format. + 2013-11-20 Werner Lemberg [truetype] Don't trust `maxp's `maxSizeOfInstructions'. diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index 8258f79de..1ec5aef39 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -969,7 +969,22 @@ case 2: case 5: case 7: - loader = tt_sbit_decoder_load_bit_aligned; + { + /* Don't trust `glyph_format'. For example, Apple's main Korean */ + /* system font, `AppleMyungJo.ttf' (version 7.0d2e6), uses glyph */ + /* format 7, but the data is format 6. We check whether we have */ + /* an excessive number of bytes in the image: If it is equal to */ + /* the value for a byte-aligned glyph, use the other loading */ + /* routine. */ + FT_UInt width = decoder->metrics->width; + FT_UInt height= decoder->metrics->width; + + + if ( height * ( ( width + 7 ) >> 3 ) == (FT_UInt)( p_limit - p ) ) + loader = tt_sbit_decoder_load_byte_aligned; + else + loader = tt_sbit_decoder_load_bit_aligned; + } break; case 8: