Fix buffer not being cleared before re-use

This commit is contained in:
Kovid Goyal 2025-01-29 17:48:04 +05:30
parent d068a0a6de
commit 44eec08b24
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 5 deletions

View file

@ -365,9 +365,11 @@ def create_face(path: str) -> 'Union[CTFace, Face]':
return Face(path=path)
def test_render_codepoint(char: str = '😺', path: str = '/t/Noto-COLRv1.ttf', font_size: float = 160.0) -> None:
def test_render_codepoint(chars: str = '😺', path: str = '/t/Noto-COLRv1.ttf', font_size: float = 160.0) -> None:
f = create_face(path=path)
f.set_size(font_size, 96, 96)
bitmap, w, h = f.render_codepoint(ord(char))
display_bitmap(bitmap, w, h)
print('\n')
for char in chars:
bitmap, w, h = f.render_codepoint(ord(char))
print('Rendered:', char)
display_bitmap(bitmap, w, h)
print('\n')

View file

@ -763,7 +763,7 @@ render_glyph_with_cairo(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned
}
sf = fit_cairo_glyph(self, &g, &bb, sf, width, height);
g.y = baseline;
cairo_set_source_rgba(self->cairo.cr, 0, 0, 0, 0); cairo_paint(self->cairo.cr); // clear to blank
memset(self->cairo.buf, 0, self->cairo.stride * self->cairo.height);
cairo_set_source_rgba(self->cairo.cr, fg.r / 255., fg.g / 255., fg.b / 255., fg.a / 255.);
cairo_show_glyphs(self->cairo.cr, &g, 1);
cairo_surface_flush(self->cairo.surface);