mirror of
https://gitlab.freedesktop.org/freetype/freetype.git
synced 2026-05-02 02:47:58 +02:00
[base] Adjust rendering limits.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Check width and height directly. Fixes #1390.
This commit is contained in:
parent
d262bd978c
commit
6995a34628
1 changed files with 14 additions and 25 deletions
|
|
@ -385,6 +385,7 @@
|
|||
FT_Pos y_shift = 0;
|
||||
FT_Pos x_left, y_top;
|
||||
FT_Pos width, height, pitch;
|
||||
FT_Bool ret;
|
||||
|
||||
|
||||
if ( slot->format == FT_GLYPH_FORMAT_SVG )
|
||||
|
|
@ -495,6 +496,18 @@
|
|||
width = pbox.xMax - pbox.xMin;
|
||||
height = pbox.yMax - pbox.yMin;
|
||||
|
||||
/* Flag the width or height unsuitable for rendering. */
|
||||
/* The limit is based on the ppem value when available. */
|
||||
/* FT_Renderer modules should check the return value. */
|
||||
ret = FT_BOOL( width >= 0x10000 || height >= 0x10000 ||
|
||||
( slot->face &&
|
||||
( width > 10 * slot->face->size->metrics.x_ppem ||
|
||||
height > 10 * slot->face->size->metrics.y_ppem ) ) );
|
||||
|
||||
if ( ret )
|
||||
FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
|
||||
pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
|
||||
|
||||
switch ( pixel_mode )
|
||||
{
|
||||
case FT_PIXEL_MODE_MONO:
|
||||
|
|
@ -524,31 +537,7 @@
|
|||
bitmap->rows = (unsigned int)height;
|
||||
bitmap->pitch = pitch;
|
||||
|
||||
/* Flag the bounding box size unsuitable for rendering. */
|
||||
/* FT_Renderer modules should check the return value. */
|
||||
/* The limit is based on the ppem value when available. */
|
||||
{
|
||||
FT_Face face = slot->face;
|
||||
FT_Pos xlim = 0x8000;
|
||||
FT_Pos ylim = 0x8000;
|
||||
|
||||
|
||||
if ( face )
|
||||
{
|
||||
xlim = FT_MIN( xlim, 10 * face->size->metrics.x_ppem );
|
||||
ylim = FT_MIN( ylim, 10 * face->size->metrics.y_ppem );
|
||||
}
|
||||
|
||||
if ( pbox.xMin < -xlim || pbox.xMax >= xlim ||
|
||||
pbox.yMin < -ylim || pbox.yMax >= ylim )
|
||||
{
|
||||
FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
|
||||
pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue