comparison libass/ass_bitmap.c @ 26035:501ea0b13962

Check glyph bounding box before rasterizing and complain if it is too large.
author eugeni
date Fri, 22 Feb 2008 19:31:53 +0000
parents 71b3e04d0555
children 0f892cd714b2
comparison
equal deleted inserted replaced
26034:e8289d9a4fec 26035:501ea0b13962
148 dst->top = src->top; 148 dst->top = src->top;
149 memcpy(dst->buffer, src->buffer, src->w * src->h); 149 memcpy(dst->buffer, src->buffer, src->w * src->h);
150 return dst; 150 return dst;
151 } 151 }
152 152
153 static int check_glyph_area(FT_Glyph glyph)
154 {
155 FT_BBox bbox;
156 long long dx, dy;
157 FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_TRUNCATE, &bbox);
158 dx = bbox.xMax - bbox.xMin;
159 dy = bbox.yMax - bbox.yMin;
160 if (dx * dy > 8000000) {
161 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_GlyphBBoxTooLarge, (int)dx, (int)dy);
162 return 1;
163 } else
164 return 0;
165 }
166
153 static bitmap_t* glyph_to_bitmap_internal(FT_Glyph glyph, int bord) 167 static bitmap_t* glyph_to_bitmap_internal(FT_Glyph glyph, int bord)
154 { 168 {
155 FT_BitmapGlyph bg; 169 FT_BitmapGlyph bg;
156 FT_Bitmap* bit; 170 FT_Bitmap* bit;
157 bitmap_t* bm; 171 bitmap_t* bm;
159 unsigned char* src; 173 unsigned char* src;
160 unsigned char* dst; 174 unsigned char* dst;
161 int i; 175 int i;
162 int error; 176 int error;
163 177
178 if (check_glyph_area(glyph))
179 return 0;
164 error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 0); 180 error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 0);
165 if (error) { 181 if (error) {
166 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FT_Glyph_To_BitmapError, error); 182 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FT_Glyph_To_BitmapError, error);
167 return 0; 183 return 0;
168 } 184 }