bidi: Expand+Correct the list of RTL codepoints in is_rtl_char()

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Sat, 27 Jun 2026 10:20:10 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 5462f203d33f69938d61686444587fca6cc4173f
Author: Solomon Peachy <[email protected]>
Date:   Sat Jun 27 10:06:51 2026 -0400

    bidi:  Expand+Correct the list of RTL codepoints in is_rtl_char()
    
    Was missing:
    
     * Arabic Supplement
     * Arabic Extended B
     * Arabic Extended A
     * Rumi Numerals
     * Arabic Extended C
     * Indic Isqaq Numerals
     * Ottoman Siyaq Numerals
     * Arabic Mathematical Alphabet Symbols
    
    Worth noting that most of these are vanishingly unlikely to ever show up
    in the context of Rockbox.  (The exceptions are "Arabic Supplement" and
    possibly the Mathematical Symbols)
    
    Also corrected "Arabic Presentation" into two distint blocks, as
    the characters between them (fe00-fe6f) are NOT indicative of RTL.
    
    Change-Id: I0c5c547921c789d32425682c8c75edb21428f549

diff --git a/firmware/export/bidi.h b/firmware/export/bidi.h
index 93a4bc1b8e..27b884beda 100644
--- a/firmware/export/bidi.h
+++ b/firmware/export/bidi.h
@@ -25,8 +25,22 @@
 /* True for code points that belong to a right-to-left script (Hebrew, Arabic
  * and the Arabic presentation forms). Shared by the bidi engine and by callers
  * that need to know a string's direction. */
-#define is_rtl_char(c) (((c) > 0x0589 && (c) < 0x0700) || \
-                        ((c) >= 0xfb50 && (c) <= 0xfefc))
+static inline bool is_rtl_char(ucschar_t c)
+{
+   return ((c >= 0x0590 && c <= 0x06ff) /* Hebrew + Arabic */ ||
+           (c >= 0x0750 && c <= 0x077f) /* Arabic Supp */ ||
+           (c >= 0x0870 && c <= 0x08ff) /* Arabic Ext B+A */ ||
+           (c >= 0xfb50 && c <= 0xfdff) /* Arabic Pres A */ ||
+           (c >= 0xfe70 && c <= 0xfefc) /* Arabic Pres B */
+#ifdef UNICODE32
+           || (c >= 0x10e60 && c <= 0x107ef) /* Rumi Numerals */
+           || (c >= 0x10ec0 && c <= 0x10eff) /* Arabic Ext C */
+           || (c >= 0x1ec70 && c <= 0x1ecbf) /* Indic Siyaq Numerals */
+           || (c >= 0x1ed00 && c <= 0x1ed4f) /* Ottoman Siyaq Numerals */
+           || (c >= 0x1ee00 && c <= 0x1eeff) /* Arabic Mathenatical Symbols */
+#endif
+           );
+}
 
 /* True if the string's first strongly-directional character is RTL, i.e. the
  * string should be laid out right-to-left. */
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs