summaryrefslogtreecommitdiffstats
path: root/apps/plugins
diff options
context:
space:
mode:
authorFranklin Wei <franklin@rockbox.org>2020-06-27 20:23:13 -0400
committerFranklin Wei <franklin@rockbox.org>2020-06-27 20:23:13 -0400
commitc02a9c5ab3b0d2c4a6d9fb0e558fa5e8e9271770 (patch)
tree6938a695225c83d50fb8c3e8ef78572c5df82ba7 /apps/plugins
parent4b108896cc7440986d9e2384021db7ea9c42abb7 (diff)
downloadrockbox-c02a9c5ab3b0d2c4a6d9fb0e558fa5e8e9271770.tar.gz
rockbox-c02a9c5ab3b0d2c4a6d9fb0e558fa5e8e9271770.tar.bz2
rockbox-c02a9c5ab3b0d2c4a6d9fb0e558fa5e8e9271770.zip
puzzles: refuse to draw non-ASCII characters
We had some issues in Keen with the arithmetic operators not being rendered properly. This is still a kludge (we should intelligently search the font) but is still less ugly than the garbage it was drawing before. Change-Id: I5b957c7371b659ea6d64847145f9913b2a892e48
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/puzzles/rockbox.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c
index de89c42eed..a10bf7dd5c 100644
--- a/apps/plugins/puzzles/rockbox.c
+++ b/apps/plugins/puzzles/rockbox.c
@@ -1421,11 +1421,41 @@ static void draw_mouse(void)
}
}
+/* doesn't work, disabled (can't find a good mechanism to check if a
+ * glyph exists in a font) */
+#if 0
+/* See: https://www.chiark.greenend.org.uk/~sgtatham/puzzles/devel/drawing.html#drawing-text-fallback */
static char *rb_text_fallback(void *handle, const char *const *strings,
int nstrings)
{
- return dupstr(strings[0]);
+ struct font *pf = rb->font_get(cur_font);
+
+ for(int i = 0; i < nstrings; i++)
+ {
+ LOGF("checking alternative \"%s\"", strings[i]);
+ const unsigned char *ptr = strings[i];
+ unsigned short code;
+ bool valid = true;
+
+ while(*ptr)
+ {
+ ptr = rb->utf8decode(ptr, &code);
+
+ if(!rb->font_get_bits(pf, code))
+ {
+ valid = false;
+ break;
+ }
+ }
+
+ if(valid)
+ return dupstr(strings[i]);
+ }
+
+ /* shouldn't get here */
+ return dupstr(strings[nstrings - 1]);
}
+#endif
const drawing_api rb_drawing = {
rb_draw_text,
@@ -1443,9 +1473,10 @@ const drawing_api rb_drawing = {
rb_blitter_free,
rb_blitter_save,
rb_blitter_load,
+ /* printing functions */
NULL, NULL, NULL, NULL, NULL, NULL, /* {begin,end}_{doc,page,puzzle} */
- NULL, NULL, /* line_width, line_dotted */
- rb_text_fallback,
+ NULL, NULL, /* line_width, line_dotted */
+ NULL, /* fall back to ASCII */
NULL,
};