freetype: Avoid dereferencing null bitmap buffer.

For some characters (eg \r) the returned glyph will have .{.rows = 0, .width=0, .pitch = 0, .buffer = null}. In zig null[0..0] causes a panic rather than returning an empty slice.
This commit is contained in:
Jamie Brandon 2022-06-08 12:59:41 -07:00 committed by Stephen Gutekanst
parent 86053d9969
commit 15c71f5135
2 changed files with 8 additions and 3 deletions

View file

@ -21,7 +21,7 @@ pub fn main() !void {
while (i < bitmap.rows()) : (i += 1) {
var j: usize = 0;
while (j < bitmap.width()) : (j += 1) {
const char: u8 = switch (bitmap.buffer()[i * bitmap.width() + j]) {
const char: u8 = switch (bitmap.buffer().?[i * bitmap.width() + j]) {
0 => ' ',
1...128 => ';',
else => '#',