From 808718bdb4c7806e14266bdeead42213f3d3ec45 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 27 Aug 2018 18:55:12 +0800 Subject: [PATCH] Support BIDI for UNICODE charsets and cleanup the implementation --- src/font/Makefile.am | 2 +- src/font/charset-arabic.c | 156 ++++++++- src/font/charset-bidi.c | 603 ++++++--------------------------- src/font/charset.c | 272 ++++++++++++--- src/font/unicode-bidi-tables.h | 404 ++++++++++++++++++++++ src/include/bidi.h | 33 +- src/include/devfont.h | 48 +-- src/newgdi/bidi.c | 41 ++- src/newgdi/tabbedtextout.c | 3 +- src/newgdi/textout.c | 3 +- 10 files changed, 942 insertions(+), 623 deletions(-) create mode 100644 src/font/unicode-bidi-tables.h diff --git a/src/font/Makefile.am b/src/font/Makefile.am index 4be321e8..50629b94 100644 --- a/src/font/Makefile.am +++ b/src/font/Makefile.am @@ -12,7 +12,7 @@ SRC_FILES = charset.c charset-arabic.c charset-bidi.c \ bitmapfont.c scripteasy.c HDR_FILES = charset.h rawbitmap.h varbitmap.h freetype1.h freetype2.h qpf.h \ - upf.h bitmapfont.h gunicode.h gunichartables.h se_minigui.h + upf.h bitmapfont.h gunicode.h gunichartables.h se_minigui.h unicode-bidi-tables.h EXTRA_DIST = convgbmap.c jisunimap.c $(SRC_FILES) $(HDR_FILES) \ makefile.ng makefile.msvc diff --git a/src/font/charset-arabic.c b/src/font/charset-arabic.c index e65923c9..d141da3c 100644 --- a/src/font/charset-arabic.c +++ b/src/font/charset-arabic.c @@ -468,13 +468,127 @@ static unsigned int iso8859_6_glyph_type (Glyph32 glyph_value) return ch_type; } +static BidiCharType __mg_iso8859_68x_type[] = { + /*0x00~0x0f*/ + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_SS, BIDI_TYPE_BS, BIDI_TYPE_SS, +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e0~0xef*/ + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_ON, + + /*0xf0~0xff*/ + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_ON, + + /*0x100~0x10f*/ + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + + /*0x110~0x11f*/ + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + + /*0x120~0x12f*/ + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, + + /*0x130~0x133*/ + BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, +}; + static unsigned int iso8859_6_bidi_glyph_type (Glyph32 glyph_value) { - unsigned int ch_type = BIDI_TYPE_AL; - - ch_type = bidi_glyph_type(FONT_CHARSET_ISO8859_6, glyph_value); - - return ch_type; + return __mg_iso8859_68x_type [REAL_GLYPH(glyph_value)]; } static int get_table_index(Uint8 c) @@ -652,13 +766,6 @@ static const unsigned char* iso8859_6_get_next_word (const unsigned char* mstr, //return sb_get_next_word(mstr, mstrlen, word_info); } -static Glyph32* iso8859_6_bidi_str_reorder (Glyph32* glyphs, int len) -{ - - return bidi_str_reorder (FONT_CHARSET_ISO8859_6, glyphs, len); -} - - /*if cur_len>1, search ligature shape, * else search letter or phonetic symbol shape*/ static Glyph32 iso8859_6_glyph_shape (const unsigned char* cur_mchar, @@ -714,6 +821,26 @@ static Glyph32 iso8859_6_glyph_shape (const unsigned char* cur_mchar, return glyph_value; } +static const BIDICHAR_MIRROR_MAP __mg_iso8859_68x_mirror_table [] = +{ + {0x0028, 0x0029}, + {0x0029, 0x0028}, + {0x003C, 0x003E}, + {0x003E, 0x003C}, + {0x005B, 0x005D}, + {0x005D, 0x005B}, + {0x007B, 0x007D}, + {0x007D, 0x007B}, +// {0x00AB, 0x00BB}, +// {0x00BB, 0x00AB} +}; + +static BOOL iso8859_6_bidi_mirror_glyph (Glyph32 glyph, Glyph32* mirrored) +{ + return get_mirror_glyph (__mg_iso8859_68x_mirror_table, + TABLESIZE (__mg_iso8859_68x_mirror_table), glyph, mirrored); +} + static CHARSETOPS CharsetOps_iso8859_6 = { 256, 3, @@ -722,14 +849,14 @@ static CHARSETOPS CharsetOps_iso8859_6 = { iso8859_6_len_first_char, iso8859_6_char_glyph_value, iso8859_6_glyph_shape, - iso8859_6_bidi_glyph_type, iso8859_6_glyph_type, sb_nr_chars_in_str, iso8859_6_is_this_charset, sb_len_first_substr, iso8859_6_get_next_word, sb_pos_first_char, - iso8859_6_bidi_str_reorder, + iso8859_6_bidi_mirror_glyph, + iso8859_6_bidi_glyph_type, #ifdef _MGCHARSET_UNICODE iso8859_6_conv_to_uc32, iso8859_6_conv_from_uc32 @@ -752,5 +879,4 @@ int test_glyph_value (int char_index, Glyph32 glyph_value) } #endif - #endif /* _ARABIC */ diff --git a/src/font/charset-bidi.c b/src/font/charset-bidi.c index 77645407..43e4a18e 100644 --- a/src/font/charset-bidi.c +++ b/src/font/charset-bidi.c @@ -42,18 +42,11 @@ #include #include -#ifndef MAIN_CAP_TEST - #include "common.h" - #include "minigui.h" - #include "gdi.h" -#endif - -#ifdef MAIN_CAP_TEST - typedef int BOOL; - #define TRUE 1 - #define FALSE 0 -#endif +#include "common.h" +#include "minigui.h" +#include "gdi.h" +#include "devfont.h" #include "bidi.h" #define BIDI_MAX(a,b) ((a) > (b) ? (a) : (b)) @@ -70,228 +63,11 @@ struct _TYPERUN struct _TYPERUN *prev; struct _TYPERUN *next; - BidiCharType type; /* char type. */ - BidiStrIndex pos, len; /* run start position、run len.*/ - BidiLevel level; /* Embedding level. */ + BidiCharType type; /* char type. */ + int pos, len; /* run start position、run len.*/ + BYTE level; /* Embedding level. */ }; -BidiCharType __mg_iso8859_68x_type[] = { - /*0x00~0x0f*/ - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_SS, BIDI_TYPE_BS, BIDI_TYPE_SS, - BIDI_TYPE_WS, BIDI_TYPE_BS, BIDI_TYPE_BN, BIDI_TYPE_BN, - - /*0x10~0x1f*/ - BIDI_TYPE_BN, BIDI_TYPE_BN, BID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E_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_ON, - - /*0xf0~0xff*/ - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_ON, - - /*0x100~0x10f*/ - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - - /*0x110~0x11f*/ - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - - /*0x120~0x12f*/ - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, - - /*0x130~0x133*/ - BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, BIDI_TYPE_AL, -}; - -BidiCharType __mg_iso8859_8_type[] = { - /*0x00~0x0f*/ - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_SS, BIDI_TYPE_BS, BIDI_TYPE_SS, - BIDI_TYPE_WS, BIDI_TYPE_BS, BIDI_TYPE_BN, BIDI_TYPE_BN, - - /*0x10~0x1f*/ - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BS, BIDI_TYPE_BS, BIDI_TYPE_BS, BIDI_TYPE_SS, - - /*0x20~0x2f*/ - BIDI_TYPE_WS, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ET, - BIDI_TYPE_ET, BIDI_TYPE_ET, BIDI_TYPE_ON, BIDI_TYPE_ON, - BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ES, - BIDI_TYPE_CS, BIDI_TYPE_ES, BIDI_TYPE_CS, BIDI_TYPE_CS, - - /*0x30~0x3f*/ - BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, - BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, - BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_CS, BIDI_TYPE_ON, - BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, - - /*0x40~0x4f*/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_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - - /*0xd0~0xdf*/ - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_ON, - - /*0xe0~0xef*/ - BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, - BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, - BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, - BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_ON, - - /*0xf0~0xff*/ - BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, - BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, - BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, - BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_BN, - BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, -}; - - #ifdef BIDI_DEBUG static char bidi_type_name(BidiCharType c) @@ -319,7 +95,7 @@ static void print_resolved_levels(TYPERUN *pp) { fprintf(stderr, " Levels: "); while(pp){ - BidiStrIndex i; + int i; for(i = 0; i < LEN (pp); i++) fprintf(stderr, "%c", bidi_level[(int)LEVEL(pp)]); pp = pp->next; @@ -332,7 +108,7 @@ static void print_resolved_types(TYPERUN *pp) fprintf(stderr, " Types: "); while(pp) { - BidiStrIndex i; + int i; for(i = 0; i < LEN (pp); i++) fprintf(stderr, "%c", bidi_type_name(pp->type)); pp = pp->next; @@ -357,15 +133,34 @@ static void print_run_types(TYPERUN *pp) fprintf (stderr, "\n"); } -#endif - -BidiCharType* ptype_table = NULL; - -static int get_glyph_type(Glyph32 glyph) +static void print_hexstr(Glyph32* str, int len, BOOL reorder_state) { - return ptype_table[REAL_GLYPH(glyph)]; + int m = 0; + + DBGLOG("\n====================================================\n"); + if(!reorder_state) + DBGLOG("Reorder one line start.\n"); + else + DBGLOG("Reorder one line end.\n"); + + DBGLOG(" "); + for(m = 0; m < len; m++){ + if(m && !(m%16)) DBGLOG("\n "); + DBGLOG2("0x%02x ", (unsigned char)str[m]); + } + DBGLOG("\n====================================================\n"); + } +#else /* BIDI_DEBUG */ + +inline static void print_hexstr(Glyph32* str, int len, BOOL reorder_state) +{ + return; +} + +#endif /* !BIDI_DEBUG */ + static void free_typerun_list (TYPERUN *type_rl_list) { TYPERUN *pp; @@ -423,11 +218,11 @@ static void compact_neutrals (TYPERUN *list) (p) = (q); \ } while (0) -static TYPERUN* get_runtype_link(Glyph32* glyphs, BidiStrIndex len) +static TYPERUN* get_runtype_link (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len) { int type = 0; TYPERUN *list, *last, *link; - BidiStrIndex i; + int i; /* Add the starting link */ list = calloc(1, sizeof(TYPERUN)); @@ -436,7 +231,7 @@ static TYPERUN* get_runtype_link(Glyph32* glyphs, BidiStrIndex len) last = list; for (i = 0; i < len; i++){ - if ((type = get_glyph_type(glyphs[i])) != last->type){ + if ((type = charset_ops->bidi_glyph_type (glyphs[i])) != last->type){ link = calloc(1, sizeof(TYPERUN)); link->type = type; link->pos = i; @@ -456,7 +251,7 @@ static TYPERUN* get_runtype_link(Glyph32* glyphs, BidiStrIndex len) /* 1.Find base level */ -static void bidi_resolveParagraphs(TYPERUN **ptype_rl_list, BidiCharType* pbase_dir, BidiLevel* pbase_level) +static void bidi_resolveParagraphs(TYPERUN **ptype_rl_list, BidiCharType* pbase_dir, BYTE* pbase_level) { TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL; DBGLOG("\n1:Finding the base level\n"); @@ -603,11 +398,9 @@ static void bidi_resolveWeak(TYPERUN **ptype_rl_list, BidiCharType base_dir) compact_neutrals (type_rl_list); #ifdef BIDI_DEBUG - if (bidi_debug){ - print_run_types(type_rl_list); - print_resolved_levels (type_rl_list); - print_resolved_types (type_rl_list); - } + print_run_types(type_rl_list); + print_resolved_levels (type_rl_list); + print_resolved_types (type_rl_list); #endif } @@ -639,11 +432,9 @@ static void bidi_resolveNeutrals(TYPERUN **ptype_rl_list, BidiCharType base_bir) } compact_list (type_rl_list); #ifdef BIDI_DEBUG - if (bidi_debug){ - print_run_types(type_rl_list); - print_resolved_levels (type_rl_list); - print_resolved_types (type_rl_list); - } + print_run_types(type_rl_list); + print_resolved_levels (type_rl_list); + print_resolved_types (type_rl_list); #endif } @@ -673,79 +464,16 @@ static int bidi_resolveImplicit(TYPERUN **ptype_rl_list, int base_level) } compact_list (type_rl_list); #ifdef BIDI_DEBUG - if (bidi_debug){ - print_run_types(type_rl_list); - print_resolved_levels (type_rl_list); - print_resolved_types (type_rl_list); - } + print_run_types(type_rl_list); + print_resolved_levels (type_rl_list); + print_resolved_types (type_rl_list); #endif return max_level; } -typedef struct _BIDIMIRROR -{ - BidiChar ch, mirrored_ch; -}BIDIMIRROR; - -static const BIDIMIRROR BidiMirroredChars[] = -{ - {0x0028, 0x0029}, - {0x0029, 0x0028}, - {0x003C, 0x003E}, - {0x003E, 0x003C}, - {0x005B, 0x005D}, - {0x005D, 0x005B}, - {0x007B, 0x007D}, - {0x007D, 0x007B}, -// {0x00AB, 0x00BB}, -// {0x00BB, 0x00AB} -}; - -const int __mg_n_bidi_mirrored_chars = sizeof(BidiMirroredChars)/(sizeof(BIDIMIRROR)); - -static BOOL bidi_get_mirror_char (BidiChar ch, BidiChar *mirrored_ch) -{ - int pos, step; - BOOL found; - BOOL is_mbc; - - pos = step = (__mg_n_bidi_mirrored_chars / 2) + 1; - - is_mbc = IS_MBC_GLYPH(ch); - ch = REAL_GLYPH(ch); - - while (step > 1) { - BidiChar cmp_ch = BidiMirroredChars[pos].ch; - step = (step + 1) / 2; - - if (cmp_ch < ch) { - pos += step; - if (pos > __mg_n_bidi_mirrored_chars - 1) - pos = __mg_n_bidi_mirrored_chars - 1; - } - else if (cmp_ch > ch) { - pos -= step; - if (pos < 0) - pos = 0; - } - else - break; - } - found = BidiMirroredChars[pos].ch == ch; - - if (mirrored_ch){ - *mirrored_ch = found ? BidiMirroredChars[pos].mirrored_ch : ch; - /* use the same mbc font for mirror char. */ - if(is_mbc) - *mirrored_ch = SET_MBC_GLYPH(*mirrored_ch); - } - - return found; -} - /* 6.Resolving Mirrored Char. */ static void -bidi_resolveMirrorChar(Glyph32* glyphs, BidiStrIndex len, +bidi_resolveMirrorChar (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, TYPERUN **ptype_rl_list, int base_level) { TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL; @@ -755,23 +483,23 @@ bidi_resolveMirrorChar(Glyph32* glyphs, BidiStrIndex len, for (pp = type_rl_list->next; pp->next; pp = pp->next) { if (pp->level & 1) { - BidiStrIndex i; + int i; for (i = POS (pp); i < POS (pp) + LEN (pp); i++) { - BidiChar mirrored_ch; - if (bidi_get_mirror_char(glyphs[i], &mirrored_ch)) + Glyph32 mirrored_ch; + if (charset_ops->bidi_mirror_glyph && charset_ops->bidi_mirror_glyph (glyphs[i], &mirrored_ch)) glyphs[i] = mirrored_ch; } } } - DBGLOG (" Mirroring, Done\n"); + DBGLOG (" Mirroring, Done\n"); } -static void bidi_map_reverse (void* context, BidiStrIndex len, int pos) +static void bidi_map_reverse (void* context, int len, int pos) { GLYPHMAPINFO* str = (GLYPHMAPINFO*)context + pos; - BidiStrIndex i; + int i; for (i = 0; i < len / 2; i++) { GLYPHMAPINFO tmp = str[i]; @@ -780,10 +508,10 @@ static void bidi_map_reverse (void* context, BidiStrIndex len, int pos) } } -static void bidi_index_reverse (void* context, BidiStrIndex len, int pos) +static void bidi_index_reverse (void* context, int len, int pos) { char* str = (char*)context + pos; - BidiStrIndex i; + int i; for (i = 0; i < len / 2; i++) { char tmp = str[i]; @@ -792,27 +520,27 @@ static void bidi_index_reverse (void* context, BidiStrIndex len, int pos) } } -static void bidi_string_reverse (void* context, BidiStrIndex len, int pos) +static void bidi_string_reverse (void* context, int len, int pos) { - BidiChar* str = (BidiChar*)context + pos; - BidiStrIndex i; + Glyph32* str = (Glyph32*)context + pos; + int i; for (i = 0; i < len / 2; i++) { - BidiChar tmp = str[i]; + Glyph32 tmp = str[i]; str[i] = str[len - 1 - i]; str[len - 1 - i] = tmp; } } -static void bidi_resolve_string(Glyph32* glyphs, BidiStrIndex len, - TYPERUN **ptype_rl_list, BidiLevel *pmax_level) +static void bidi_resolve_string (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, + TYPERUN **ptype_rl_list, BYTE *pmax_level) { - BidiLevel base_level = 0; + BYTE base_level = 0; BidiCharType base_dir = BIDI_TYPE_L; TYPERUN *type_rl_list = NULL; /* split the text to some runs. */ - type_rl_list = get_runtype_link(glyphs, len); + type_rl_list = get_runtype_link (charset_ops, glyphs, len); /* 1.Find base level */ bidi_resolveParagraphs(&type_rl_list, &base_dir, &base_level); @@ -830,60 +558,13 @@ static void bidi_resolve_string(Glyph32* glyphs, BidiStrIndex len, *pmax_level = bidi_resolveImplicit(&type_rl_list, base_level); /* 6.Resolving Mirrored Char. */ - bidi_resolveMirrorChar(glyphs, len, &type_rl_list, base_level); + bidi_resolveMirrorChar (charset_ops, glyphs, len, &type_rl_list, base_level); *ptype_rl_list = type_rl_list; } -BidiCharType bidi_str_base_dir(Glyph32* glyphs, BidiStrIndex len) -{ - BidiLevel base_level = 0; - BidiCharType base_dir = BIDI_TYPE_L; - TYPERUN *type_rl_list = NULL; - - /* split the text to some runs. */ - type_rl_list = get_runtype_link(glyphs, len); - - /* 1.Find base level */ - bidi_resolveParagraphs(&type_rl_list, &base_dir, &base_level); - - /* free typerun list.*/ - free_typerun_list(type_rl_list); - - return base_dir; -} - -static void print_hexstr(Glyph32* str, int len, BOOL reorder_state) -{ - int m = 0; - - DBGLOG("\n====================================================\n"); - if(!reorder_state) - DBGLOG("Reorder one line start.\n"); - else - DBGLOG("Reorder one line end.\n"); - - DBGLOG(" "); - for(m = 0; m < len; m++){ - if(m && !(m%16)) DBGLOG("\n "); - DBGLOG2("0x%02x ", (unsigned char)str[m]); - } - DBGLOG("\n====================================================\n"); - -} - -static void bidi_set_typetable(const char* charset_name) -{ -#ifndef MAIN_CAP_TEST - if (strcmp (charset_name, FONT_CHARSET_ISO8859_6) == 0) - ptype_table = __mg_iso8859_68x_type; - else if (strcmp (charset_name, FONT_CHARSET_ISO8859_8) == 0) - ptype_table = __mg_iso8859_8_type; -#endif -} - -static void bidi_reorder_cb(void* context, BidiStrIndex len, - TYPERUN **ptype_rl_list, BidiLevel max_level, CB_DO_REORDER cb) +static void bidi_reorder_cb (void* context, int len, + TYPERUN **ptype_rl_list, BYTE max_level, CB_DO_REORDER cb) { int i = 0; TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL; @@ -895,7 +576,7 @@ static void bidi_reorder_cb(void* context, BidiStrIndex len, for (pp = type_rl_list->next; pp->next; pp = pp->next){ if (LEVEL (pp) >= i){ /* Find all stretches that are >= i.*/ - BidiStrIndex len = LEN(pp), pos = POS(pp); + int len = LEN(pp), pos = POS(pp); TYPERUN *pp1 = pp->next; while (pp1->next && LEVEL(pp1) >= i){ len += LEN(pp1); @@ -909,27 +590,21 @@ static void bidi_reorder_cb(void* context, BidiStrIndex len, DBGLOG("\nReordering, Done\n"); } -void bidi_get_embeddlevels(const char* charset_name, Glyph32* glyphs, BidiStrIndex len, +void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, Uint8* embedding_level_list, Uint8 type) { int i = 0; - BidiLevel max_level = 1; + BYTE max_level = 1; TYPERUN *type_rl_list = NULL, *pp; -#ifdef BIDI_DEBUG - bidi_debug = TRUE; -#endif - - bidi_set_typetable(charset_name); - print_hexstr(glyphs, len, FALSE); /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */ - bidi_resolve_string(glyphs, len, &type_rl_list, &max_level); + bidi_resolve_string (charset_ops, glyphs, len, &type_rl_list, &max_level); /* type = 0, get the logical embedding level; else visual level.*/ for (pp = type_rl_list->next; pp->next; pp = pp->next){ - BidiStrIndex pos = POS (pp), len = LEN (pp); + int pos = POS (pp), len = LEN (pp); for(i = 0; i < len; i++) embedding_level_list[pos + i] = LEVEL(pp); } @@ -944,26 +619,20 @@ void bidi_get_embeddlevels(const char* charset_name, Glyph32* glyphs, BidiStrInd print_hexstr(glyphs, len, TRUE); } -Glyph32* bidi_map_reorder (const char* charset_name, Glyph32* glyphs, +Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, GLYPHMAPINFO* map) { - BidiLevel max_level = 1; + BYTE max_level = 1; TYPERUN *type_rl_list = NULL; TYPERUN *node_p = NULL; int i; int run_pos; int run_len; -#ifdef BIDI_DEBUG - bidi_debug = TRUE; -#endif - - bidi_set_typetable(charset_name); - print_hexstr(glyphs, len, FALSE); /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */ - bidi_resolve_string(glyphs, len, &type_rl_list, &max_level); + bidi_resolve_string (charset_ops, glyphs, len, &type_rl_list, &max_level); for (node_p=type_rl_list->next; node_p->next; node_p=node_p->next) @@ -988,22 +657,16 @@ Glyph32* bidi_map_reorder (const char* charset_name, Glyph32* glyphs, return glyphs; } -Glyph32* bidi_index_reorder (const char* charset_name, Glyph32* glyphs, +Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, int* index_map) { - BidiLevel max_level = 1; + BYTE max_level = 1; TYPERUN *type_rl_list = NULL; -#ifdef BIDI_DEBUG - bidi_debug = TRUE; -#endif - - bidi_set_typetable(charset_name); - print_hexstr(glyphs, len, FALSE); /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */ - bidi_resolve_string(glyphs, len, &type_rl_list, &max_level); + bidi_resolve_string (charset_ops, glyphs, len, &type_rl_list, &max_level); bidi_reorder_cb(index_map, len, &type_rl_list, max_level, bidi_string_reverse); @@ -1016,101 +679,41 @@ Glyph32* bidi_index_reorder (const char* charset_name, Glyph32* glyphs, return glyphs; } -int bidi_glyph_type(const char* charset_name, Glyph32 glyph_value) +Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len) { - bidi_set_typetable(charset_name); - return ptype_table[REAL_GLYPH(glyph_value)]; -} - -Glyph32* bidi_str_reorder (const char* charset_name, Glyph32* glyphs, int len) -{ - BidiLevel max_level = 1; + BYTE max_level = 1; TYPERUN *type_rl_list = NULL; -#ifdef BIDI_DEBUG - bidi_debug = TRUE; -#endif - - bidi_set_typetable(charset_name); - print_hexstr(glyphs, len, FALSE); /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */ - bidi_resolve_string(glyphs, len, &type_rl_list, &max_level); + bidi_resolve_string (charset_ops, glyphs, len, &type_rl_list, &max_level); - bidi_reorder_cb(glyphs, len, &type_rl_list, max_level, - bidi_string_reverse); + bidi_reorder_cb (glyphs, len, &type_rl_list, max_level, bidi_string_reverse); + + /* free typerun list.*/ + free_typerun_list (type_rl_list); + + print_hexstr (glyphs, len, TRUE); + + return glyphs; +} + +BidiCharType __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len) +{ + BYTE base_level = 0; + BidiCharType base_dir = BIDI_TYPE_L; + TYPERUN *type_rl_list = NULL; + + /* split the text to some runs. */ + type_rl_list = get_runtype_link (charset_ops, glyphs, len); + + /* 1.Find base level */ + bidi_resolveParagraphs(&type_rl_list, &base_dir, &base_level); /* free typerun list.*/ free_typerun_list(type_rl_list); - print_hexstr(glyphs, len, TRUE); - - - return glyphs; + return base_dir; } -#ifdef MAIN_CAP_TEST - -/* test bidi reorder alone, use the CapRTLType.*/ -// gcc charset-bidi.c -DMAIN_CAP_TEST -g -o charset-bidi -lminigui_ths -lm -ljpeg -lz -lpng -lpthread - -#define LRE 0 -#define RLE 0 -#define PDF 0 -#define RLO 0 -#define LRO 0 - -#define LTR BIDI_TYPE_LTR -#define AL BIDI_TYPE_AL -#define RTL BIDI_TYPE_RTL -#define WS BIDI_TYPE_WS -#define ON BIDI_TYPE_ON -#define EN BIDI_TYPE_EN -#define AN BIDI_TYPE_AN -#define ET BIDI_TYPE_ET -#define ES BIDI_TYPE_ES -#define SS BIDI_TYPE_SS -#define CS BIDI_TYPE_CS -#define BS BIDI_TYPE_BS -#define NSM BIDI_TYPE_NSM - -static BidiCharType CapRTLTypes[] = { - /* *INDENT-OFF* */ - ON, ON, ON, ON, LTR,RTL,ON, ON, ON, ON, ON, ON, ON, BS, RLO,RLE, /* 00-0f */ - LRO,LRE,PDF,WS, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, /* 10-1f */ - WS, ON, ON, ON, ET, ON, ON, ON, ON, ON, ON, ET, CS, ON, ES, ES, /* 20-2f */ - EN, EN, EN, EN, EN, EN, AN, AN, AN, AN, CS, ON, ON, ON, ON, ON, /* 30-3f */ - RTL,AL, AL, AL, AL, AL, AL, RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL, /* 40-4f */ - RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,RTL,ON, BS, ON, ON, ON, /* 50-5f */ - NSM,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR, /* 60-6f */ - LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,LTR,ON, SS, ON, WS, ON, /* 70-7f */ - /* *INDENT-ON* */ -}; - -int main(int args, const char* argv[]) -{ - int i = 0; - BidiCharType base_dir = 0; - Glyph32* visual_glyphs = NULL; - //char bidi_str_n[] = "this is only a test ARABIC."; - char bidi_str_n[] = "ARABIC this is only a test."; - - /* open debug.*/ - bidi_debug = TRUE; - - ptype_table = CapRTLTypes; - visual_glyphs = bidi_str_reorder((Glyph32*)bidi_str_n, strlen(bidi_str_n)); - if(base_dir%2){ - fprintf(stderr, "%s===>%s\n", bidi_str_n, visual_glyphs); - } - else{ - /* output right align. */ - fprintf(stderr, "%s===> %s\n", bidi_str_n, visual_glyphs); - } - - return 0; -} - -#endif - diff --git a/src/font/charset.c b/src/font/charset.c index ad195b58..5d27cb66 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -222,7 +222,6 @@ static CHARSETOPS CharsetOps_ascii = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, ascii_is_this_charset, @@ -230,6 +229,7 @@ static CHARSETOPS CharsetOps_ascii = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE ascii_conv_to_uc32, ascii_conv_from_uc32 @@ -285,7 +285,6 @@ static CHARSETOPS CharsetOps_iso8859_1 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_1_is_this_charset, @@ -293,6 +292,7 @@ static CHARSETOPS CharsetOps_iso8859_1 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_1_conv_to_uc32, iso8859_1_conv_from_uc32 @@ -396,7 +396,6 @@ static CHARSETOPS CharsetOps_iso8859_2 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_2_is_this_charset, @@ -404,6 +403,7 @@ static CHARSETOPS CharsetOps_iso8859_2 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_2_conv_to_uc32, iso8859_2_conv_from_uc32, @@ -508,7 +508,6 @@ static CHARSETOPS CharsetOps_iso8859_3 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_3_is_this_charset, @@ -516,6 +515,7 @@ static CHARSETOPS CharsetOps_iso8859_3 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_3_conv_to_uc32, iso8859_3_conv_from_uc32, @@ -622,7 +622,6 @@ static CHARSETOPS CharsetOps_iso8859_4 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_4_is_this_charset, @@ -630,6 +629,7 @@ static CHARSETOPS CharsetOps_iso8859_4 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_4_conv_to_uc32, iso8859_4_conv_from_uc32 @@ -716,7 +716,6 @@ static CHARSETOPS CharsetOps_iso8859_5 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_5_is_this_charset, @@ -724,6 +723,7 @@ static CHARSETOPS CharsetOps_iso8859_5 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_5_conv_to_uc32, iso8859_5_conv_from_uc32, @@ -732,6 +732,53 @@ static CHARSETOPS CharsetOps_iso8859_5 = { #endif /* _CYRILLIC */ +#if defined (_MGCHARSET_HEBREW) || defined (_MGCHARSET_ARABIC) || defined (_MGCHARSET_UNICODE) + +#include "bidi.h" + +static BOOL get_mirror_glyph (const BIDICHAR_MIRROR_MAP* map, int n, Glyph32 glyph, Glyph32* mirrored) +{ + int pos, step; + BOOL found = FALSE; + BOOL is_mbc; + + pos = step = (n / 2) + 1; + + is_mbc = IS_MBC_GLYPH(glyph); + glyph = REAL_GLYPH(glyph); + + while (step > 1) { + Glyph32 cmp_glyph = map[pos].glyph; + step = (step + 1) / 2; + + if (cmp_glyph < glyph) { + pos += step; + if (pos > n - 1) + pos = n - 1; + } + else if (cmp_glyph > glyph) { + pos -= step; + if (pos < 0) + pos = 0; + } + else + break; + } + + found = map[pos].glyph == glyph; + + if (mirrored){ + *mirrored = found ? map[pos].mirrored : glyph; + /* use the same mbc font for mirror char. */ + if(is_mbc) + *mirrored = SET_MBC_GLYPH(*mirrored); + } + + return found; +} + +#endif /* definede (_MGCHARSET_HEBREW) || defined (_MGCHARSET_ARABIC) || defined (_MGCHARSET_UNICODE) */ + /* houhh 20080123 */ #ifdef _MGCHARSET_ARABIC #include "charset-arabic.c" @@ -822,7 +869,6 @@ static CHARSETOPS CharsetOps_iso8859_7 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_7_is_this_charset, @@ -830,6 +876,7 @@ static CHARSETOPS CharsetOps_iso8859_7 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_7_conv_to_uc32, iso8859_7_conv_from_uc32 @@ -840,8 +887,6 @@ static CHARSETOPS CharsetOps_iso8859_7 = { #ifdef _MGCHARSET_HEBREW -#include "bidi.h" - /************************* ISO8859-8 Specific Operations **********************/ static int iso8859_8_is_this_charset (const unsigned char* charset) { @@ -904,19 +949,128 @@ static const unsigned char* iso8859_8_get_next_word (const unsigned char* mstr, //return sb_get_next_word(mstr, mstrlen, word_info); } -static Glyph32* iso8859_8_bidi_str_reorder (Glyph32* glyphs, int len) -{ - return bidi_str_reorder (FONT_CHARSET_ISO8859_8, glyphs, len); -} +static BidiCharType __mg_iso8859_8_type[] = { + /*0x00~0x0f*/ + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_SS, BIDI_TYPE_BS, BIDI_TYPE_SS, + BIDI_TYPE_WS, BIDI_TYPE_BS, BIDI_TYPE_BN, BIDI_TYPE_BN, + + /*0x10~0x1f*/ + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, + BIDI_TYPE_BS, BIDI_TYPE_BS, BIDI_TYPE_BS, BIDI_TYPE_SS, + + /*0x20~0x2f*/ + BIDI_TYPE_WS, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ET, + BIDI_TYPE_ET, BIDI_TYPE_ET, BIDI_TYPE_ON, BIDI_TYPE_ON, + BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ES, + BIDI_TYPE_CS, BIDI_TYPE_ES, BIDI_TYPE_CS, BIDI_TYPE_CS, + + /*0x30~0x3f*/ + BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, + BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_EN, + BIDI_TYPE_EN, BIDI_TYPE_EN, BIDI_TYPE_CS, BIDI_TYPE_ON, + BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, BIDI_TYPE_ON, + + /*0x40~0x4f*/ + BIDI_TYPE_ON, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, + BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, + BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, + BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, + + /*0x50~0x6f*/ + BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, BIDI_TYPE_LTR, + BIDI_TYPE_LTR, BIDI_TYPE_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I_TYPE_RTL, + BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, + BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, + BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_ON, + + /*0xf0~0xff*/ + BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, + BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, + BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, + BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_RTL, BIDI_TYPE_BN, + BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, BIDI_TYPE_BN, +}; static unsigned int iso8859_8_bidi_glyph_type (Glyph32 glyph_value) { - unsigned int ch_type = BIDI_TYPE_AL; + return __mg_iso8859_8_type [REAL_GLYPH(glyph_value)]; +} - ch_type = bidi_glyph_type(FONT_CHARSET_ISO8859_8, glyph_value); +static const BIDICHAR_MIRROR_MAP __mg_iso8859_8_mirror_table [] = +{ + {0x0028, 0x0029}, + {0x0029, 0x0028}, + {0x003C, 0x003E}, + {0x003E, 0x003C}, + {0x005B, 0x005D}, + {0x005D, 0x005B}, + {0x007B, 0x007D}, + {0x007D, 0x007B}, +// {0x00AB, 0x00BB}, +// {0x00BB, 0x00AB} +}; - return ch_type; +static BOOL iso8859_8_bidi_mirror_glyph (Glyph32 glyph, Glyph32* mirrored) +{ + return get_mirror_glyph (__mg_iso8859_8_mirror_table, + TABLESIZE (__mg_iso8859_8_mirror_table), glyph, mirrored); } #ifdef _MGCHARSET_UNICODE @@ -982,14 +1136,14 @@ static CHARSETOPS CharsetOps_iso8859_8 = { sb_len_first_char, sb_char_glyph_value, NULL, - iso8859_8_bidi_glyph_type, sb_glyph_type, sb_nr_chars_in_str, iso8859_8_is_this_charset, sb_len_first_substr, iso8859_8_get_next_word, sb_pos_first_char, - iso8859_8_bidi_str_reorder, + iso8859_8_bidi_glyph_type, + iso8859_8_bidi_mirror_glyph, #ifdef _MGCHARSET_UNICODE iso8859_8_conv_to_uc32, iso8859_8_conv_from_uc32 @@ -1083,7 +1237,6 @@ static CHARSETOPS CharsetOps_iso8859_9 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_9_is_this_charset, @@ -1091,6 +1244,7 @@ static CHARSETOPS CharsetOps_iso8859_9 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_9_conv_to_uc32, iso8859_9_conv_from_uc32 @@ -1196,7 +1350,6 @@ static CHARSETOPS CharsetOps_iso8859_10 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_10_is_this_charset, @@ -1204,6 +1357,7 @@ static CHARSETOPS CharsetOps_iso8859_10 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_10_conv_to_uc32, iso8859_10_conv_from_uc32 @@ -1308,7 +1462,6 @@ static CHARSETOPS CharsetOps_iso8859_11 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_11_is_this_charset, @@ -1316,6 +1469,7 @@ static CHARSETOPS CharsetOps_iso8859_11 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_11_conv_to_uc32, iso8859_11_conv_from_uc32 @@ -1420,7 +1574,6 @@ static CHARSETOPS CharsetOps_iso8859_13 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_13_is_this_charset, @@ -1428,6 +1581,7 @@ static CHARSETOPS CharsetOps_iso8859_13 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_13_conv_to_uc32, iso8859_13_conv_from_uc32 @@ -1532,7 +1686,6 @@ static CHARSETOPS CharsetOps_iso8859_14 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_14_is_this_charset, @@ -1540,6 +1693,7 @@ static CHARSETOPS CharsetOps_iso8859_14 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_14_conv_to_uc32, iso8859_14_conv_from_uc32 @@ -1643,7 +1797,6 @@ static CHARSETOPS CharsetOps_iso8859_15 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_15_is_this_charset, @@ -1651,6 +1804,7 @@ static CHARSETOPS CharsetOps_iso8859_15 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_15_conv_to_uc32, iso8859_15_conv_from_uc32 @@ -1793,7 +1947,6 @@ static CHARSETOPS CharsetOps_iso8859_16 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, iso8859_16_is_this_charset, @@ -1801,6 +1954,7 @@ static CHARSETOPS CharsetOps_iso8859_16 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE iso8859_16_conv_to_uc32, iso8859_16_conv_from_uc32 @@ -1990,7 +2144,6 @@ static CHARSETOPS CharsetOps_gb2312_0 = { gb2312_0_len_first_char, gb2312_0_char_glyph_value, NULL, - NULL, mb_glyph_type, db_nr_chars_in_str, gb2312_0_is_this_charset, @@ -1998,6 +2151,7 @@ static CHARSETOPS CharsetOps_gb2312_0 = { db_get_next_word, gb2312_0_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE gb2312_0_conv_to_uc32, gb2312_0_conv_from_uc32 @@ -2148,7 +2302,6 @@ static CHARSETOPS CharsetOps_gbk = { gbk_len_first_char, gbk_char_glyph_value, NULL, - NULL, mb_glyph_type, db_nr_chars_in_str, gbk_is_this_charset, @@ -2156,6 +2309,7 @@ static CHARSETOPS CharsetOps_gbk = { db_get_next_word, gbk_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE gbk_conv_to_uc32, gbk_conv_from_uc32, @@ -2414,7 +2568,6 @@ static CHARSETOPS CharsetOps_gb18030_0 = { gb18030_0_len_first_char, gb18030_0_char_glyph_value, NULL, - NULL, mb_glyph_type, gb18030_0_nr_chars_in_str, gb18030_0_is_this_charset, @@ -2422,6 +2575,7 @@ static CHARSETOPS CharsetOps_gb18030_0 = { gb18030_0_get_next_word, gb18030_0_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE gb18030_0_conv_to_uc32, gb18030_0_conv_from_uc32 @@ -2571,7 +2725,6 @@ static CHARSETOPS CharsetOps_big5 = { big5_len_first_char, big5_char_glyph_value, NULL, - NULL, mb_glyph_type, db_nr_chars_in_str, big5_is_this_charset, @@ -2579,6 +2732,7 @@ static CHARSETOPS CharsetOps_big5 = { db_get_next_word, big5_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE big5_conv_to_uc32, big5_conv_from_uc32, @@ -2717,7 +2871,6 @@ static CHARSETOPS CharsetOps_ksc5601_0 = { ksc5601_0_len_first_char, ksc5601_0_char_glyph_value, NULL, - NULL, mb_glyph_type, db_nr_chars_in_str, ksc5601_0_is_this_charset, @@ -2725,6 +2878,7 @@ static CHARSETOPS CharsetOps_ksc5601_0 = { db_get_next_word, ksc5601_0_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE ksc5601_0_conv_to_uc32, ksc5601_0_conv_from_uc32, @@ -2842,7 +2996,6 @@ static CHARSETOPS CharsetOps_jisx0201_0 = { jisx0201_0_len_first_char, jisx0201_0_char_glyph_value, NULL, - NULL, sb_glyph_type, jisx0201_0_nr_chars_in_str, jisx0201_0_is_this_charset, @@ -2850,6 +3003,7 @@ static CHARSETOPS CharsetOps_jisx0201_0 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE jisx0201_0_conv_to_uc32, jisx0201_0_conv_from_uc32, @@ -2985,7 +3139,6 @@ static CHARSETOPS CharsetOps_jisx0208_0 = { jisx0208_0_len_first_char, jisx0208_0_char_glyph_value, NULL, - NULL, mb_glyph_type, db_nr_chars_in_str, jisx0208_0_is_this_charset, @@ -2993,6 +3146,7 @@ static CHARSETOPS CharsetOps_jisx0208_0 = { db_get_next_word, jisx0208_0_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE jisx0208_0_conv_to_uc32, jisx0208_0_conv_from_uc32, @@ -3070,7 +3224,6 @@ static CHARSETOPS CharsetOps_jisx0201_1 = { sb_len_first_char, sb_char_glyph_value, NULL, - NULL, sb_glyph_type, sb_nr_chars_in_str, jisx0201_1_is_this_charset, @@ -3078,6 +3231,7 @@ static CHARSETOPS CharsetOps_jisx0201_1 = { sb_get_next_word, sb_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE jisx0201_1_conv_to_uc32, jisx0201_1_conv_from_uc32, @@ -3241,7 +3395,6 @@ static CHARSETOPS CharsetOps_jisx0208_1 = { jisx0208_1_len_first_char, jisx0208_1_char_glyph_value, NULL, - NULL, mb_glyph_type, db_nr_chars_in_str, jisx0208_1_is_this_charset, @@ -3249,6 +3402,7 @@ static CHARSETOPS CharsetOps_jisx0208_1 = { db_get_next_word, jisx0208_1_pos_first_char, NULL, + NULL, #ifdef _MGCHARSET_UNICODE jisx0208_1_conv_to_uc32, jisx0208_1_conv_from_uc32 @@ -3324,14 +3478,48 @@ static Glyph32 utf8_char_glyph_value (const unsigned char* pre_mchar, int pre_l ? TTYPE_PART1 ((Char) >> 8, (Char) & 0xff) \ : G_UNICODE_UNASSIGNED) +#include "unicode-bidi-tables.h" + +static unsigned int unicode_bidi_glyph_type (Glyph32 glyph_value) +{ + Glyph32 glyph_first = 0; + Glyph32 glyph_last = (Glyph32)TABLESIZE (__mg_unicode_bidi_char_type_map); + Glyph32 glyph_mid; + + while (glyph_last >= glyph_first) { + glyph_mid = (glyph_first + glyph_last)/2; + + if ((__mg_unicode_bidi_char_type_map[glyph_mid].glyph <= glyph_value) + && ((__mg_unicode_bidi_char_type_map[glyph_mid].glyph + __mg_unicode_bidi_char_type_map[glyph_mid].count) > glyph_value)) { + return __mg_unicode_bidi_char_type_map[glyph_mid].type; + } + + if (glyph_value >= (__mg_unicode_bidi_char_type_map[glyph_mid].glyph + __mg_unicode_bidi_char_type_map[glyph_mid].count)) { + glyph_first = glyph_mid + 1; + } + else { + if (glyph_value < __mg_unicode_bidi_char_type_map[glyph_mid].glyph) + glyph_last = glyph_mid - 1; + else + glyph_last = glyph_mid; + } + } + + return BIDI_TYPE_LTR; +} + +static BOOL unicode_bidi_mirror_glyph (Glyph32 glyph, Glyph32* mirrored) +{ + return get_mirror_glyph (__mg_unicode_mirror_table, + TABLESIZE (__mg_unicode_mirror_table), glyph, mirrored); +} + static unsigned int utf8_glyph_type (Glyph32 glyph_value) { if (glyph_value < 0x80) { return sb_glyph_type (glyph_value); } else { - /* TODO: get the subtype of the char */ - //ch_type = MCHAR_TYPE_GENERIC; return UNICODE_TYPE (glyph_value); } } @@ -3529,14 +3717,14 @@ static CHARSETOPS CharsetOps_utf8 = { utf8_len_first_char, utf8_char_glyph_value, NULL, - NULL, utf8_glyph_type, utf8_nr_chars_in_str, utf8_is_this_charset, utf8_len_first_substr, utf8_get_next_word, utf8_pos_first_char, - NULL, + unicode_bidi_glyph_type, + unicode_bidi_mirror_glyph, NULL, utf8_conv_from_uc32, }; @@ -3769,14 +3957,14 @@ static CHARSETOPS CharsetOps_utf16le = { utf16le_len_first_char, utf16le_char_glyph_value, NULL, - NULL, utf16_glyph_type, utf16le_nr_chars_in_str, utf16le_is_this_charset, utf16le_len_first_substr, utf16le_get_next_word, utf16le_pos_first_char, - NULL, + unicode_bidi_glyph_type, + unicode_bidi_mirror_glyph, NULL, utf16le_conv_from_uc32 }; @@ -3995,14 +4183,14 @@ static CHARSETOPS CharsetOps_utf16be = { utf16be_len_first_char, utf16be_char_glyph_value, NULL, - NULL, utf16_glyph_type, utf16be_nr_chars_in_str, utf16be_is_this_charset, utf16be_len_first_substr, utf16be_get_next_word, utf16be_pos_first_char, - NULL, + unicode_bidi_glyph_type, + unicode_bidi_mirror_glyph, NULL, utf16be_conv_from_uc32 }; diff --git a/src/font/unicode-bidi-tables.h b/src/font/unicode-bidi-tables.h new file mode 100644 index 00000000..d0da7a3d --- /dev/null +++ b/src/font/unicode-bidi-tables.h @@ -0,0 +1,404 @@ +/* + * This file is part of MiniGUI, a mature cross-platform windowing + * and Graphics User Interface (GUI) support system for embedded systems + * and smart IoT devices. + * + * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. + * Copyright (C) 1998~2002, WEI Yongming + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Or, + * + * As this program is a library, any link to this program must follow + * GNU General Public License version 3 (GPLv3). If you cannot accept + * GPLv3, you need to be licensed from FMSoft. + * + * If you have got a commercial license of this program, please use it + * under the terms and conditions of the commercial license. + * + * For more information about the commercial license, please refer to + * . + */ +/* +** unicode-bidi-tables.h: the Unicode BIDI tables. +** +** Created by VincentWei at 2018/08/27 +*/ + +#ifndef _UNICODE_BIDI_TABLES_H +#define _UNICODE_BIDI_TABLES_H + +typedef struct _bidichar_type_map +{ + BidiCharType type; // Type of Unicode characters + Glyph32 glyph; // Starting index of Unicode character + Uint8 count; // Total number of Unicode characters of same type starting from glyphn +} BIDICHAR_TYPE_MAP; + +static const BIDICHAR_TYPE_MAP __mg_unicode_bidi_char_type_map []= +{ + { BIDI_TYPE_ON, 0x0000, 0x06}, + { BIDI_TYPE_NSM, 0x0006, 0x04}, + { BIDI_TYPE_BS, 0x000a, 0x01}, + { BIDI_TYPE_ON, 0x000b, 0x02}, + { BIDI_TYPE_BS, 0x000d, 0x01}, + { BIDI_TYPE_ON, 0x000e, 0x05}, + { BIDI_TYPE_WS, 0x0013, 0x01}, + { BIDI_TYPE_ON, 0x0014, 0x08}, + { BIDI_TYPE_ON, 0x001c, 0x04}, + { BIDI_TYPE_WS, 0x0020, 0x01}, + { BIDI_TYPE_ON, 0x0021, 0x02}, + { BIDI_TYPE_ET, 0x0023, 0x03}, + { BIDI_TYPE_ON, 0x0026, 0x05}, + { BIDI_TYPE_ET, 0x002b, 0x01}, + { BIDI_TYPE_CS, 0x002c, 0x01}, + { BIDI_TYPE_ES, 0x002d, 0x01}, + { BIDI_TYPE_CS, 0x002e, 0x02}, + { BIDI_TYPE_EN, 0x0030, 0x0a}, + { BIDI_TYPE_CS, 0x003a, 0x01}, + { BIDI_TYPE_ON, 0x003b, 0x06}, + { BIDI_TYPE_LTR, 0x0041, 0x1a}, + { BIDI_TYPE_ON, 0x005b, 0x02}, + { BIDI_TYPE_ON, 0x005d, 0x03}, + { BIDI_TYPE_NSM, 0x0060, 0x01}, + { BIDI_TYPE_LTR, 0x0061, 0x1a}, + { BIDI_TYPE_ON, 0x007b, 0x01}, + { BIDI_TYPE_SS, 0x007c, 0x01}, + { BIDI_TYPE_ON, 0x007d, 0x03}, + { BIDI_TYPE_BN, 0x0080, 0x05}, + { BIDI_TYPE_BS, 0x0085, 0x01}, + { BIDI_TYPE_BN, 0x0086, 0x1a}, + { BIDI_TYPE_CS, 0x00a0, 0x01}, + { BIDI_TYPE_ON, 0x00a1, 0x01}, + { BIDI_TYPE_ET, 0x00a2, 0x04}, + { BIDI_TYPE_ON, 0x00a6, 0x04}, + { BIDI_TYPE_LTR, 0x00aa, 0x01}, + { BIDI_TYPE_ON, 0x00ab, 0x05}, + { BIDI_TYPE_ET, 0x00b0, 0x02}, + { BIDI_TYPE_EN, 0x00b2, 0x02}, + { BIDI_TYPE_ON, 0x00b4, 0x01}, + { BIDI_TYPE_LTR, 0x00b5, 0x01}, + { BIDI_TYPE_ON, 0x00b6, 0x03}, + { BIDI_TYPE_EN, 0x00b9, 0x01}, + { BIDI_TYPE_LTR, 0x00ba, 0x01}, + { BIDI_TYPE_ON, 0x00bb, 0x05}, + { BIDI_TYPE_LTR, 0x00c0, 0x17}, + { BIDI_TYPE_ON, 0x00d7, 0x01}, + { BIDI_TYPE_LTR, 0x00d8, 0x1f}, + { BIDI_TYPE_ON, 0x00f7, 0x01}, + { BIDI_TYPE_LTR, 0x00f8, 0x29}, + { BIDI_TYPE_LTR, 0x0222, 0x12}, + { BIDI_TYPE_LTR, 0x0250, 0x5e}, + { BIDI_TYPE_LTR, 0x02b0, 0x09}, + { BIDI_TYPE_ON, 0x02b9, 0x02}, + { BIDI_TYPE_LTR, 0x02bb, 0x07}, + { BIDI_TYPE_ON, 0x02c2, 0x0e}, + { BIDI_TYPE_LTR, 0x02d0, 0x02}, + { BIDI_TYPE_ON, 0x02d2, 0x0e}, + { BIDI_TYPE_LTR, 0x02e0, 0x05}, + { BIDI_TYPE_ON, 0x02e5, 0x09}, + { BIDI_TYPE_LTR, 0x02ee, 0x01}, + { BIDI_TYPE_NSM, 0x0300, 0x50}, + { BIDI_TYPE_NSM, 0x0360, 0x10}, + { BIDI_TYPE_LTR, 0x0400, 0x83}, + { BIDI_TYPE_NSM, 0x0483, 0x04}, + { BIDI_TYPE_NSM, 0x0488, 0x02}, + { BIDI_TYPE_LTR, 0x048a, 0x45}, + { BIDI_TYPE_LTR, 0x04d0, 0x26}, + { BIDI_TYPE_LTR, 0x04f8, 0x02}, + { BIDI_TYPE_LTR, 0x0500, 0x10}, + { BIDI_TYPE_AL, 0x0591, 0x11}, + { BIDI_TYPE_AL, 0x05a3, 0x17}, + { BIDI_TYPE_AL, 0x05bb, 0x0A}, + { BIDI_TYPE_AL, 0x05d0, 0x1B}, + { BIDI_TYPE_AL, 0x05f0, 0x05}, + { BIDI_TYPE_CS, 0x060c, 0x01}, + { BIDI_TYPE_AL, 0x061b, 0x01}, + { BIDI_TYPE_AL, 0x061f, 0x01}, + { BIDI_TYPE_AL, 0x0621, 0x1a}, + { BIDI_TYPE_AL, 0x0640, 0x0b}, + { BIDI_TYPE_NSM, 0x064b, 0x0b}, + { BIDI_TYPE_AN, 0x0660, 0x0a}, + { BIDI_TYPE_ET, 0x066a, 0x01}, + { BIDI_TYPE_AN, 0x066b, 0x02}, + { BIDI_TYPE_AL, 0x066d, 0x03}, + { BIDI_TYPE_NSM, 0x0670, 0x01}, + { BIDI_TYPE_AL, 0x0671, 0x65}, + { BIDI_TYPE_NSM, 0x06d6, 0x07}, + { BIDI_TYPE_AL, 0x06dd, 0x01}, + { BIDI_TYPE_NSM, 0x06de, 0x07}, + { BIDI_TYPE_AL, 0x06e5, 0x02}, + { BIDI_TYPE_NSM, 0x06e7, 0x02}, + { BIDI_TYPE_ON, 0x06e9, 0x01}, + { BIDI_TYPE_NSM, 0x06ea, 0x04}, + { BIDI_TYPE_EN, 0x06f0, 0x0a}, + { BIDI_TYPE_AL, 0x06fa, 0x05}, + { BIDI_TYPE_LTR, 0x0e01, 0x30}, + { BIDI_TYPE_NSM, 0x0e31, 0x01}, + { BIDI_TYPE_LTR, 0x0e32, 0x02}, + { BIDI_TYPE_LTR, 0x0e34, 0x07}, + { BIDI_TYPE_ET, 0x0e3f, 0x01}, + { BIDI_TYPE_LTR, 0x0e40, 0x07}, + { BIDI_TYPE_LTR, 0x0e47, 0x08}, + { BIDI_TYPE_LTR, 0x0e4f, 0x0d}, + { BIDI_TYPE_LTR, 0x1e00, 0x9c}, + { BIDI_TYPE_LTR, 0x1ea0, 0x5a}, + { BIDI_TYPE_WS, 0x2000, 0x0b}, + { BIDI_TYPE_BN, 0x200b, 0x03}, + { BIDI_TYPE_LTR, 0x200e, 0x01}, + { BIDI_TYPE_RTL, 0x200f, 0x01}, + { BIDI_TYPE_ON, 0x2010, 0x18}, + { BIDI_TYPE_WS, 0x2028, 0x01}, + { BIDI_TYPE_BS, 0x2029, 0x01}, + { BIDI_TYPE_LRE, 0x202a, 0x01}, + { BIDI_TYPE_RLE, 0x202b, 0x01}, + { BIDI_TYPE_PDF, 0x202c, 0x01}, + { BIDI_TYPE_LRO, 0x202d, 0x01}, + { BIDI_TYPE_RLO, 0x202e, 0x01}, + { BIDI_TYPE_WS, 0x202f, 0x01}, + { BIDI_TYPE_ET, 0x2030, 0x05}, + { BIDI_TYPE_ON, 0x2035, 0x1e}, + { BIDI_TYPE_ON, 0x2057, 0x01}, + { BIDI_TYPE_WS, 0x205f, 0x01}, + { BIDI_TYPE_BN, 0x2060, 0x04}, + { BIDI_TYPE_BN, 0x206a, 0x06}, + { BIDI_TYPE_EN, 0x2070, 0x01}, + { BIDI_TYPE_LTR, 0x2071, 0x01}, + { BIDI_TYPE_EN, 0x2074, 0x06}, + { BIDI_TYPE_ET, 0x207a, 0x02}, + { BIDI_TYPE_ON, 0x207c, 0x03}, + { BIDI_TYPE_LTR, 0x207f, 0x01}, + { BIDI_TYPE_EN, 0x2080, 0x0a}, + { BIDI_TYPE_ET, 0x208a, 0x02}, + { BIDI_TYPE_ON, 0x208c, 0x03}, + { BIDI_TYPE_ET, 0x20a0, 0x12}, + { BIDI_TYPE_NSM, 0x20d0, 0x1b}, + { BIDI_TYPE_ON, 0x2100, 0x02}, + { BIDI_TYPE_LTR, 0x2102, 0x01}, + { BIDI_TYPE_ON, 0x2103, 0x04}, + { BIDI_TYPE_LTR, 0x2107, 0x01}, + { BIDI_TYPE_ON, 0x2108, 0x02}, + { BIDI_TYPE_LTR, 0x210a, 0x0a}, + { BIDI_TYPE_ON, 0x2114, 0x01}, + { BIDI_TYPE_LTR, 0x2115, 0x01}, + { BIDI_TYPE_ON, 0x2116, 0x03}, + { BIDI_TYPE_LTR, 0x2119, 0x05}, + { BIDI_TYPE_ON, 0x211e, 0x06}, + { BIDI_TYPE_LTR, 0x2124, 0x01}, + { BIDI_TYPE_ON, 0x2125, 0x01}, + { BIDI_TYPE_LTR, 0x2126, 0x01}, + { BIDI_TYPE_ON, 0x2127, 0x01}, + { BIDI_TYPE_LTR, 0x2128, 0x01}, + { BIDI_TYPE_ON, 0x2129, 0x01}, + { BIDI_TYPE_LTR, 0x212a, 0x04}, + { BIDI_TYPE_ET, 0x212e, 0x01}, + { BIDI_TYPE_LTR, 0x212f, 0x03}, + { BIDI_TYPE_ON, 0x2132, 0x01}, + { BIDI_TYPE_LTR, 0x2133, 0x07}, + { BIDI_TYPE_ON, 0x213a, 0x01}, + { BIDI_TYPE_LTR, 0x213d, 0x03}, + { BIDI_TYPE_ON, 0x2140, 0x05}, + { BIDI_TYPE_LTR, 0x2145, 0x05}, + { BIDI_TYPE_ON, 0x214a, 0x02}, + { BIDI_TYPE_ON, 0x2153, 0x0d}, + { BIDI_TYPE_LTR, 0x2160, 0x24}, + { BIDI_TYPE_ON, 0x2190, 0x82}, + { BIDI_TYPE_ET, 0x2212, 0x02}, + { BIDI_TYPE_ON, 0x2214, 0x22}, + { BIDI_TYPE_LTR, 0x2336, 0x45}, + { BIDI_TYPE_ON, 0x237b, 0x1a}, + { BIDI_TYPE_LTR, 0x2395, 0x01}, + { BIDI_TYPE_ON, 0x2396, 0x39}, + { BIDI_TYPE_ON, 0x2400, 0x27}, + { BIDI_TYPE_ON, 0x2440, 0x0b}, + { BIDI_TYPE_EN, 0x2460, 0x3c}, + { BIDI_TYPE_LTR, 0x249c, 0x4e}, + { BIDI_TYPE_EN, 0x24ea, 0x01}, + { BIDI_TYPE_ON, 0x24eb, 0x14}, + { BIDI_TYPE_ON, 0x2500, 0x14}, + { BIDI_TYPE_ON, 0x2616, 0x02}, + { BIDI_TYPE_ON, 0x2619, 0x65}, + { BIDI_TYPE_ON, 0x2680, 0x0a}, + { BIDI_TYPE_ON, 0x2701, 0x04}, + { BIDI_TYPE_ON, 0x2706, 0x04}, + { BIDI_TYPE_ON, 0x270c, 0x1c}, + { BIDI_TYPE_ON, 0x2729, 0x23}, + { BIDI_TYPE_ON, 0x274d, 0x01}, + { BIDI_TYPE_ON, 0x274f, 0x04}, + { BIDI_TYPE_ON, 0x2756, 0x01}, + { BIDI_TYPE_ON, 0x2758, 0x07}, + { BIDI_TYPE_ON, 0x2761, 0x34}, + { BIDI_TYPE_ON, 0x2798, 0x18}, + { BIDI_TYPE_ON, 0x27b1, 0x0e}, + { BIDI_TYPE_ON, 0x27d0, 0x1c}, + { BIDI_TYPE_ON, 0x27f0, 0x10}, + { BIDI_TYPE_ON, 0x2e80, 0x1a}, + { BIDI_TYPE_ON, 0x2e9b, 0x59}, + { BIDI_TYPE_ON, 0x2f00, 0xd6}, + { BIDI_TYPE_ON, 0x2ff0, 0x0c}, + { BIDI_TYPE_WS, 0x3000, 0x01}, + { BIDI_TYPE_ON, 0x3001, 0x04}, + { BIDI_TYPE_LTR, 0x3005, 0x03}, + { BIDI_TYPE_ON, 0x3008, 0x19}, + { BIDI_TYPE_LTR, 0x3021, 0x09}, + { BIDI_TYPE_NSM, 0x302a, 0x06}, + { BIDI_TYPE_ON, 0x3030, 0x01}, + { BIDI_TYPE_LTR, 0x3031, 0x05}, + { BIDI_TYPE_ON, 0x3036, 0x02}, + { BIDI_TYPE_LTR, 0x3038, 0x05}, + { BIDI_TYPE_ON, 0x303d, 0x03}, + { BIDI_TYPE_LTR, 0x3041, 0x56}, + { BIDI_TYPE_NSM, 0x3099, 0x02}, + { BIDI_TYPE_ON, 0x309b, 0x02}, + { BIDI_TYPE_LTR, 0x309d, 0x03}, + { BIDI_TYPE_ON, 0x30a0, 0x01}, + { BIDI_TYPE_LTR, 0x30a1, 0x5a}, + { BIDI_TYPE_ON, 0x30fb, 0x01}, + { BIDI_TYPE_LTR, 0x30fc, 0x04}, + { BIDI_TYPE_LTR, 0x3105, 0x28}, + { BIDI_TYPE_LTR, 0x3131, 0x5e}, + { BIDI_TYPE_LTR, 0x3190, 0x28}, + { BIDI_TYPE_LTR, 0x31f0, 0x2d}, + { BIDI_TYPE_LTR, 0x3220, 0x24}, + { BIDI_TYPE_ON, 0x3251, 0x0f}, + { BIDI_TYPE_LTR, 0x3260, 0x1c}, + { BIDI_TYPE_LTR, 0x327f, 0x32}, + { BIDI_TYPE_ON, 0x32b1, 0x0f}, + { BIDI_TYPE_LTR, 0x32c0, 0x0c}, + { BIDI_TYPE_LTR, 0x32d0, 0x2f}, + { BIDI_TYPE_LTR, 0x3300, 0x77}, + { BIDI_TYPE_LTR, 0x337b, 0x63}, + { BIDI_TYPE_LTR, 0x33e0, 0x1f}, + { BIDI_TYPE_LTR, 0x3400, 0x01}, + { BIDI_TYPE_LTR, 0x4db5, 0x01}, + { BIDI_TYPE_LTR, 0x4e00, 0x01}, + { BIDI_TYPE_LTR, 0x9fa5, 0x01}, + { BIDI_TYPE_ON, 0xEA00, 0xFF}, + { BIDI_TYPE_ON, 0xEB00, 0xFF}, + { BIDI_TYPE_ON, 0xEC00, 0xFF}, + { BIDI_TYPE_ON, 0xED00, 0xFF}, + { BIDI_TYPE_ON, 0xEE00, 0xFF}, + { BIDI_TYPE_ON, 0xEF00, 0xFF}, + { BIDI_TYPE_LTR, 0xf900, 0x2e}, + { BIDI_TYPE_LTR, 0xfa30, 0x3b}, + { BIDI_TYPE_LTR, 0xfb00, 0x07}, + { BIDI_TYPE_AL, 0xfb50, 0x62}, + { BIDI_TYPE_AL, 0xfbd3, 0x6b}, + { BIDI_TYPE_AL, 0xfc3f, 0x01}, + { BIDI_TYPE_AL, 0xfc40, 0x10}, + { BIDI_TYPE_AL, 0xfc60, 0x90}, + { BIDI_TYPE_AL, 0xfd0a, 0x07}, + { BIDI_TYPE_AL, 0xfd20, 0x10}, + { BIDI_TYPE_AL, 0xfd30, 0x0c}, + { BIDI_TYPE_ON, 0xfd3e, 0x02}, + { BIDI_TYPE_AL, 0xfd50, 0x40}, + { BIDI_TYPE_AL, 0xfd92, 0x36}, + { BIDI_TYPE_AL, 0xfdf0, 0x0d}, + { BIDI_TYPE_NSM, 0xfe00, 0x10}, + { BIDI_TYPE_NSM, 0xfe20, 0x04}, + { BIDI_TYPE_ON, 0xfe30, 0x17}, + { BIDI_TYPE_ON, 0xfe49, 0x07}, + { BIDI_TYPE_CS, 0xfe50, 0x01}, + { BIDI_TYPE_ON, 0xfe51, 0x01}, + { BIDI_TYPE_CS, 0xfe52, 0x01}, + { BIDI_TYPE_ON, 0xfe54, 0x01}, + { BIDI_TYPE_CS, 0xfe55, 0x01}, + { BIDI_TYPE_ON, 0xfe56, 0x09}, + { BIDI_TYPE_ET, 0xfe5f, 0x01}, + { BIDI_TYPE_ON, 0xfe60, 0x02}, + { BIDI_TYPE_ET, 0xfe62, 0x02}, + { BIDI_TYPE_ON, 0xfe64, 0x03}, + { BIDI_TYPE_ON, 0xfe68, 0x01}, + { BIDI_TYPE_ET, 0xfe69, 0x02}, + { BIDI_TYPE_ON, 0xfe6b, 0x01}, + { BIDI_TYPE_AL, 0xfe70, 0x05}, + { BIDI_TYPE_AL, 0xfe76, 0x87}, + { BIDI_TYPE_BN, 0xfeff, 0x01}, + { BIDI_TYPE_ON, 0xff01, 0x02}, + { BIDI_TYPE_ET, 0xff03, 0x03}, + { BIDI_TYPE_ON, 0xff06, 0x05}, + { BIDI_TYPE_ET, 0xff0b, 0x01}, + { BIDI_TYPE_CS, 0xff0c, 0x01}, + { BIDI_TYPE_ET, 0xff0d, 0x01}, + { BIDI_TYPE_CS, 0xff0e, 0x01}, + { BIDI_TYPE_ES, 0xff0f, 0x01}, + { BIDI_TYPE_EN, 0xff10, 0x0a}, + { BIDI_TYPE_CS, 0xff1a, 0x01}, + { BIDI_TYPE_ON, 0xff1b, 0x06}, + { BIDI_TYPE_LTR, 0xff21, 0x1a}, + { BIDI_TYPE_ON, 0xff3b, 0x06}, + { BIDI_TYPE_LTR, 0xff41, 0x1a}, + { BIDI_TYPE_ON, 0xff5b, 0x0b}, + { BIDI_TYPE_LTR, 0xff66, 0x59}, + { BIDI_TYPE_LTR, 0xffc2, 0x06}, + { BIDI_TYPE_LTR, 0xffca, 0x06}, + { BIDI_TYPE_LTR, 0xffd2, 0x06}, + { BIDI_TYPE_LTR, 0xffda, 0x03}, + { BIDI_TYPE_ET, 0xffe0, 0x02}, + { BIDI_TYPE_ON, 0xffe2, 0x03}, + { BIDI_TYPE_ET, 0xffe5, 0x02}, + { BIDI_TYPE_ON, 0xffe8, 0x07}, + { BIDI_TYPE_BN, 0xfff9, 0x03}, + { BIDI_TYPE_ON, 0xfffc, 0x02}, +}; + +static const BIDICHAR_MIRROR_MAP __mg_unicode_mirror_table []= +{ + {0x0028, 0x0029}, + {0x003c, 0x003e}, + {0x005b, 0x005d}, + {0x007b, 0x007d}, + {0x00ab, 0x00bb}, + {0x2039, 0x203a}, + {0x2045, 0x2046}, + {0x207d, 0x207e}, + {0x208d, 0x208e}, + {0x2208, 0x220b}, + {0x2209, 0x220c}, + {0x220a, 0x220d}, + {0x2215, 0x29f5}, + {0x2768, 0x2769}, + {0x276a, 0x276b}, + {0x276c, 0x276d}, + {0x276e, 0x276f}, + {0x2770, 0x2771}, + {0x2772, 0x2773}, + {0x2774, 0x2775}, + {0x27d5, 0x27d6}, + {0x27dd, 0x27de}, + {0x27e2, 0x27e3}, + {0x27e4, 0x27e5}, + {0x27e6, 0x27e7}, + {0x27e8, 0x27e9}, + {0x27ea, 0x27eb}, + {0x3008, 0x3009}, + {0x300a, 0x300b}, + {0x300c, 0x300d}, + {0x300e, 0x300f}, + {0x3010, 0x3011}, + {0x3014, 0x3015}, + {0x3016, 0x3017}, + {0x3018, 0x3019}, + {0x301a, 0x301b}, + {0xff08, 0xff09}, + {0xff1c, 0xff1e}, + {0xff3b, 0xff3d}, + {0xff5b, 0xff5d}, + {0xff5f, 0xff60}, + {0xff62, 0xff63} +}; + +#endif /* !_UNICODE_BIDI_TABLES_H */ + diff --git a/src/include/bidi.h b/src/include/bidi.h index c4e8a6e8..03faee4f 100644 --- a/src/include/bidi.h +++ b/src/include/bidi.h @@ -197,7 +197,7 @@ extern "C" { /* Return the minimum level of the direction, 0 for BIDI_TYPE_LTR and 1 for BIDI_TYPE_RTL and BIDI_TYPE_AL. */ -#define BIDI_DIR_TO_LEVEL(dir) ((BidiLevel)(dir & 1)) +#define BIDI_DIR_TO_LEVEL(dir) ((BYTE)(dir & 1)) /* Is right to left? */ #define BIDI_IS_RTL(p) ((p) & BIDI_MASK_RTL) @@ -251,31 +251,28 @@ extern "C" { #define BIDI_NUMBER_TO_RTL(p) \ (BIDI_IS_NUMBER(p) ? BIDI_TYPE_RTL : (p)) -#ifdef MAIN_CAP_TEST -typedef char BidiChar; -#else -typedef int BidiChar; -#endif -typedef int BidiCharType; -typedef char BidiLevel; -typedef int BidiStrIndex; -typedef struct _TYPERUN TYPERUN; +typedef Uint32 BidiCharType; +typedef struct _TYPERUN TYPERUN; + +typedef struct _BIDICHAR_MIRROR_MAP { + Glyph32 glyph; + Glyph32 mirrored; +} BIDICHAR_MIRROR_MAP; typedef void (*CB_DO_REORDER) (void* context, int len, int pos); -int bidi_glyph_type(const char* charset_name, Glyph32 glyph_value); +Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len); -Glyph32* bidi_str_reorder (const char* charset_name, Glyph32* glyphs, - int len); +Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs, + int len, GLYPHMAPINFO* map); -void bidi_get_embeddlevels(const char* charset_name, Glyph32* glyphs, - BidiStrIndex len, Uint8* embedding_level_list, Uint8 type); +void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, Glyph32* glyphs, + int len, Uint8* embedding_level_list, Uint8 type); -Glyph32* bidi_index_reorder (const char* charset_name, Glyph32* glyphs, +Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len, int* index_map); -Glyph32* bidi_map_reorder (const char* charset_name, Glyph32* glyphs, - int len, GLYPHMAPINFO* map); +BidiCharType __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len); #ifdef __cplusplus } diff --git a/src/include/devfont.h b/src/include/devfont.h index c7ced915..74cbb8a7 100644 --- a/src/include/devfont.h +++ b/src/include/devfont.h @@ -117,63 +117,63 @@ static inline long get_opened_file_size (FILE* fp) /** The character set operation structure. */ struct _CHARSETOPS { - /** The character number of the character set. */ + /** The character number of the character set. */ int nr_chars; - /** The byte number of the max length character. */ + /** The byte number of the max length character. */ int bytes_maxlen_char; - /** The name of the character set. */ + /** The name of the character set. */ const char* name; - /** Default character. */ + /** Default character. */ Glyph32 def_glyph_value; - /** The method to get the length of the first character function. */ + /** The method to get the length of the first character function. */ int (*len_first_char) (const unsigned char* mstr, int mstrlen); - /** The method to get character offset function. */ + /** The method to get character offset function. */ Glyph32 (*char_glyph_value) (const unsigned char* pre_mchar, int pre_len, const unsigned char* cur_mchar, int cur_len); /** The method to get the require shape type glyph value. */ Glyph32 (*glyph_shape) (const unsigned char* cur_mchar, int cur_len, int shape_type); - /** The method to get the type of one glyph. */ - unsigned int (*bidi_glyph_type) (Glyph32 glyph_value); - - /** The method to get the type of one glyph. */ + /** The method to get the type of one glyph. */ unsigned int (*glyph_type) (Glyph32 glyph_value); - /** The method to get character number in the string function. */ + /** The method to get character number in the string function. */ int (*nr_chars_in_str) (const unsigned char* mstr, int mstrlen); - /** The method to judge the \a charset is belong to the character set - * function. - */ + /** The method to judge the \a charset is belong to the character set + * function. + */ int (*is_this_charset) (const unsigned char* charset); - /** The method to get the length of the first substring. */ + /** The method to get the length of the first substring. */ int (*len_first_substr) (const unsigned char* mstr, int mstrlen); - /** The method to get next word in the specitied length string function. */ + /** The method to get next word in the specitied length string function. */ const unsigned char* (*get_next_word) (const unsigned char* mstr, int strlen, WORDINFO* word_info); - /** The method to get the position of the first character in the - * specified length string function. - */ + /** The method to get the position of the first character in the + * specified length string function. + */ int (*pos_first_char) (const unsigned char* mstr, int mstrlen); - /** reorder bidi string specified length function. - */ - Glyph32* (*bidi_reorder) (Glyph32* glyphs, int len); + /** The method to get the type of one glyph. */ + unsigned int (*bidi_glyph_type) (Glyph32 glyph_value); + + /** Get mirrored glyph + */ + BOOL (*bidi_mirror_glyph) (Glyph32 glyph, Glyph32* mirrored); #ifdef _MGCHARSET_UNICODE - /** The method to convert \a mchar to 32 bit UNICODE function. */ + /** The method to convert \a mchar to 32 bit UNICODE function. */ UChar32 (*conv_to_uc32) (Glyph32 glyph_value); - /** The method to convert \a wc to multily byte character function. */ + /** The method to convert \a wc to multily byte character function. */ int (*conv_from_uc32) (UChar32 wc, unsigned char* mchar); #endif /* _UNICODE_SUPPORT */ }; diff --git a/src/newgdi/bidi.c b/src/newgdi/bidi.c index bbd23098..0294ebbd 100644 --- a/src/newgdi/bidi.c +++ b/src/newgdi/bidi.c @@ -471,11 +471,10 @@ Glyph32* _gdi_bidi_reorder (PDC pdc, const unsigned char* text, int text_len, DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; Glyph32 *logical_glyphs = NULL; - if (mbc_devfont && mbc_devfont->charset_ops->bidi_reorder) { - logical_glyphs = _gdi_get_glyphs_string(pdc, text, text_len, - nr_glyphs); + if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) { + logical_glyphs = _gdi_get_glyphs_string (pdc, text, text_len, nr_glyphs); if (*nr_glyphs > 0) - mbc_devfont->charset_ops->bidi_reorder (logical_glyphs, *nr_glyphs); + __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, logical_glyphs, *nr_glyphs); } return logical_glyphs; @@ -494,13 +493,13 @@ int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, int nr_glyphs = 0; Glyph32 *logical_glyphs = NULL; - if(mbc_devfont->charset_ops->bidi_reorder){ + if (mbc_devfont->charset_ops->bidi_glyph_type) { - logical_glyphs = _gdi_bidi_reorder(pdc, text, text_len, &nr_glyphs); + logical_glyphs = _gdi_bidi_reorder (pdc, text, text_len, &nr_glyphs); if(!logical_glyphs || nr_glyphs <= 0) return 0; - i = _gdi_output_visual_glyphs(pdc, logical_glyphs, nr_glyphs, + i = _gdi_output_visual_glyphs (pdc, logical_glyphs, nr_glyphs, direction, cb_one_glyph, context); } else if(!direction){ @@ -872,11 +871,11 @@ int _gdi_reorder_text_break (PDC pdc, const unsigned char* text, int nr_glyphs = text_len; Glyph32 *logical_glyphs = NULL; - if(mbc_devfont->charset_ops->bidi_reorder){ + if (mbc_devfont->charset_ops->bidi_glyph_type){ logical_glyphs = _gdi_get_glyphs_string_break(pdc, text, text_len, &nr_glyphs, context); - mbc_devfont->charset_ops->bidi_reorder(logical_glyphs, nr_glyphs); + __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, logical_glyphs, nr_glyphs); if(!logical_glyphs) return 0; @@ -1012,11 +1011,11 @@ int GUIAPI BIDIGetTextVisualGlyphs( nr_glyphs = BIDIGetTextLogicalGlyphs(log_font, text, text_len, glyphs, glyphs_map); - if(mbc_devfont && mbc_devfont->charset_ops->bidi_reorder){ - bidi_map_reorder(mbc_devfont->charset_ops->name, *glyphs, + if(mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type){ + __mg_charset_bidi_map_reorder (mbc_devfont->charset_ops, *glyphs, nr_glyphs, *glyphs_map); - mbc_devfont->charset_ops->bidi_reorder(*glyphs, nr_glyphs); + __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, *glyphs, nr_glyphs); } return nr_glyphs; } @@ -1040,13 +1039,13 @@ Glyph32* GUIAPI BIDILogGlyphs2VisGlyphs( { DEVFONT* mbc_devfont = log_font->mbc_devfont; - if(mbc_devfont && mbc_devfont->charset_ops->bidi_reorder){ + if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) { /* get the visual glyphs map from the logical glyphs map. */ if(glyphs_map){ - bidi_map_reorder((const char*)mbc_devfont->charset_ops->name, + __mg_charset_bidi_map_reorder (mbc_devfont->charset_ops, glyphs, nr_glyphs, glyphs_map); } - mbc_devfont->charset_ops->bidi_reorder(glyphs, nr_glyphs); + __mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, glyphs, nr_glyphs); } return glyphs; @@ -1441,8 +1440,8 @@ void GUIAPI GetTextRangesLog2Vis( *nr_ranges = 0; /* it is not bidi string. */ - if(!log_font->mbc_devfont || (log_font->mbc_devfont && - !log_font->mbc_devfont->charset_ops->bidi_reorder)){ + if (!log_font->mbc_devfont || (log_font->mbc_devfont && + !log_font->mbc_devfont->charset_ops->bidi_glyph_type)) { *ranges = NULL; return; } @@ -1535,8 +1534,8 @@ void GUIAPI BIDIGetLogicalEmbeddLevels( if(*embedding_level_list == NULL) *embedding_level_list = malloc(nr_glyphs * sizeof (Uint8)); - if (mbc_devfont && mbc_devfont->charset_ops->bidi_reorder) { - bidi_get_embeddlevels(mbc_devfont->charset_ops->name, glyphs, nr_glyphs, + if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) { + __mg_charset_bidi_get_embeddlevels (mbc_devfont->charset_ops, glyphs, nr_glyphs, *embedding_level_list, 0); } else{ @@ -1567,8 +1566,8 @@ void GUIAPI BIDIGetVisualEmbeddLevels( if(*embedding_level_list == NULL) *embedding_level_list = malloc(nr_glyphs * sizeof (Uint8)); - if (mbc_devfont && mbc_devfont->charset_ops->bidi_reorder) { - bidi_get_embeddlevels(mbc_devfont->charset_ops->name, glyphs, nr_glyphs, + if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) { + __mg_charset_bidi_get_embeddlevels (mbc_devfont->charset_ops, glyphs, nr_glyphs, *embedding_level_list, 1); } else{ diff --git a/src/newgdi/tabbedtextout.c b/src/newgdi/tabbedtextout.c index 245a947a..cf086a99 100644 --- a/src/newgdi/tabbedtextout.c +++ b/src/newgdi/tabbedtextout.c @@ -529,9 +529,10 @@ int GUIAPI GetTabbedTextExtentPoint (HDC hdc, const char* text, /* set size to zero first */ size->cx = size->cy = 0; - /* bidi is not supported */ + /* FIXME: use HDC property for BIDI enable or not if (mbc_devfont && mbc_devfont->charset_ops->bidi_reorder) return -1; + */ _gdi_start_new_line (pdc); diff --git a/src/newgdi/textout.c b/src/newgdi/textout.c index 2d5852cc..4aa51f7a 100644 --- a/src/newgdi/textout.c +++ b/src/newgdi/textout.c @@ -462,9 +462,10 @@ int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, /* set size to zero first */ size->cx = size->cy = 0; - /* bidi is not supported */ + /* FIXME: use HDC property for BIDI enable or not if (mbc_devfont && mbc_devfont->charset_ops->bidi_reorder) return -1; + */ _gdi_start_new_line(pdc);