Diacritic display enhancements

- Use the fact that unicode code currently does not support chars above 0xffff
  (see utf8decode()), and change diacritic database's char code type to
  unsigned short from int. Also comment out database entries above unsupported
  range.

- Use const when possible.

- Iterate over buffer using the buffer's pointer, thus avoiding usage of some
  variables, and avoiding multiple access to the same array item.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23776 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomer Shalev 2009-11-28 17:07:57 +00:00
parent c074c76211
commit c2617dc4ed
3 changed files with 326 additions and 319 deletions

View file

@ -26,309 +26,319 @@
#include "diacritic.h"
#include "system.h"
#define DIAC_FLAG_DIACRITIC (1 << 31)
#define DIAC_FLAG_RTL (1 << 30)
#define DIAC_MASK 0x000FFFFF
#define DIAC_FLAG_NONE 0
#define DIAC_FLAG_DIACRITIC (1 << 0)
#define DIAC_FLAG_RTL (1 << 1)
#define DIAC_VAL(i) (diac_range[(i)] & DIAC_MASK)
#define DIAC_IS_DIACRITIC(i) ((diac_range[(i)] & DIAC_FLAG_DIACRITIC) ? 1 : 0)
#define DIAC_IS_RTL(i) ((diac_range[(i)] & DIAC_FLAG_RTL) ? 1 : 0)
#define DIAC_NUM_RANGES (ARRAYLEN(diac_range))
#define DIAC_VAL(i) (diac_ranges[(i)].last)
#define DIAC_IS_DIACRITIC(i) (diac_ranges[(i)].flags & DIAC_FLAG_DIACRITIC)
#define DIAC_IS_RTL(i) (diac_ranges[(i)].flags & DIAC_FLAG_RTL)
#define DIAC_NUM_RANGES (ARRAYLEN(diac_ranges))
struct diac_range
{
unsigned short last;
unsigned char flags;
};
/* Sorted by Unicode value */
static const int diac_range[] =
static const struct diac_range diac_ranges[] =
{
0x00000,
0x002ff,
0x0036f | DIAC_FLAG_DIACRITIC, /* Combining Diacritical Marks */
0x00482,
0x00489 | DIAC_FLAG_DIACRITIC, /* Cyrillic */
0x00590,
0x005bd | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Hebrew */
0x005be | DIAC_FLAG_RTL,
0x005bf | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Hebrew */
0x005c0 | DIAC_FLAG_RTL,
0x005c2 | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Hebrew */
0x005c3 | DIAC_FLAG_RTL,
0x005c5 | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Hebrew */
0x005c6 | DIAC_FLAG_RTL,
0x005c7 | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Hebrew */
0x0060f | DIAC_FLAG_RTL,
0x0061a | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Arabic */
0x0064a | DIAC_FLAG_RTL,
0x0065e | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Arabic */
0x0066f | DIAC_FLAG_RTL,
0x00670 | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Arabic */
0x006d5 | DIAC_FLAG_RTL,
0x006dc | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Arabic */
0x006de | DIAC_FLAG_RTL,
0x006e4 | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Arabic */
0x006e6 | DIAC_FLAG_RTL,
0x006e8 | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Arabic */
0x006e9 | DIAC_FLAG_RTL,
0x006ed | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Arabic */
0x00710 | DIAC_FLAG_RTL,
0x00711 | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Syriac */
0x0072f | DIAC_FLAG_RTL,
0x0074a | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Syriac */
0x007a5 | DIAC_FLAG_RTL,
0x007b0 | DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL, /* Thaana */
0x007c0 | DIAC_FLAG_RTL,
0x007ea,
0x007f3 | DIAC_FLAG_DIACRITIC, /* NKo */
0x00815,
0x00819 | DIAC_FLAG_DIACRITIC, /* Samaritan */
0x0081a,
0x00823 | DIAC_FLAG_DIACRITIC, /* Samaritan */
0x00824,
0x00827 | DIAC_FLAG_DIACRITIC, /* Samaritan */
0x00828,
0x0082d | DIAC_FLAG_DIACRITIC, /* Samaritan */
0x008ff,
0x00903 | DIAC_FLAG_DIACRITIC, /* Devanagari */
0x0093b,
0x0093c | DIAC_FLAG_DIACRITIC, /* Devanagari */
0x0093d,
0x0094e | DIAC_FLAG_DIACRITIC, /* Devanagari */
0x00950,
0x00955 | DIAC_FLAG_DIACRITIC, /* Devanagari */
0x00961,
0x00963 | DIAC_FLAG_DIACRITIC, /* Devanagari */
0x00980,
0x00983 | DIAC_FLAG_DIACRITIC, /* Bengali */
0x009bb,
0x009bc | DIAC_FLAG_DIACRITIC, /* Bengali */
0x009bd,
0x009cd | DIAC_FLAG_DIACRITIC, /* Bengali */
0x009d6,
0x009d7 | DIAC_FLAG_DIACRITIC, /* Bengali */
0x009e1,
0x009e3 | DIAC_FLAG_DIACRITIC, /* Bengali */
0x00a00,
0x00a03 | DIAC_FLAG_DIACRITIC, /* Gurmukhi */
0x00a3b,
0x00a51 | DIAC_FLAG_DIACRITIC, /* Gurmukhi */
0x00a6f,
0x00a71 | DIAC_FLAG_DIACRITIC, /* Gurmukhi */
0x00a74,
0x00a75 | DIAC_FLAG_DIACRITIC, /* Gurmukhi */
0x00a80,
0x00a83 | DIAC_FLAG_DIACRITIC, /* Gujarati */
0x00abb,
0x00abc | DIAC_FLAG_DIACRITIC, /* Gujarati */
0x00abd,
0x00acd | DIAC_FLAG_DIACRITIC, /* Gujarati */
0x00ae1,
0x00ae3 | DIAC_FLAG_DIACRITIC, /* Gujarati */
0x00b00,
0x00b03 | DIAC_FLAG_DIACRITIC, /* Oriya */
0x00b3b,
0x00b3c | DIAC_FLAG_DIACRITIC, /* Oriya */
0x00b3d,
0x00b57 | DIAC_FLAG_DIACRITIC, /* Oriya */
0x00b81,
0x00b82 | DIAC_FLAG_DIACRITIC, /* Tamil */
0x00bbd,
0x00bcd | DIAC_FLAG_DIACRITIC, /* Tamil */
0x00bd6,
0x00bd7 | DIAC_FLAG_DIACRITIC, /* Tamil */
0x00c00,
0x00c03 | DIAC_FLAG_DIACRITIC, /* Telugu */
0x00c3d,
0x00c56 | DIAC_FLAG_DIACRITIC, /* Telugu */
0x00c61,
0x00c63 | DIAC_FLAG_DIACRITIC, /* Telugu */
0x00c81,
0x00c83 | DIAC_FLAG_DIACRITIC, /* Kannada */
0x00cbb,
0x00cbc | DIAC_FLAG_DIACRITIC, /* Kannada */
0x00cbd,
0x00cd6 | DIAC_FLAG_DIACRITIC, /* Kannada */
0x00ce1,
0x00ce3 | DIAC_FLAG_DIACRITIC, /* Kannada */
0x00d01,
0x00d03 | DIAC_FLAG_DIACRITIC, /* Malayalam */
0x00d3d,
0x00d57 | DIAC_FLAG_DIACRITIC, /* Malayalam */
0x00d61,
0x00d63 | DIAC_FLAG_DIACRITIC, /* Malayalam */
0x00d81,
0x00d83 | DIAC_FLAG_DIACRITIC, /* Sinhala */
0x00dc9,
0x00df3 | DIAC_FLAG_DIACRITIC, /* Sinhala */
0x00e30,
0x00e31 | DIAC_FLAG_DIACRITIC, /* Thai */
0x00e33,
0x00e3a | DIAC_FLAG_DIACRITIC, /* Thai */
0x00e46,
0x00e4e | DIAC_FLAG_DIACRITIC, /* Thai */
0x00eb0,
0x00eb1 | DIAC_FLAG_DIACRITIC, /* Lao */
0x00eb3,
0x00ebc | DIAC_FLAG_DIACRITIC, /* Lao */
0x00ec7,
0x00ecd | DIAC_FLAG_DIACRITIC, /* Lao */
0x00f17,
0x00f19 | DIAC_FLAG_DIACRITIC, /* Tibetan */
0x00f34,
0x00f35 | DIAC_FLAG_DIACRITIC, /* Tibetan */
0x00f36,
0x00f37 | DIAC_FLAG_DIACRITIC, /* Tibetan */
0x00f38,
0x00f39 | DIAC_FLAG_DIACRITIC, /* Tibetan */
0x00f3d,
0x00f3f | DIAC_FLAG_DIACRITIC, /* Tibetan */
0x00f70,
0x00f84 | DIAC_FLAG_DIACRITIC, /* Tibetan */
0x00f85,
0x00f87 | DIAC_FLAG_DIACRITIC, /* Tibetan */
0x00f8f,
0x00fbc | DIAC_FLAG_DIACRITIC, /* Tibetan */
0x0102a,
0x0103e | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x01055,
0x01059 | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x0105d,
0x01060 | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x01061,
0x01064 | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x01066,
0x0106d | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x01070,
0x01074 | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x01081,
0x0108d | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x0108e,
0x0108f | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x01099,
0x0109d | DIAC_FLAG_DIACRITIC, /* Myanmar */
0x0135e,
0x0135f | DIAC_FLAG_DIACRITIC, /* Ethiopic */
0x01711,
0x01714 | DIAC_FLAG_DIACRITIC, /* Tagalog */
0x01731,
0x01734 | DIAC_FLAG_DIACRITIC, /* Hanunoo */
0x01751,
0x01753 | DIAC_FLAG_DIACRITIC, /* Buhid */
0x01771,
0x01773 | DIAC_FLAG_DIACRITIC, /* Tagbanwa */
0x017b5,
0x017d3 | DIAC_FLAG_DIACRITIC, /* Khmer */
0x017dc,
0x017dd | DIAC_FLAG_DIACRITIC, /* Khmer */
0x018a8,
0x018a9 | DIAC_FLAG_DIACRITIC, /* Mongolian */
0x0191f,
0x0193b | DIAC_FLAG_DIACRITIC, /* Limbu */
0x019af,
0x019c0 | DIAC_FLAG_DIACRITIC, /* New Tai Lue */
0x019c7,
0x019c9 | DIAC_FLAG_DIACRITIC, /* New Tai Lue */
0x01a16,
0x01a1b | DIAC_FLAG_DIACRITIC, /* Buginese */
0x01a54,
0x01a7f | DIAC_FLAG_DIACRITIC, /* Tai Tham */
0x01aff,
0x01b04 | DIAC_FLAG_DIACRITIC, /* Balinese */
0x01b33,
0x01b44 | DIAC_FLAG_DIACRITIC, /* Balinese */
0x01b6a,
0x01b73 | DIAC_FLAG_DIACRITIC, /* Balinese */
0x01b7f,
0x01b82 | DIAC_FLAG_DIACRITIC, /* Sundanese */
0x01ba0,
0x01baa | DIAC_FLAG_DIACRITIC, /* Sundanese */
0x01c23,
0x01c37 | DIAC_FLAG_DIACRITIC, /* Lepcha */
0x01ccf,
0x01cd2 | DIAC_FLAG_DIACRITIC, /* Vedic Extensions */
0x01cd3,
0x01ce8 | DIAC_FLAG_DIACRITIC, /* Vedic Extensions */
0x01cec,
0x01ced | DIAC_FLAG_DIACRITIC, /* Vedic Extensions */
0x01cf1,
0x01cf2 | DIAC_FLAG_DIACRITIC, /* Vedic Extensions */
0x01dbf,
0x01dff | DIAC_FLAG_DIACRITIC, /* Combining Diacritical Marks Supplement */
0x020cf,
0x020f0 | DIAC_FLAG_DIACRITIC, /* Combining Diacritical Marks for Symbols */
0x02cee,
0x02cf1 | DIAC_FLAG_DIACRITIC, /* Coptic */
0x02ddf,
0x02dff | DIAC_FLAG_DIACRITIC, /* Coptic */
0x03029,
0x0302f | DIAC_FLAG_DIACRITIC, /* CJK Symbols and Punctuation */
0x03098,
0x0309a | DIAC_FLAG_DIACRITIC, /* Hiragana */
0x0a66e,
0x0a672 | DIAC_FLAG_DIACRITIC, /* Hiragana */
0x0a67b,
0x0a67d | DIAC_FLAG_DIACRITIC, /* Hiragana */
0x0a6ef,
0x0a6f1 | DIAC_FLAG_DIACRITIC, /* Bamum */
0x0a801,
0x0a802 | DIAC_FLAG_DIACRITIC, /* Syloti Nagri */
0x0a805,
0x0a806 | DIAC_FLAG_DIACRITIC, /* Syloti Nagri */
0x0a80a,
0x0a80b | DIAC_FLAG_DIACRITIC, /* Syloti Nagri */
0x0a822,
0x0a827 | DIAC_FLAG_DIACRITIC, /* Syloti Nagri */
0x0a87f,
0x0a881 | DIAC_FLAG_DIACRITIC, /* Saurashtra */
0x0a8b3,
0x0a8c4 | DIAC_FLAG_DIACRITIC, /* Saurashtra */
0x0a8df,
0x0a8f1 | DIAC_FLAG_DIACRITIC, /* Devanagari Extended */
0x0a925,
0x0a92d | DIAC_FLAG_DIACRITIC, /* Kayah Li */
0x0a946,
0x0a953 | DIAC_FLAG_DIACRITIC, /* Rejang */
0x0a97f,
0x0a983 | DIAC_FLAG_DIACRITIC, /* Javanese */
0x0a9b2,
0x0a9c0 | DIAC_FLAG_DIACRITIC, /* Javanese */
0x0aa28,
0x0aa36 | DIAC_FLAG_DIACRITIC, /* Cham */
0x0aa42,
0x0aa43 | DIAC_FLAG_DIACRITIC, /* Cham */
0x0aa4b,
0x0aa4d | DIAC_FLAG_DIACRITIC, /* Cham */
0x0aa7a,
0x0aa7b | DIAC_FLAG_DIACRITIC, /* Cham */
0x0aaaf,
0x0aab0 | DIAC_FLAG_DIACRITIC, /* Tai Viet */
0x0aab1,
0x0aab4 | DIAC_FLAG_DIACRITIC, /* Tai Viet */
0x0aab6,
0x0aab8 | DIAC_FLAG_DIACRITIC, /* Tai Viet */
0x0aabd,
0x0aabf | DIAC_FLAG_DIACRITIC, /* Tai Viet */
0x0aac0,
0x0aac1 | DIAC_FLAG_DIACRITIC, /* Tai Viet */
0x0abe2,
0x0abea | DIAC_FLAG_DIACRITIC, /* Meetei Mayek */
0x0abeb,
0x0abed | DIAC_FLAG_DIACRITIC, /* Meetei Mayek */
0x0fb1d,
0x0fb1e | DIAC_FLAG_DIACRITIC, /* Alphabetic Presentation Forms */
0x0fe1f,
0x0fe26 | DIAC_FLAG_DIACRITIC, /* Combining Half Marks */
0x1107f,
0x11082 | DIAC_FLAG_DIACRITIC, /* Kaithi */
0x110af,
0x110ba | DIAC_FLAG_DIACRITIC, /* Kaithi */
0x1d164,
0x1d169 | DIAC_FLAG_DIACRITIC, /* Musical Symbols */
0x1d16c,
0x1d182 | DIAC_FLAG_DIACRITIC, /* Musical Symbols */
0x1d184,
0x1d18b | DIAC_FLAG_DIACRITIC, /* Musical Symbols */
0x1d1a9,
0x1d1ad | DIAC_FLAG_DIACRITIC, /* Musical Symbols */
0x1d241,
0x1d244 | DIAC_FLAG_DIACRITIC, /* Ancient Greek Musical Notation */
0xe01ef,
{ 0x0000, DIAC_FLAG_NONE },
{ 0x02ff, DIAC_FLAG_NONE },
{ 0x036f, DIAC_FLAG_DIACRITIC }, /* Combining Diacritical Marks */
{ 0x0482, DIAC_FLAG_NONE },
{ 0x0489, DIAC_FLAG_DIACRITIC }, /* Cyrillic */
{ 0x0590, DIAC_FLAG_NONE },
{ 0x05bd, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Hebrew */
{ 0x05be, DIAC_FLAG_RTL },
{ 0x05bf, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Hebrew */
{ 0x05c0, DIAC_FLAG_RTL },
{ 0x05c2, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Hebrew */
{ 0x05c3, DIAC_FLAG_RTL },
{ 0x05c5, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Hebrew */
{ 0x05c6, DIAC_FLAG_RTL },
{ 0x05c7, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Hebrew */
{ 0x060f, DIAC_FLAG_RTL },
{ 0x061a, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Arabic */
{ 0x064a, DIAC_FLAG_RTL },
{ 0x065e, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Arabic */
{ 0x066f, DIAC_FLAG_RTL },
{ 0x0670, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Arabic */
{ 0x06d5, DIAC_FLAG_RTL },
{ 0x06dc, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Arabic */
{ 0x06de, DIAC_FLAG_RTL },
{ 0x06e4, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Arabic */
{ 0x06e6, DIAC_FLAG_RTL },
{ 0x06e8, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Arabic */
{ 0x06e9, DIAC_FLAG_RTL },
{ 0x06ed, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Arabic */
{ 0x0710, DIAC_FLAG_RTL },
{ 0x0711, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Syriac */
{ 0x072f, DIAC_FLAG_RTL },
{ 0x074a, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Syriac */
{ 0x07a5, DIAC_FLAG_RTL },
{ 0x07b0, DIAC_FLAG_DIACRITIC | DIAC_FLAG_RTL }, /* Thaana */
{ 0x07c0, DIAC_FLAG_RTL },
{ 0x07ea, DIAC_FLAG_NONE },
{ 0x07f3, DIAC_FLAG_DIACRITIC }, /* NKo */
{ 0x0815, DIAC_FLAG_NONE },
{ 0x0819, DIAC_FLAG_DIACRITIC }, /* Samaritan */
{ 0x081a, DIAC_FLAG_NONE },
{ 0x0823, DIAC_FLAG_DIACRITIC }, /* Samaritan */
{ 0x0824, DIAC_FLAG_NONE },
{ 0x0827, DIAC_FLAG_DIACRITIC }, /* Samaritan */
{ 0x0828, DIAC_FLAG_NONE },
{ 0x082d, DIAC_FLAG_DIACRITIC }, /* Samaritan */
{ 0x08ff, DIAC_FLAG_NONE },
{ 0x0903, DIAC_FLAG_DIACRITIC }, /* Devanagari */
{ 0x093b, DIAC_FLAG_NONE },
{ 0x093c, DIAC_FLAG_DIACRITIC }, /* Devanagari */
{ 0x093d, DIAC_FLAG_NONE },
{ 0x094e, DIAC_FLAG_DIACRITIC }, /* Devanagari */
{ 0x0950, DIAC_FLAG_NONE },
{ 0x0955, DIAC_FLAG_DIACRITIC }, /* Devanagari */
{ 0x0961, DIAC_FLAG_NONE },
{ 0x0963, DIAC_FLAG_DIACRITIC }, /* Devanagari */
{ 0x0980, DIAC_FLAG_NONE },
{ 0x0983, DIAC_FLAG_DIACRITIC }, /* Bengali */
{ 0x09bb, DIAC_FLAG_NONE },
{ 0x09bc, DIAC_FLAG_DIACRITIC }, /* Bengali */
{ 0x09bd, DIAC_FLAG_NONE },
{ 0x09cd, DIAC_FLAG_DIACRITIC }, /* Bengali */
{ 0x09d6, DIAC_FLAG_NONE },
{ 0x09d7, DIAC_FLAG_DIACRITIC }, /* Bengali */
{ 0x09e1, DIAC_FLAG_NONE },
{ 0x09e3, DIAC_FLAG_DIACRITIC }, /* Bengali */
{ 0x0a00, DIAC_FLAG_NONE },
{ 0x0a03, DIAC_FLAG_DIACRITIC }, /* Gurmukhi */
{ 0x0a3b, DIAC_FLAG_NONE },
{ 0x0a51, DIAC_FLAG_DIACRITIC }, /* Gurmukhi */
{ 0x0a6f, DIAC_FLAG_NONE },
{ 0x0a71, DIAC_FLAG_DIACRITIC }, /* Gurmukhi */
{ 0x0a74, DIAC_FLAG_NONE },
{ 0x0a75, DIAC_FLAG_DIACRITIC }, /* Gurmukhi */
{ 0x0a80, DIAC_FLAG_NONE },
{ 0x0a83, DIAC_FLAG_DIACRITIC }, /* Gujarati */
{ 0x0abb, DIAC_FLAG_NONE },
{ 0x0abc, DIAC_FLAG_DIACRITIC }, /* Gujarati */
{ 0x0abd, DIAC_FLAG_NONE },
{ 0x0acd, DIAC_FLAG_DIACRITIC }, /* Gujarati */
{ 0x0ae1, DIAC_FLAG_NONE },
{ 0x0ae3, DIAC_FLAG_DIACRITIC }, /* Gujarati */
{ 0x0b00, DIAC_FLAG_NONE },
{ 0x0b03, DIAC_FLAG_DIACRITIC }, /* Oriya */
{ 0x0b3b, DIAC_FLAG_NONE },
{ 0x0b3c, DIAC_FLAG_DIACRITIC }, /* Oriya */
{ 0x0b3d, DIAC_FLAG_NONE },
{ 0x0b57, DIAC_FLAG_DIACRITIC }, /* Oriya */
{ 0x0b81, DIAC_FLAG_NONE },
{ 0x0b82, DIAC_FLAG_DIACRITIC }, /* Tamil */
{ 0x0bbd, DIAC_FLAG_NONE },
{ 0x0bcd, DIAC_FLAG_DIACRITIC }, /* Tamil */
{ 0x0bd6, DIAC_FLAG_NONE },
{ 0x0bd7, DIAC_FLAG_DIACRITIC }, /* Tamil */
{ 0x0c00, DIAC_FLAG_NONE },
{ 0x0c03, DIAC_FLAG_DIACRITIC }, /* Telugu */
{ 0x0c3d, DIAC_FLAG_NONE },
{ 0x0c56, DIAC_FLAG_DIACRITIC }, /* Telugu */
{ 0x0c61, DIAC_FLAG_NONE },
{ 0x0c63, DIAC_FLAG_DIACRITIC }, /* Telugu */
{ 0x0c81, DIAC_FLAG_NONE },
{ 0x0c83, DIAC_FLAG_DIACRITIC }, /* Kannada */
{ 0x0cbb, DIAC_FLAG_NONE },
{ 0x0cbc, DIAC_FLAG_DIACRITIC }, /* Kannada */
{ 0x0cbd, DIAC_FLAG_NONE },
{ 0x0cd6, DIAC_FLAG_DIACRITIC }, /* Kannada */
{ 0x0ce1, DIAC_FLAG_NONE },
{ 0x0ce3, DIAC_FLAG_DIACRITIC }, /* Kannada */
{ 0x0d01, DIAC_FLAG_NONE },
{ 0x0d03, DIAC_FLAG_DIACRITIC }, /* Malayalam */
{ 0x0d3d, DIAC_FLAG_NONE },
{ 0x0d57, DIAC_FLAG_DIACRITIC }, /* Malayalam */
{ 0x0d61, DIAC_FLAG_NONE },
{ 0x0d63, DIAC_FLAG_DIACRITIC }, /* Malayalam */
{ 0x0d81, DIAC_FLAG_NONE },
{ 0x0d83, DIAC_FLAG_DIACRITIC }, /* Sinhala */
{ 0x0dc9, DIAC_FLAG_NONE },
{ 0x0df3, DIAC_FLAG_DIACRITIC }, /* Sinhala */
{ 0x0e30, DIAC_FLAG_NONE },
{ 0x0e31, DIAC_FLAG_DIACRITIC }, /* Thai */
{ 0x0e33, DIAC_FLAG_NONE },
{ 0x0e3a, DIAC_FLAG_DIACRITIC }, /* Thai */
{ 0x0e46, DIAC_FLAG_NONE },
{ 0x0e4e, DIAC_FLAG_DIACRITIC }, /* Thai */
{ 0x0eb0, DIAC_FLAG_NONE },
{ 0x0eb1, DIAC_FLAG_DIACRITIC }, /* Lao */
{ 0x0eb3, DIAC_FLAG_NONE },
{ 0x0ebc, DIAC_FLAG_DIACRITIC }, /* Lao */
{ 0x0ec7, DIAC_FLAG_NONE },
{ 0x0ecd, DIAC_FLAG_DIACRITIC }, /* Lao */
{ 0x0f17, DIAC_FLAG_NONE },
{ 0x0f19, DIAC_FLAG_DIACRITIC }, /* Tibetan */
{ 0x0f34, DIAC_FLAG_NONE },
{ 0x0f35, DIAC_FLAG_DIACRITIC }, /* Tibetan */
{ 0x0f36, DIAC_FLAG_NONE },
{ 0x0f37, DIAC_FLAG_DIACRITIC }, /* Tibetan */
{ 0x0f38, DIAC_FLAG_NONE },
{ 0x0f39, DIAC_FLAG_DIACRITIC }, /* Tibetan */
{ 0x0f3d, DIAC_FLAG_NONE },
{ 0x0f3f, DIAC_FLAG_DIACRITIC }, /* Tibetan */
{ 0x0f70, DIAC_FLAG_NONE },
{ 0x0f84, DIAC_FLAG_DIACRITIC }, /* Tibetan */
{ 0x0f85, DIAC_FLAG_NONE },
{ 0x0f87, DIAC_FLAG_DIACRITIC }, /* Tibetan */
{ 0x0f8f, DIAC_FLAG_NONE },
{ 0x0fbc, DIAC_FLAG_DIACRITIC }, /* Tibetan */
{ 0x102a, DIAC_FLAG_NONE },
{ 0x103e, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x1055, DIAC_FLAG_NONE },
{ 0x1059, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x105d, DIAC_FLAG_NONE },
{ 0x1060, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x1061, DIAC_FLAG_NONE },
{ 0x1064, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x1066, DIAC_FLAG_NONE },
{ 0x106d, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x1070, DIAC_FLAG_NONE },
{ 0x1074, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x1081, DIAC_FLAG_NONE },
{ 0x108d, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x108e, DIAC_FLAG_NONE },
{ 0x108f, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x1099, DIAC_FLAG_NONE },
{ 0x109d, DIAC_FLAG_DIACRITIC }, /* Myanmar */
{ 0x135e, DIAC_FLAG_NONE },
{ 0x135f, DIAC_FLAG_DIACRITIC }, /* Ethiopic */
{ 0x1711, DIAC_FLAG_NONE },
{ 0x1714, DIAC_FLAG_DIACRITIC }, /* Tagalog */
{ 0x1731, DIAC_FLAG_NONE },
{ 0x1734, DIAC_FLAG_DIACRITIC }, /* Hanunoo */
{ 0x1751, DIAC_FLAG_NONE },
{ 0x1753, DIAC_FLAG_DIACRITIC }, /* Buhid */
{ 0x1771, DIAC_FLAG_NONE },
{ 0x1773, DIAC_FLAG_DIACRITIC }, /* Tagbanwa */
{ 0x17b5, DIAC_FLAG_NONE },
{ 0x17d3, DIAC_FLAG_DIACRITIC }, /* Khmer */
{ 0x17dc, DIAC_FLAG_NONE },
{ 0x17dd, DIAC_FLAG_DIACRITIC }, /* Khmer */
{ 0x18a8, DIAC_FLAG_NONE },
{ 0x18a9, DIAC_FLAG_DIACRITIC }, /* Mongolian */
{ 0x191f, DIAC_FLAG_NONE },
{ 0x193b, DIAC_FLAG_DIACRITIC }, /* Limbu */
{ 0x19af, DIAC_FLAG_NONE },
{ 0x19c0, DIAC_FLAG_DIACRITIC }, /* New Tai Lue */
{ 0x19c7, DIAC_FLAG_NONE },
{ 0x19c9, DIAC_FLAG_DIACRITIC }, /* New Tai Lue */
{ 0x1a16, DIAC_FLAG_NONE },
{ 0x1a1b, DIAC_FLAG_DIACRITIC }, /* Buginese */
{ 0x1a54, DIAC_FLAG_NONE },
{ 0x1a7f, DIAC_FLAG_DIACRITIC }, /* Tai Tham */
{ 0x1aff, DIAC_FLAG_NONE },
{ 0x1b04, DIAC_FLAG_DIACRITIC }, /* Balinese */
{ 0x1b33, DIAC_FLAG_NONE },
{ 0x1b44, DIAC_FLAG_DIACRITIC }, /* Balinese */
{ 0x1b6a, DIAC_FLAG_NONE },
{ 0x1b73, DIAC_FLAG_DIACRITIC }, /* Balinese */
{ 0x1b7f, DIAC_FLAG_NONE },
{ 0x1b82, DIAC_FLAG_DIACRITIC }, /* Sundanese */
{ 0x1ba0, DIAC_FLAG_NONE },
{ 0x1baa, DIAC_FLAG_DIACRITIC }, /* Sundanese */
{ 0x1c23, DIAC_FLAG_NONE },
{ 0x1c37, DIAC_FLAG_DIACRITIC }, /* Lepcha */
{ 0x1ccf, DIAC_FLAG_NONE },
{ 0x1cd2, DIAC_FLAG_DIACRITIC }, /* Vedic Extensions */
{ 0x1cd3, DIAC_FLAG_NONE },
{ 0x1ce8, DIAC_FLAG_DIACRITIC }, /* Vedic Extensions */
{ 0x1cec, DIAC_FLAG_NONE },
{ 0x1ced, DIAC_FLAG_DIACRITIC }, /* Vedic Extensions */
{ 0x1cf1, DIAC_FLAG_NONE },
{ 0x1cf2, DIAC_FLAG_DIACRITIC }, /* Vedic Extensions */
{ 0x1dbf, DIAC_FLAG_NONE },
{ 0x1dff, DIAC_FLAG_DIACRITIC }, /* Combining Diacritical Marks Supplement */
{ 0x20cf, DIAC_FLAG_NONE },
{ 0x20f0, DIAC_FLAG_DIACRITIC }, /* Combining Diacritical Marks for Symbols */
{ 0x2cee, DIAC_FLAG_NONE },
{ 0x2cf1, DIAC_FLAG_DIACRITIC }, /* Coptic */
{ 0x2ddf, DIAC_FLAG_NONE },
{ 0x2dff, DIAC_FLAG_DIACRITIC }, /* Coptic */
{ 0x3029, DIAC_FLAG_NONE },
{ 0x302f, DIAC_FLAG_DIACRITIC }, /* CJK Symbols and Punctuation */
{ 0x3098, DIAC_FLAG_NONE },
{ 0x309a, DIAC_FLAG_DIACRITIC }, /* Hiragana */
{ 0xa66e, DIAC_FLAG_NONE },
{ 0xa672, DIAC_FLAG_DIACRITIC }, /* Hiragana */
{ 0xa67b, DIAC_FLAG_NONE },
{ 0xa67d, DIAC_FLAG_DIACRITIC }, /* Hiragana */
{ 0xa6ef, DIAC_FLAG_NONE },
{ 0xa6f1, DIAC_FLAG_DIACRITIC }, /* Bamum */
{ 0xa801, DIAC_FLAG_NONE },
{ 0xa802, DIAC_FLAG_DIACRITIC }, /* Syloti Nagri */
{ 0xa805, DIAC_FLAG_NONE },
{ 0xa806, DIAC_FLAG_DIACRITIC }, /* Syloti Nagri */
{ 0xa80a, DIAC_FLAG_NONE },
{ 0xa80b, DIAC_FLAG_DIACRITIC }, /* Syloti Nagri */
{ 0xa822, DIAC_FLAG_NONE },
{ 0xa827, DIAC_FLAG_DIACRITIC }, /* Syloti Nagri */
{ 0xa87f, DIAC_FLAG_NONE },
{ 0xa881, DIAC_FLAG_DIACRITIC }, /* Saurashtra */
{ 0xa8b3, DIAC_FLAG_NONE },
{ 0xa8c4, DIAC_FLAG_DIACRITIC }, /* Saurashtra */
{ 0xa8df, DIAC_FLAG_NONE },
{ 0xa8f1, DIAC_FLAG_DIACRITIC }, /* Devanagari Extended */
{ 0xa925, DIAC_FLAG_NONE },
{ 0xa92d, DIAC_FLAG_DIACRITIC }, /* Kayah Li */
{ 0xa946, DIAC_FLAG_NONE },
{ 0xa953, DIAC_FLAG_DIACRITIC }, /* Rejang */
{ 0xa97f, DIAC_FLAG_NONE },
{ 0xa983, DIAC_FLAG_DIACRITIC }, /* Javanese */
{ 0xa9b2, DIAC_FLAG_NONE },
{ 0xa9c0, DIAC_FLAG_DIACRITIC }, /* Javanese */
{ 0xaa28, DIAC_FLAG_NONE },
{ 0xaa36, DIAC_FLAG_DIACRITIC }, /* Cham */
{ 0xaa42, DIAC_FLAG_NONE },
{ 0xaa43, DIAC_FLAG_DIACRITIC }, /* Cham */
{ 0xaa4b, DIAC_FLAG_NONE },
{ 0xaa4d, DIAC_FLAG_DIACRITIC }, /* Cham */
{ 0xaa7a, DIAC_FLAG_NONE },
{ 0xaa7b, DIAC_FLAG_DIACRITIC }, /* Cham */
{ 0xaaaf, DIAC_FLAG_NONE },
{ 0xaab0, DIAC_FLAG_DIACRITIC }, /* Tai Viet */
{ 0xaab1, DIAC_FLAG_NONE },
{ 0xaab4, DIAC_FLAG_DIACRITIC }, /* Tai Viet */
{ 0xaab6, DIAC_FLAG_NONE },
{ 0xaab8, DIAC_FLAG_DIACRITIC }, /* Tai Viet */
{ 0xaabd, DIAC_FLAG_NONE },
{ 0xaabf, DIAC_FLAG_DIACRITIC }, /* Tai Viet */
{ 0xaac0, DIAC_FLAG_NONE },
{ 0xaac1, DIAC_FLAG_DIACRITIC }, /* Tai Viet */
{ 0xabe2, DIAC_FLAG_NONE },
{ 0xabea, DIAC_FLAG_DIACRITIC }, /* Meetei Mayek */
{ 0xabeb, DIAC_FLAG_NONE },
{ 0xabed, DIAC_FLAG_DIACRITIC }, /* Meetei Mayek */
{ 0xfb1d, DIAC_FLAG_NONE },
{ 0xfb1e, DIAC_FLAG_DIACRITIC }, /* Alphabetic Presentation Forms */
{ 0xfe1f, DIAC_FLAG_NONE },
{ 0xfe26, DIAC_FLAG_DIACRITIC }, /* Combining Half Marks */
/* Currently we don't support chars above U-FFFF */
{ 0xffff, DIAC_FLAG_NONE },
#if 0
{ 0x1107f, DIAC_FLAG_NONE },
{ 0x11082, DIAC_FLAG_DIACRITIC }, /* Kaithi */
{ 0x110af, DIAC_FLAG_NONE },
{ 0x110ba, DIAC_FLAG_DIACRITIC }, /* Kaithi */
{ 0x1d164, DIAC_FLAG_NONE },
{ 0x1d169, DIAC_FLAG_DIACRITIC }, /* Musical Symbols */
{ 0x1d16c, DIAC_FLAG_NONE },
{ 0x1d182, DIAC_FLAG_DIACRITIC }, /* Musical Symbols */
{ 0x1d184, DIAC_FLAG_NONE },
{ 0x1d18b, DIAC_FLAG_DIACRITIC }, /* Musical Symbols */
{ 0x1d1a9, DIAC_FLAG_NONE },
{ 0x1d1ad, DIAC_FLAG_DIACRITIC }, /* Musical Symbols */
{ 0x1d241, DIAC_FLAG_NONE },
{ 0x1d244, DIAC_FLAG_DIACRITIC }, /* Ancient Greek Musical Notation */
{ 0xe01ef, DIAC_FLAG_NONE },
#endif
};
#define MRU_MAX_LEN 32
@ -336,7 +346,7 @@ static const int diac_range[] =
static unsigned short mru_len = 0;
static unsigned short diacritic_mru[MRU_MAX_LEN];
int is_diacritic(unsigned short char_code, bool *is_rtl)
int is_diacritic(const unsigned short char_code, bool *is_rtl)
{
unsigned short mru, i;

View file

@ -83,11 +83,10 @@ static void lcd_gradient_rect(int x1, int x2, int y, unsigned h,
/* put a string at a given pixel position, skipping first ofs pixel columns */
static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
{
unsigned short ch, *ucs;
unsigned short *ucs;
struct font* pf = font_get(current_vp->font);
int vp_flags = current_vp->flags;
unsigned i;
static int rtl_next_non_diacritic_width, last_non_diacritic_width;
int rtl_next_non_diac_width, last_non_diacritic_width;
if ((vp_flags & VP_FLAG_ALIGNMENT_MASK) != 0)
{
@ -109,25 +108,23 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
}
}
ucs = bidi_l2v(str, 1);
rtl_next_non_diacritic_width = 0;
rtl_next_non_diac_width = 0;
last_non_diacritic_width = 0;
/* Mark diacritic and rtl flags for each character */
for (i = 0; i < SCROLL_LINE_SIZE && (ch = ucs[i]); i++)
for (ucs = bidi_l2v(str, 1); *ucs; ucs++)
{
bool is_rtl, is_diac;
const unsigned char *bits;
int width, base_width, drawmode = 0, base_ofs = 0;
unsigned short next_ch = ucs[i + 1];
const unsigned short next_ch = ucs[1];
if (x >= current_vp->width)
break;
is_diac = is_diacritic(ch, &is_rtl);
is_diac = is_diacritic(*ucs, &is_rtl);
/* Get proportional width and glyph bits */
width = font_get_width(pf, ch);
width = font_get_width(pf, *ucs);
/* Calculate base width */
if (is_rtl)
@ -135,20 +132,20 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
/* Forward-seek the next non-diacritic character for base width */
if (is_diac)
{
if (!rtl_next_non_diacritic_width)
if (!rtl_next_non_diac_width)
{
unsigned j;
const unsigned short *u;
/* Jump to next non-diacritic char, and calc its width */
for (j = i + 1; ucs[j] && is_diacritic(ucs[j], NULL); j++);
rtl_next_non_diacritic_width = ucs[j] ?
font_get_width(pf, ucs[j]) : 0;
for (u = &ucs[1]; *u && is_diacritic(*u, NULL); u++);
rtl_next_non_diac_width = *u ? font_get_width(pf, *u) : 0;
}
base_width = rtl_next_non_diacritic_width;
base_width = rtl_next_non_diac_width;
}
else
{
rtl_next_non_diacritic_width = 0; /* Mark */
rtl_next_non_diac_width = 0; /* Mark */
base_width = width;
}
}
@ -188,7 +185,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
base_ofs = (base_width - width) / 2;
}
bits = font_get_bits(pf, ch);
bits = font_get_bits(pf, *ucs);
LCDFN(mono_bitmap_part)(bits, ofs, 0, width, MAX(x + base_ofs, 0), y,
width - ofs, pf->height);

View file

@ -22,5 +22,5 @@
#define _DIACRITIC_H_
#include "system.h"
int is_diacritic(unsigned short char_code, bool *is_rtl);
int is_diacritic(const unsigned short char_code, bool *is_rtl);
#endif