diff options
author | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-02-22 19:31:53 +0000 |
---|---|---|
committer | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2008-02-22 19:31:53 +0000 |
commit | caf7e86eef8df95434798dec9b675da68fbef1ff (patch) | |
tree | 71253027645841417e2ee5abd97fa98111cb940a /libass/ass_bitmap.c | |
parent | 25e97ce713229319b404b52b4f70c67287a27c4a (diff) | |
download | libass-caf7e86eef8df95434798dec9b675da68fbef1ff.tar.bz2 libass-caf7e86eef8df95434798dec9b675da68fbef1ff.tar.xz |
Check glyph bounding box before rasterizing and complain if it is too large.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26067 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass/ass_bitmap.c')
-rw-r--r-- | libass/ass_bitmap.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index 8aa1fe7..f84b453 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -150,6 +150,20 @@ static bitmap_t* copy_bitmap(const bitmap_t* src) return dst; } +static int check_glyph_area(FT_Glyph glyph) +{ + FT_BBox bbox; + long long dx, dy; + FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_TRUNCATE, &bbox); + dx = bbox.xMax - bbox.xMin; + dy = bbox.yMax - bbox.yMin; + if (dx * dy > 8000000) { + mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_GlyphBBoxTooLarge, (int)dx, (int)dy); + return 1; + } else + return 0; +} + static bitmap_t* glyph_to_bitmap_internal(FT_Glyph glyph, int bord) { FT_BitmapGlyph bg; @@ -161,6 +175,8 @@ static bitmap_t* glyph_to_bitmap_internal(FT_Glyph glyph, int bord) int i; int error; + if (check_glyph_area(glyph)) + return 0; error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 0); if (error) { mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FT_Glyph_To_BitmapError, error); |