From e4d73bf327a47dab30f3bd4e52ab11ae488a7f67 Mon Sep 17 00:00:00 2001 From: idea4good Date: Wed, 9 Jan 2019 21:42:51 +0800 Subject: [PATCH] Show "X" when lattice/font not found --- core/src/word.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/word.cpp b/core/src/word.cpp index 4640f70..6bc2b45 100644 --- a/core/src/word.cpp +++ b/core/src/word.cpp @@ -161,14 +161,16 @@ int c_word::draw_single_char(c_surface* surface, int z_order, unsigned int utf8_ error_color = GL_RGB(255, 0, 0); } - //lattice/font not found, draw mosaic + //lattice/font not found, draw "X" int len = 16; for (int y_ = 0; y_ < len; y_++) { for (int x_ = 0; x_ < len; x_++) { - ((y_ % 4) == 0) ? surface->draw_pixel((x + x_), (y + y_), 0, z_order) : - surface->draw_pixel((x + x_), (y + y_), error_color, z_order); + int diff = (x_ - y_); + int sum = (x_ + y_); + (diff == 0 || diff == -1 || diff == 1 || sum == len || sum == (len - 1) || sum == (len + 1)) ? + surface->draw_pixel((x + x_), (y + y_), error_color, z_order) : surface->draw_pixel((x + x_), (y + y_), 0, z_order); } } return len;