[base] Maintain overall rendering limits.

Reject rendering of outlines that stretch beyond 32767 pixels from
the origin,  which is further restricted to 10922 horizontal pixels
for LCD rendering with ClearType-like algorithms. 16-bit FT_Span is
one of the reasons to have this limit imposed, fixes #1384.

* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Impose global
rendering limits.
This commit is contained in:
Alexei Podtelezhnikov
2026-01-15 21:09:56 -05:00
parent a9babbcbc0
commit dad4640660

View File

@@ -529,10 +529,22 @@
/* The limit is based on the ppem value when available. */
{
FT_Face face = slot->face;
FT_Pos xlim = face ? 10 * face->size->metrics.x_ppem : 0x8000;
FT_Pos ylim = face ? 10 * face->size->metrics.y_ppem : 0x8000;
FT_Pos xlim = 0x7FFF;
FT_Pos ylim = 0x7FFF;
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
/* should fit 16-bit FT_Span after 3x implosion */
if ( mode == FT_RENDER_MODE_LCD )
xlim = 0x2AAA;
#endif
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 )
{