ttf_font: fix artifacts with large font sizes

This patch is a follow-up fix for "ttf_font: prevent out-of-bounds
access", which produced sporadic single-pixel artifacts with large font
sizes, e.g., with the monospaced font set to 24px in Sculpt.

The artifacts occurred only for some horizontal sub-pixel positions, in
combination with the font cache, and after the rendering of '>'
characters. They were ultimately caused by the missed clearning of the
first pixel of a glyph where x0 is 1 (e.g., the character 'd'). In this
case, a pixel from the previously evicted cache entry (the '>') shined
through. The patch fixes the problem by clearing the glyph starting from
the first, not the x0's, pixel.

Fixes #3567
This commit is contained in:
Norman Feske 2019-11-29 15:53:22 +01:00 committed by Christian Helmuth
parent 3f83ac5580
commit 6b6915e304
1 changed files with 2 additions and 2 deletions

View File

@ -174,12 +174,12 @@ Ttf_font::Glyph_buffer::render_shifted(Codepoint const c,
unsigned const height = dy + 1 + PAD_Y;
unsigned const dst_width = filter_x*width;
unsigned char * const dst_ptr = (unsigned char *)_values + _headroom + x0;
unsigned char * const dst_ptr = (unsigned char *)_values + _headroom;
::memset(dst_ptr, 0, dst_width*height);
float sub_x = 0, sub_y = 0;
stbtt_MakeCodepointBitmapSubpixelPrefilter(&font, dst_ptr,
stbtt_MakeCodepointBitmapSubpixelPrefilter(&font, dst_ptr + x0,
dst_width, dy + 1, dst_width,
scale*4, scale,
shift_x, shift_y,