mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-07 02:52:42 +08:00
two implementations for biditype, bracket and mirror
This commit is contained in:
@@ -7311,6 +7311,10 @@ MG_EXPORT int GUIAPI GetFirstWord (PLOGFONT log_font,
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef Uint8 BidiLevel;
|
||||
typedef Uint16 BidiType;
|
||||
typedef Uint32 BidiBracketType;
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI MB2WCEx (PLOGFONT log_font, void* dest, BOOL wc32, \
|
||||
* const unsigned char* mstr, int n)
|
||||
@@ -7472,12 +7476,53 @@ MG_EXPORT UCharBreakType GUIAPI UCharGetBreakType(Uchar32 uc);
|
||||
/** The function determines the BIDI type of a UNICODE character. */
|
||||
MG_EXPORT Uint16 GUIAPI UCharGetBIDIType(Uchar32 uc);
|
||||
|
||||
#define BIDICHAR_BRACKET_NONE 0
|
||||
#define BIDICHAR_BRACKET_OPEN 1
|
||||
#define BIDICHAR_BRACKET_CLOSE 2
|
||||
#define BIDI_BRACKET_NONE 0
|
||||
#define BIDI_BRACKET_OPEN_MASK 0x80000000
|
||||
#define BIDI_BRACKET_CHAR_MASK 0X7FFFFFFF
|
||||
#define BIDI_IS_BRACKET_OPEN(bt) ((bt & BIDI_BRACKET_OPEN_MASK)>0)
|
||||
#define BIDI_BRACKET_CHAR(bt) ((bt & BIDI_BRACKET_CHAR_MASK))
|
||||
|
||||
/** The function returns the bracket type of a UNICODE character. */
|
||||
MG_EXPORT Uint8 GUIAPI UCharGetBracketType(Uchar32 uc);
|
||||
/* \fn BidiBracketType GUIAPI UCharGetBracketType(Uchar32 ch)
|
||||
* \brief Get bracketed character
|
||||
*
|
||||
* This function finds the bracketed equivalent of a character as defined in
|
||||
* the file BidiBrackets.txt of the Unicode Character Database available at
|
||||
* http://www.unicode.org/Public/UNIDATA/BidiBrackets.txt.
|
||||
*
|
||||
* If the input character is a declared as a brackets character in the
|
||||
* Unicode standard and has a bracketed equivalent. The matching bracketed
|
||||
* character is put in the output, otherwise the input character itself is
|
||||
* put.
|
||||
*
|
||||
* \param ch input character
|
||||
*
|
||||
* \return The bracket type of the character. Use the
|
||||
* BIDI_IS_BRACKET(BidiBracketType) to test if it is a valid
|
||||
* property. Use BCHI_BRACKET_CHAR(BidiBracketType) to get
|
||||
* the bracketed character value.
|
||||
*
|
||||
* \sa UCharGetBracketTypes
|
||||
*/
|
||||
MG_EXPORT BidiBracketType GUIAPI UCharGetBracketType(Uchar32 ch);
|
||||
|
||||
/* \fn void UCharGetBracketTypes(const Uchar32 *ucs, int nr_ucs,
|
||||
* const BidiType *bidi_types, BidiBracketType *bracket_types)
|
||||
* \brief Get bracketed characters of a Uchar32 string.
|
||||
*
|
||||
* This function finds the bracketed characters of an string of characters.
|
||||
* See UCharGetBracketType() for more information about the bracketed
|
||||
* characters returned by this function.
|
||||
*
|
||||
* \param ucs The input Uchar32 string.
|
||||
* \param nr_ucs The length of string.
|
||||
* \param bidi_types The bidi types (an array of BidiType) of the string.
|
||||
* \param bracket_types The pointer to a BidiBracketType array storing
|
||||
* the bracketed characters.
|
||||
*
|
||||
* \sa UCharGetBracketType
|
||||
*/
|
||||
MG_EXPORT void GUIAPI UCharGetBracketTypes(const Uchar32 *ucs, int len_ucs,
|
||||
const BidiType *bidi_types, BidiBracketType *bracket_types);
|
||||
|
||||
/** The function returns the mirror character of a UNICODE character. */
|
||||
MG_EXPORT BOOL GUIAPI UCharGetMirror(Uchar32 uc, Uchar32* mirrored);
|
||||
@@ -9731,9 +9776,6 @@ MG_EXPORT Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv);
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef Uint16 BidiType;
|
||||
typedef Uint8 BidiLevel;
|
||||
|
||||
#define BIDI_PGDIR_LTR 0
|
||||
#define BIDI_PGDIR_RTL 1
|
||||
#define BIDI_PGDIR_ON 2
|
||||
|
||||
@@ -9,7 +9,8 @@ SRC_FILES = charset.c charset-arabic.c \
|
||||
fontcache.c freetype2.c font-engines.c\
|
||||
gbunimap.c gbkunimap.c gb18030unimap.c big5unimap.c \
|
||||
ujisunimap.c sjisunimap.c euckrunimap.c \
|
||||
textops.c mapunitogb.c mapunitogbk.c mapunitobig5.c mapunitogb18030.c \
|
||||
textops.c \
|
||||
mapunitogb.c mapunitogbk.c mapunitobig5.c mapunitogb18030.c \
|
||||
bitmapfont.c scripteasy.c \
|
||||
unicode-emoji.c \
|
||||
mgbidi.c
|
||||
|
||||
@@ -324,7 +324,7 @@ static int iso8859_2_is_this_charset (const unsigned char* charset)
|
||||
}
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
static unsigned short iso8859_2_unicode_map [] =
|
||||
static const unsigned short iso8859_2_unicode_map [] =
|
||||
{
|
||||
0x0104, 0x02D8,
|
||||
0x0141, 0x00A4, 0x013D,
|
||||
@@ -437,7 +437,7 @@ static int iso8859_3_is_this_charset (const unsigned char* charset)
|
||||
}
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
static unsigned short iso8859_3_unicode_map [] =
|
||||
static const unsigned short iso8859_3_unicode_map [] =
|
||||
{
|
||||
0x0126, 0x02D8, 0x00A3,
|
||||
0x00A4, 0x00A5, 0x0124,
|
||||
@@ -549,7 +549,7 @@ static int iso8859_4_is_this_charset (const unsigned char* charset)
|
||||
}
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
static unsigned short iso8859_4_unicode_map [] =
|
||||
static const unsigned short iso8859_4_unicode_map [] =
|
||||
{
|
||||
0x0104, 0x0138, 0x0156,
|
||||
0x00A4, 0x0128, 0x013B,
|
||||
@@ -807,7 +807,7 @@ static int iso8859_7_is_this_charset (const unsigned char* charset)
|
||||
}
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
static unsigned short iso8859_7_unicode_map [] =
|
||||
static const unsigned short iso8859_7_unicode_map [] =
|
||||
{
|
||||
0x2018, 0x2019, 0x00A3,
|
||||
0x00A4, 0x00A5, 0x00A6,
|
||||
@@ -1278,7 +1278,7 @@ static int iso8859_10_is_this_charset (const unsigned char* charset)
|
||||
}
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
static unsigned short iso8859_10_unicode_map [] =
|
||||
static const unsigned short iso8859_10_unicode_map [] =
|
||||
{
|
||||
0x0104, 0x0112, 0x0122,
|
||||
0x012A, 0x0128, 0x0136,
|
||||
@@ -1391,7 +1391,7 @@ static int iso8859_11_is_this_charset (const unsigned char* charset)
|
||||
}
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
static unsigned short iso8859_11_unicode_map [] =
|
||||
static const unsigned short iso8859_11_unicode_map [] =
|
||||
{
|
||||
0x0E01, 0x0E02, 0x0E03,
|
||||
0x0E04, 0x0E05, 0x0E06,
|
||||
@@ -1503,7 +1503,7 @@ static int iso8859_13_is_this_charset (const unsigned char* charset)
|
||||
}
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
static unsigned short iso8859_13_unicode_map [] =
|
||||
static const unsigned short iso8859_13_unicode_map [] =
|
||||
{
|
||||
0x201D, 0x00A2, 0x00A3,
|
||||
0x00A4, 0x201E, 0x00A6,
|
||||
@@ -1615,7 +1615,7 @@ static int iso8859_14_is_this_charset (const unsigned char* charset)
|
||||
}
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
static unsigned short iso8859_14_unicode_map [] =
|
||||
static const unsigned short iso8859_14_unicode_map [] =
|
||||
{
|
||||
0x1E02, 0x1E03, 0x00A3,
|
||||
0x010A, 0x010B, 0x1E0A,
|
||||
@@ -3566,6 +3566,125 @@ static unsigned int unicode_char_type (Achar32 chv)
|
||||
return (break_type << 24) | (basic_type << 16) | mchar_type;
|
||||
}
|
||||
|
||||
#define _USE_MGBIDI
|
||||
|
||||
#ifdef _USE_MGBIDI
|
||||
|
||||
enum _BidiCharTypeLinearEnum {
|
||||
#define _MGBIDI_ADD_TYPE(TYPE,SYMBOL) TYPE,
|
||||
#include "mgbidi-bidi-types-list.inc"
|
||||
#undef _MGBIDI_ADD_TYPE
|
||||
_MGBIDI_NUM_TYPES
|
||||
};
|
||||
|
||||
#include "mgbidi-bidi-type-table.inc"
|
||||
|
||||
/* Map _BidiCharTypeLinearEnum to BidiType. */
|
||||
static const BidiType linear_enum_to_bidi_type[] = {
|
||||
#define _MGBIDI_ADD_TYPE(TYPE,SYMBOL) BIDI_TYPE_##TYPE,
|
||||
#include "mgbidi-bidi-types-list.inc"
|
||||
#undef _MGBIDI_ADD_TYPE
|
||||
};
|
||||
|
||||
static BidiType unicode_bidi_char_type(Achar32 ch)
|
||||
{
|
||||
ch = REAL_ACHAR(ch);
|
||||
return linear_enum_to_bidi_type[MGBIDI_GET_BIDI_TYPE(ch)];
|
||||
}
|
||||
|
||||
BidiType GUIAPI UCharGetBidiType(Uchar32 uc)
|
||||
{
|
||||
return linear_enum_to_bidi_type[MGBIDI_GET_BIDI_TYPE(uc)];
|
||||
}
|
||||
|
||||
void UCharGetBidiTypes(const Uchar32 *str, int len, BidiType *btypes)
|
||||
{
|
||||
register int i = len;
|
||||
for (; i; i--) {
|
||||
*btypes++ = linear_enum_to_bidi_type[MGBIDI_GET_BIDI_TYPE(*str)];
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
#include "mgbidi-brackets-table.inc"
|
||||
#include "mgbidi-brackets-type-table.inc"
|
||||
|
||||
#define MGBIDI_TYPE_BRACKET_OPEN 2
|
||||
|
||||
BidiBracketType UCharGetBracketType(Uchar32 ch)
|
||||
{
|
||||
BidiBracketType bracket_type;
|
||||
register Uint8 char_type = MGBIDI_GET_BRACKET_TYPE (ch);
|
||||
|
||||
/* The bracket type from the table may be:
|
||||
0 - Not a bracket
|
||||
1 - a bracket
|
||||
2 - closing.
|
||||
|
||||
This will be recodeded into the BidiBracketType as having a
|
||||
bracket_id = 0 if the character is not a bracket.
|
||||
*/
|
||||
BOOL is_open = FALSE;
|
||||
|
||||
if (char_type == 0)
|
||||
bracket_type = BIDI_BRACKET_NONE;
|
||||
else {
|
||||
is_open = (char_type & MGBIDI_TYPE_BRACKET_OPEN) != 0;
|
||||
bracket_type = MGBIDI_GET_BRACKETS (ch) & BIDI_BRACKET_CHAR_MASK;
|
||||
}
|
||||
|
||||
if (is_open)
|
||||
bracket_type |= BIDI_BRACKET_OPEN_MASK;
|
||||
|
||||
return bracket_type;
|
||||
}
|
||||
|
||||
void UCharGetBracketTypes(const Uchar32 *str, int len,
|
||||
const BidiType *types, BidiBracketType *btypes)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
/* Optimization that bracket must be of types ON */
|
||||
if (*types == BIDI_TYPE_ON)
|
||||
*btypes = UCharGetBracketType (*str);
|
||||
else
|
||||
*btypes = BIDI_BRACKET_NONE;
|
||||
|
||||
btypes++;
|
||||
types++;
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
#include "mgbidi-mirroring-table.inc"
|
||||
|
||||
static BOOL unicode_bidi_mirror_char(Achar32 ch, Achar32* mirrored_ch)
|
||||
{
|
||||
register Achar32 result;
|
||||
register Uint32 mbc_mask;
|
||||
|
||||
mbc_mask = ch & ACHAR_MBC_FLAG;
|
||||
ch = REAL_ACHAR(ch);
|
||||
result = MGBIDI_GET_MIRRORING(ch);
|
||||
if (mirrored_ch)
|
||||
*mirrored_ch = result;
|
||||
result |= mbc_mask;
|
||||
|
||||
return ch != result ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
BOOL GUIAPI UCharGetMirror(Uchar32 ch, Uchar32* mirrored_ch)
|
||||
{
|
||||
register Achar32 result;
|
||||
|
||||
result = MGBIDI_GET_MIRRORING(ch);
|
||||
if (mirrored_ch)
|
||||
*mirrored_ch = result;
|
||||
return ch != result ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "unicode-bidi-tables.h"
|
||||
|
||||
static Uint16 unicode_bidi_char_type (Achar32 chv)
|
||||
@@ -3603,6 +3722,63 @@ static BOOL unicode_bidi_mirror_char (Achar32 chv, Achar32* mirrored)
|
||||
TABLESIZE (__mg_unicode_mirror_table), chv, mirrored);
|
||||
}
|
||||
|
||||
BidiType GUIAPI UCharGetBidiType(Uchar32 uc)
|
||||
{
|
||||
return unicode_bidi_char_type(uc);
|
||||
}
|
||||
|
||||
BidiBracketType GUIAPI UCharGetBracketType(Uchar32 uc)
|
||||
{
|
||||
BidiBracketType bracket_type;
|
||||
unsigned int lower = 0;
|
||||
unsigned int upper = TABLESIZE (__mg_unicode_bracket_table) - 1;
|
||||
int mid = TABLESIZE (__mg_unicode_bracket_table) / 2;
|
||||
|
||||
if (uc < __mg_unicode_bracket_table[lower].chv ||
|
||||
uc > __mg_unicode_bracket_table[upper].chv)
|
||||
return BIDI_BRACKET_NONE;
|
||||
|
||||
do {
|
||||
if (uc < __mg_unicode_bracket_table[mid].chv)
|
||||
upper = mid - 1;
|
||||
else if (uc > __mg_unicode_bracket_table[mid].chv)
|
||||
lower = mid + 1;
|
||||
else
|
||||
goto found;
|
||||
|
||||
mid = (lower + upper) / 2;
|
||||
|
||||
} while (lower <= upper);
|
||||
|
||||
return BIDI_BRACKET_NONE;
|
||||
|
||||
found:
|
||||
bracket_type = __mg_unicode_bracket_table[mid].chv +
|
||||
__mg_unicode_bracket_table[mid].bracket_off;
|
||||
bracket_type &= BIDI_BRACKET_CHAR_MASK;
|
||||
if (__mg_unicode_bracket_table[mid].type == MGBIDI_BRACKET_OPEN)
|
||||
bracket_type |= BIDI_BRACKET_OPEN_MASK;
|
||||
|
||||
return bracket_type;
|
||||
}
|
||||
|
||||
void GUIAPI UCharGetBidiTypes(const Uchar32 *str, int len, BidiType *btypes)
|
||||
{
|
||||
register int i = len;
|
||||
for (; i; i--) {
|
||||
*btypes++ = UCharGetBracketType(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
/** The function returns the mirror character of a UNICODE character. */
|
||||
BOOL GUIAPI UCharGetMirror(Uchar32 uc, Uchar32* mirrored)
|
||||
{
|
||||
return unicode_bidi_mirror_char (uc, mirrored);
|
||||
}
|
||||
|
||||
#endif /* !_USE_MGBIDI */
|
||||
|
||||
static int utf8_nr_chars_in_str (const unsigned char* mstr, int mstrlen)
|
||||
{
|
||||
int charlen;
|
||||
@@ -4401,44 +4577,6 @@ UCharBreakType GUIAPI UCharGetBreakType(Uchar32 uc)
|
||||
return (UCharBreakType)PROP(uc);
|
||||
}
|
||||
|
||||
/** The function determines the BIDI type of a UNICODE character. */
|
||||
Uint16 GUIAPI UCharGetBIDIType(Uchar32 uc)
|
||||
{
|
||||
return unicode_bidi_char_type(uc);
|
||||
}
|
||||
|
||||
/** The function returns the bracket type of a UNICODE character. */
|
||||
Uint8 GUIAPI UCharGetBracketType(Uchar32 uc)
|
||||
{
|
||||
unsigned int lower = 0;
|
||||
unsigned int upper = TABLESIZE (__mg_unicode_bracket_table) - 1;
|
||||
int mid = TABLESIZE (__mg_unicode_bracket_table) / 2;
|
||||
|
||||
if (uc < __mg_unicode_bracket_table[lower].chv ||
|
||||
uc > __mg_unicode_bracket_table[upper].chv)
|
||||
return BIDICHAR_BRACKET_NONE;
|
||||
|
||||
do {
|
||||
if (uc < __mg_unicode_bracket_table[mid].chv)
|
||||
upper = mid - 1;
|
||||
else if (uc > __mg_unicode_bracket_table[mid].chv)
|
||||
lower = mid + 1;
|
||||
else
|
||||
return __mg_unicode_bracket_table[mid].type;
|
||||
|
||||
mid = (lower + upper) / 2;
|
||||
|
||||
} while (lower <= upper);
|
||||
|
||||
return BIDICHAR_BRACKET_NONE;
|
||||
}
|
||||
|
||||
/** The function returns the mirror character of a UNICODE character. */
|
||||
BOOL GUIAPI UCharGetMirror(Uchar32 uc, Uchar32* mirrored)
|
||||
{
|
||||
return unicode_bidi_mirror_char (uc, mirrored);
|
||||
}
|
||||
|
||||
BOOL GUIAPI IsUCharAlnum(Uchar32 uc)
|
||||
{
|
||||
return ISALDIGIT(TYPE(uc));
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
use MGBIDI_GET_BRACKETS_DELTA(key) to access your table
|
||||
|
||||
assumed sizeof(Int32): 4
|
||||
assumed sizeof(Sint32): 4
|
||||
required memory: 6400
|
||||
lookups: 2
|
||||
partition shape: Brk[1024][64]
|
||||
different table entries: 1 17
|
||||
*/
|
||||
static const Int32 BrkLev1[64*17] = {
|
||||
static const Sint32 BrkLev1[64*17] = {
|
||||
#define BrkLev1_0000 0x0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
use MGBIDI_GET_BRACKET_TYPE(key) to access your table
|
||||
|
||||
assumed sizeof(Int8): 1
|
||||
assumed sizeof(Sint8): 1
|
||||
required memory: 2816
|
||||
lookups: 2
|
||||
partition shape: Brt[512][128]
|
||||
different table entries: 1 14
|
||||
*/
|
||||
static const Int8 BrtLev1[128*14] = {
|
||||
static const Sint8 BrtLev1[128*14] = {
|
||||
#define BrtLev1_0000 0x0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
use MGBIDI_GET_MIRRORING_DELTA(key) to access your table
|
||||
|
||||
assumed sizeof(Int16): 2
|
||||
assumed sizeof(Sint16): 2
|
||||
required memory: 5632
|
||||
lookups: 2
|
||||
partition shape: Mir[1024][64]
|
||||
different table entries: 1 28
|
||||
*/
|
||||
static const Int16 MirLev1[64*28] = {
|
||||
static const Sint16 MirLev1[64*28] = {
|
||||
#define MirLev1_0000 0x0
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,-2,0,
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static inline int gbidi_debug_status(void)
|
||||
static inline int mgbidi_debug_status(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -166,14 +166,14 @@ static BidiRun* run_list_encode_bidi_types (const BidiType *bidi_types,
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
register BidiType char_type = bidi_types[i];
|
||||
register Uint8 bracket_type = BIDICHAR_BRACKET_NONE;
|
||||
register Uint8 bracket_type = BIDI_BRACKET_NONE;
|
||||
if (bracket_types)
|
||||
bracket_type = bracket_types[i];
|
||||
|
||||
if (char_type != last->type
|
||||
/* Always separate bracket into single char runs! */
|
||||
|| bracket_type != BIDICHAR_BRACKET_NONE
|
||||
|| last->bracket_type != BIDICHAR_BRACKET_NONE
|
||||
|| bracket_type != BIDI_BRACKET_NONE
|
||||
|| last->bracket_type != BIDI_BRACKET_NONE
|
||||
|| BIDI_IS_ISOLATE(char_type)) {
|
||||
run = new_run ();
|
||||
if (!run) break;
|
||||
@@ -377,8 +377,8 @@ static void compact_list(BidiRun *list)
|
||||
if (RL_TYPE (list->prev) == RL_TYPE (list)
|
||||
&& RL_LEVEL (list->prev) == RL_LEVEL (list)
|
||||
/* Don't join brackets! */
|
||||
&& RL_BRACKET_TYPE(list) == BIDICHAR_BRACKET_NONE
|
||||
&& RL_BRACKET_TYPE(list->prev) == BIDICHAR_BRACKET_NONE) {
|
||||
&& RL_BRACKET_TYPE(list) == BIDI_BRACKET_NONE
|
||||
&& RL_BRACKET_TYPE(list->prev) == BIDI_BRACKET_NONE) {
|
||||
list = merge_with_prev (list);
|
||||
}
|
||||
}
|
||||
@@ -395,8 +395,8 @@ static void compact_neutrals(BidiRun *list)
|
||||
|| (BIDI_IS_NEUTRAL (RL_TYPE (list->prev))
|
||||
&& BIDI_IS_NEUTRAL (RL_TYPE (list)))))
|
||||
/* Don't join brackets! */
|
||||
&& RL_BRACKET_TYPE(list) == BIDICHAR_BRACKET_NONE
|
||||
&& RL_BRACKET_TYPE(list->prev) == BIDICHAR_BRACKET_NONE) {
|
||||
&& RL_BRACKET_TYPE(list) == BIDI_BRACKET_NONE
|
||||
&& RL_BRACKET_TYPE(list->prev) == BIDI_BRACKET_NONE) {
|
||||
list = merge_with_prev (list);
|
||||
}
|
||||
}
|
||||
@@ -411,7 +411,7 @@ static void compact_neutrals(BidiRun *list)
|
||||
/* The static sentinel is used to signal the end of an isolating sequence */
|
||||
static BidiRun sentinel = {
|
||||
NULL, NULL, NULL, NULL, 0, 0, BIDI_TYPE_SENTINEL, -1, -1,
|
||||
BIDICHAR_BRACKET_NONE,
|
||||
BIDI_BRACKET_NONE,
|
||||
};
|
||||
|
||||
static BidiRun *get_adjacent_run(BidiRun *list,
|
||||
@@ -479,9 +479,9 @@ static const char char_from_level_array[] = {
|
||||
'*', '*', '*', '*', '*'
|
||||
};
|
||||
|
||||
#define gbidi_char_from_level(level) char_from_level_array[(level) + 1]
|
||||
#define mgbidi_char_from_level(level) char_from_level_array[(level) + 1]
|
||||
|
||||
static const char *gbidi_get_bidi_type_name(BidiType t)
|
||||
static const char *mgbidi_get_bidi_type_name(BidiType t)
|
||||
{
|
||||
switch ((int)t) {
|
||||
# define _BIDI_ADD_TYPE(TYPE,SYMBOL) case BIDI_TYPE_##TYPE: return #TYPE;
|
||||
@@ -499,7 +499,7 @@ static void print_types_re(const BidiRun *pp)
|
||||
_DBG_PRINTF (" Run types : ");
|
||||
for_run_list (pp, pp) {
|
||||
_DBG_PRINTF ("%d:%d(%s)[%d,%d] ",
|
||||
pp->pos, pp->len, gbidi_get_bidi_type_name (pp->type), pp->level, pp->isolate_level);
|
||||
pp->pos, pp->len, mgbidi_get_bidi_type_name (pp->type), pp->level, pp->isolate_level);
|
||||
}
|
||||
_DBG_PRINTF ("\n");
|
||||
}
|
||||
@@ -511,7 +511,7 @@ static void print_resolved_levels(const BidiRun *pp)
|
||||
{
|
||||
register int i;
|
||||
for (i = RL_LEN (pp); i; i--)
|
||||
_DBG_PRINTF ("%c", gbidi_char_from_level (RL_LEVEL (pp)));
|
||||
_DBG_PRINTF ("%c", mgbidi_char_from_level (RL_LEVEL (pp)));
|
||||
}
|
||||
_DBG_PRINTF ("\n");
|
||||
}
|
||||
@@ -522,7 +522,7 @@ static void print_resolved_types(const BidiRun *pp)
|
||||
for_run_list (pp, pp) {
|
||||
int i;
|
||||
for (i = RL_LEN (pp); i; i--)
|
||||
_DBG_PRINTF ("%s ", gbidi_get_bidi_type_name (pp->type));
|
||||
_DBG_PRINTF ("%s ", mgbidi_get_bidi_type_name (pp->type));
|
||||
}
|
||||
_DBG_PRINTF ("\n");
|
||||
}
|
||||
@@ -533,7 +533,7 @@ static void print_bidi_string(const BidiType *bidi_types, const int len)
|
||||
|
||||
_DBG_PRINTF (" Org. types : ");
|
||||
for (i = 0; i < len; i++)
|
||||
_DBG_PRINTF ("%s ", gbidi_get_bidi_type_name (bidi_types[i]));
|
||||
_DBG_PRINTF ("%s ", mgbidi_get_bidi_type_name (bidi_types[i]));
|
||||
_DBG_PRINTF ("\n");
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ static void print_pairing_nodes(BidiPairingNode *nodes)
|
||||
#define BIDI_EMBEDDING_DIRECTION(link) \
|
||||
BIDI_LEVEL_TO_DIR(RL_LEVEL(link))
|
||||
|
||||
int gbidi_get_par_direction(const BidiType *bidi_types, const int len)
|
||||
int mgbidi_get_par_direction(const BidiType *bidi_types, const int len)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -741,7 +741,7 @@ static void free_pairing_nodes(BidiPairingNode *nodes)
|
||||
}
|
||||
}
|
||||
|
||||
BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
const Uint8 *bracket_types, const int len,
|
||||
int *pbase_dir, BidiLevel *embedding_levels)
|
||||
{
|
||||
@@ -757,7 +757,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
goto out;
|
||||
}
|
||||
|
||||
_DBG_PRINTF ("in gbidi_get_paragraph_els");
|
||||
_DBG_PRINTF ("in mgbidi_get_paragraph_els");
|
||||
|
||||
/* Determinate character types */
|
||||
{
|
||||
@@ -794,13 +794,13 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
}
|
||||
}
|
||||
base_dir = BIDI_LEVEL_TO_DIR (base_level);
|
||||
_DBG_PRINTF (" base level : %c", gbidi_char_from_level (base_level));
|
||||
_DBG_PRINTF (" base dir : %s", gbidi_get_bidi_type_name (base_dir));
|
||||
_DBG_PRINTF (" base level : %c", mgbidi_char_from_level (base_level));
|
||||
_DBG_PRINTF (" base dir : %s", mgbidi_get_bidi_type_name (base_dir));
|
||||
|
||||
base_level_per_iso_level[0] = base_level;
|
||||
|
||||
# ifdef DEBUG
|
||||
if (gbidi_debug_status ()) {
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_types_re (main_run_list);
|
||||
}
|
||||
# endif /* DEBUG */
|
||||
@@ -1043,7 +1043,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
compact_list (main_run_list);
|
||||
|
||||
# ifdef DEBUG
|
||||
if (gbidi_debug_status ()) {
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_types_re (main_run_list);
|
||||
print_bidi_string (bidi_types, len);
|
||||
print_resolved_levels (main_run_list);
|
||||
@@ -1225,7 +1225,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
compact_neutrals (main_run_list);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (gbidi_debug_status ()) {
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
@@ -1273,7 +1273,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
if (level != last_level && last_iso_level == iso_level)
|
||||
bracket_stack_size[last_iso_level] = 0;
|
||||
|
||||
if (brack_prop!= BIDICHAR_BRACKET_NONE
|
||||
if (brack_prop!= BIDI_BRACKET_NONE
|
||||
&& RL_TYPE(pp)==BIDI_TYPE_ON) {
|
||||
if (BIDI_IS_BRACKET_OPEN(brack_prop)) {
|
||||
if (bracket_stack_size[iso_level] ==
|
||||
@@ -1308,7 +1308,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
sort_pairing_nodes(&pairing_nodes);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (gbidi_debug_status ()) {
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_pairing_nodes (pairing_nodes);
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
@@ -1393,7 +1393,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
|
||||
/* Remove the bracket property and re-compact */
|
||||
{
|
||||
const Uint8 NoBracket = BIDICHAR_BRACKET_NONE;
|
||||
const Uint8 NoBracket = BIDI_BRACKET_NONE;
|
||||
for_run_list (pp, main_run_list)
|
||||
pp->bracket_type = NoBracket;
|
||||
compact_neutrals (main_run_list);
|
||||
@@ -1401,8 +1401,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (gbidi_debug_status ())
|
||||
{
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
@@ -1443,7 +1442,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
compact_list (main_run_list);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (gbidi_debug_status ()) {
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
@@ -1479,7 +1478,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
compact_list (main_run_list);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (gbidi_debug_status ()) {
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_bidi_string (bidi_types, len);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
@@ -1506,7 +1505,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
}
|
||||
|
||||
# ifdef DEBUG
|
||||
if (gbidi_debug_status ()) {
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_types_re (main_run_list);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
@@ -1526,7 +1525,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
separator or paragraph separator, and
|
||||
4. any sequence of whitespace characters and/or isolate formatting
|
||||
characters at the end of the line.
|
||||
... (to be continued in gbidi_reorder_line()). */
|
||||
... (to be continued in mgbidi_reorder_line()). */
|
||||
list = new_run_list ();
|
||||
if (!list) goto out;
|
||||
q = list;
|
||||
@@ -1566,7 +1565,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (gbidi_debug_status ()) {
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_types_re (main_run_list);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
@@ -1587,7 +1586,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
status = TRUE;
|
||||
|
||||
out:
|
||||
_DBG_PRINTF ("leaving gbidi_get_paragraph_els");
|
||||
_DBG_PRINTF ("leaving mgbidi_get_paragraph_els");
|
||||
|
||||
if (main_run_list)
|
||||
free_run_list (main_run_list);
|
||||
@@ -1620,7 +1619,7 @@ static void index_array_reverse (int *arr, int len)
|
||||
}
|
||||
}
|
||||
|
||||
BidiLevel gbidi_reorder_line(Uint32 flags,
|
||||
BidiLevel mgbidi_reorder_line(Uint32 flags,
|
||||
const BidiType *bidi_types, int len,
|
||||
int off, int base_dir,
|
||||
BidiLevel *embedding_levels,
|
||||
@@ -1635,7 +1634,7 @@ BidiLevel gbidi_reorder_line(Uint32 flags,
|
||||
goto out;
|
||||
}
|
||||
|
||||
_DBG_PRINTF ("in gbidi_reorder_line");
|
||||
_DBG_PRINTF ("in mgbidi_reorder_line");
|
||||
|
||||
_DBG_PRINTF ("reset the embedding levels, 4. whitespace at the end of line");
|
||||
{
|
||||
|
||||
@@ -59,21 +59,21 @@
|
||||
#define STRINGIZE(symbol) #symbol
|
||||
|
||||
/* A few macros for working with bits */
|
||||
#define BIDI_TEST_BITS(x, mask) (((x) & (mask)) ? 1 : 0)
|
||||
#define BIDI_TEST_BITS(x, mask) (((x) & (mask)) ? 1 : 0)
|
||||
|
||||
#define BIDI_INCLUDE_BITS(x, mask) ((x) | (mask))
|
||||
#define BIDI_INCLUDE_BITS(x, mask) ((x) | (mask))
|
||||
|
||||
#define BIDI_EXCLUDE_BITS(x, mask) ((x) & ~(mask))
|
||||
#define BIDI_EXCLUDE_BITS(x, mask) ((x) & ~(mask))
|
||||
|
||||
#define BIDI_SET_BITS(x, mask) ((x) |= (mask))
|
||||
#define BIDI_SET_BITS(x, mask) ((x) |= (mask))
|
||||
|
||||
#define BIDI_UNSET_BITS(x, mask) ((x) &= ~(mask))
|
||||
#define BIDI_UNSET_BITS(x, mask) ((x) &= ~(mask))
|
||||
|
||||
#define BIDI_ADJUST_BITS(x, mask, cond) \
|
||||
((x) = ((x) & ~(mask)) | ((cond) ? (mask) : 0))
|
||||
#define BIDI_ADJUST_BITS(x, mask, cond) \
|
||||
((x) = ((x) & ~(mask)) | ((cond) ? (mask) : 0))
|
||||
|
||||
#define BIDI_ADJUST_AND_TEST_BITS(x, mask, cond) \
|
||||
BIDI_TEST_BITS(BIDI_ADJUST_BITS((x), (mask), (cond)), (mask))
|
||||
#define BIDI_ADJUST_AND_TEST_BITS(x, mask, cond) \
|
||||
BIDI_TEST_BITS(BIDI_ADJUST_BITS((x), (mask), (cond)), (mask))
|
||||
|
||||
/* The maximum embedding level value assigned by explicit marks */
|
||||
#define BIDI_MAX_EXPLICIT_LEVEL 125
|
||||
@@ -147,7 +147,7 @@ struct _BidiRun {
|
||||
for ((x) = (list)->next; (x)->type != BIDI_TYPE_SENTINEL; (x) = (x)->next)
|
||||
|
||||
/**
|
||||
* \fn gbidi_get_paragraph_dir
|
||||
* \fn mgbidi_get_paragraph_dir
|
||||
* \brief get base paragraph direction
|
||||
*
|
||||
* This function finds the base direction of a single paragraph,
|
||||
@@ -155,7 +155,7 @@ struct _BidiRun {
|
||||
* http://www.unicode.org/reports/tr9/#P2.
|
||||
*
|
||||
* You typically do not need this function as
|
||||
* gbidi_get_paragraph_els() knows how to compute base direction
|
||||
* mgbidi_get_paragraph_els() knows how to compute base direction
|
||||
* itself, but you may need this to implement a more sophisticated paragraph
|
||||
* direction handling. Note that you can pass more than a paragraph to this
|
||||
* function and the direction of the first non-neutral paragraph is returned,
|
||||
@@ -164,32 +164,32 @@ struct _BidiRun {
|
||||
* direction of the previous paragraph.
|
||||
*
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* gbidi_get_bidi_types()
|
||||
* mgbidi_get_bidi_types()
|
||||
* \param len The length of bidi_types
|
||||
*
|
||||
* \return Base pargraph direction. No weak paragraph direction is returned,
|
||||
* only BIDI_PGDIR_LTR, BIDI_PGDIR_RTL, or BIDI_PGDIR_ON.
|
||||
*
|
||||
*/
|
||||
int gbidi_get_paragraph_dir(const BidiType *bidi_types, int len);
|
||||
int mgbidi_get_paragraph_dir(const BidiType *bidi_types, int len);
|
||||
|
||||
/* gbidi_get_paragraph_els_ex - get bidi embedding levels of a paragraph
|
||||
/* mgbidi_get_paragraph_els_ex - get bidi embedding levels of a paragraph
|
||||
*
|
||||
* This function finds the bidi embedding levels of a single paragraph,
|
||||
* as defined by the Unicode Bidirectional Algorithm available at
|
||||
* http://www.unicode.org/reports/tr9/.
|
||||
*
|
||||
* This function implements rules P2 to I1 inclusive, and parts 1 to 3 of L1,
|
||||
* except for rule X9 which is implemented in gbidi_remove_bidi_marks().
|
||||
* Part 4 of L1 is implemented in gbidi_reorder_line().
|
||||
* except for rule X9 which is implemented in mgbidi_remove_bidi_marks().
|
||||
* Part 4 of L1 is implemented in mgbidi_reorder_line().
|
||||
*
|
||||
* There are a few macros defined in gbidi-bidi-types.h to work with this
|
||||
* There are a few macros defined in mgbidi-bidi-types.h to work with this
|
||||
* embedding levels.
|
||||
*
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* gbidi_get_bidi_types()
|
||||
* mgbidi_get_bidi_types()
|
||||
* \param bracket_types The pointer to a Uint8 which contains the
|
||||
bracket types as returned by gbidi_get_bracket_types()
|
||||
bracket types as returned by mgbidi_get_bracket_types()
|
||||
* \param len The length of the list.
|
||||
* \param base_dir requested and resolved paragraph base direction
|
||||
* \param embedding_levels The pointer to a buffer which will restore
|
||||
@@ -198,11 +198,11 @@ int gbidi_get_paragraph_dir(const BidiType *bidi_types, int len);
|
||||
* \return The Maximum level found plus one, or zero if any error occurred
|
||||
* (memory allocation failure most probably).
|
||||
*/
|
||||
BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
const Uint8* bracket_types, int len,
|
||||
int *base_dir, BidiLevel *embedding_levels);
|
||||
|
||||
/* gbidi_reorder_line - reorder a line of logical string to visual
|
||||
/* mgbidi_reorder_line - reorder a line of logical string to visual
|
||||
*
|
||||
* This function reorders the characters in a line of text from logical to
|
||||
* final visual order.
|
||||
@@ -214,7 +214,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
* As a side effect it also sets position maps if not NULL.
|
||||
*
|
||||
* You should provide the resolved paragraph direction and embedding levels as
|
||||
* set by gbidi_get_paragraph_els(). Also note that the embedding
|
||||
* set by mgbidi_get_paragraph_els(). Also note that the embedding
|
||||
* levels may change a bit. To be exact, the embedding level of any sequence
|
||||
* of white space at the end of line is reset to the paragraph embedding level
|
||||
* (That is part 4 of rule L1).
|
||||
@@ -234,14 +234,14 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
*
|
||||
* \param flags The reorder flags.
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* gbidi_get_bidi_types()
|
||||
* mgbidi_get_bidi_types()
|
||||
* \param bracket_types The pointer to a Uint8 which contains the
|
||||
bracket types as returned by gbidi_get_bracket_types()
|
||||
bracket types as returned by mgbidi_get_bracket_types()
|
||||
* \param len The length of the list.
|
||||
* \param off The input offset of the beginning of the line in the paragraph.
|
||||
* \param base_dir The resolved paragraph base direction.
|
||||
* \param embedding_levels The embedding levels, as returned by
|
||||
gbidi_get_paragraph_els()
|
||||
mgbidi_get_paragraph_els()
|
||||
* \param visual_str
|
||||
* \param extra The pointer to the extra array to reorder; can be NULL.
|
||||
* \param cb_reverse_extra The callback function to reverse the extra array.
|
||||
@@ -251,7 +251,7 @@ BidiLevel gbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
* \return Maximum level found in this line plus one, or zero if any error
|
||||
* occurred (memory allocation failure most probably).
|
||||
*/
|
||||
BidiLevel gbidi_reorder_line(Uint32 flags, const BidiType *bidi_types,
|
||||
BidiLevel mgbidi_reorder_line(Uint32 flags, const BidiType *bidi_types,
|
||||
int len, int off, int base_dir, BidiLevel *embedding_levels,
|
||||
Achar32 *visual_str, int *map,
|
||||
void* extra, CB_REVERSE_EXTRA cb_reverse_extra);
|
||||
|
||||
@@ -1159,126 +1159,126 @@ static const BIDICHAR_TYPE_MAP __mg_unicode_bidi_char_type_map[] =
|
||||
|
||||
static const BIDICHAR_BRACKET __mg_unicode_bracket_table[] =
|
||||
{
|
||||
{ 0x000028, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x000029, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00005B, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00005D, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00007B, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00007D, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x000F3A, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x000F3B, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x000F3C, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x000F3D, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00169B, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00169C, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002045, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002046, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00207D, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00207E, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00208D, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00208E, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002308, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002309, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00230A, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00230B, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002329, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00232A, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002768, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002769, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00276A, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00276B, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00276C, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00276D, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00276E, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00276F, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002770, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002771, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002772, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002773, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002774, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002775, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0027C5, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0027C6, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0027E6, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0027E7, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0027E8, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0027E9, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0027EA, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0027EB, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0027EC, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0027ED, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0027EE, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0027EF, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002983, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002984, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002985, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002986, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002987, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002988, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002989, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00298A, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00298B, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00298C, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00298D, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00298E, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00298F, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002990, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002991, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002992, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002993, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002994, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002995, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002996, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002997, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002998, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0029D8, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0029D9, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0029DA, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0029DB, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x0029FC, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x0029FD, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002E22, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002E23, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002E24, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002E25, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002E26, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002E27, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x002E28, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x002E29, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x003008, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x003009, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00300A, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00300B, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00300C, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00300D, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00300E, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00300F, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x003010, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x003011, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x003014, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x003015, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x003016, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x003017, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x003018, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x003019, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00301A, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00301B, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00FE59, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00FE5A, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00FE5B, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00FE5C, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00FE5D, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00FE5E, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00FF08, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00FF09, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00FF3B, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00FF3D, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00FF5B, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00FF5D, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00FF5F, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00FF60, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x00FF62, BIDICHAR_BRACKET_OPEN },
|
||||
{ 0x00FF63, BIDICHAR_BRACKET_CLOSE },
|
||||
{ 0x000028, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x000029, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00005B, 2, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00005D, -2, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00007B, 2, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00007D, -2, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x000F3A, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x000F3B, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x000F3C, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x000F3D, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00169B, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00169C, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002045, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002046, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00207D, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00207E, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00208D, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00208E, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002308, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002309, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00230A, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00230B, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002329, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00232A, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002768, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002769, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00276A, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00276B, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00276C, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00276D, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00276E, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00276F, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002770, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002771, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002772, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002773, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002774, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002775, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0027C5, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0027C6, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0027E6, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0027E7, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0027E8, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0027E9, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0027EA, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0027EB, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0027EC, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0027ED, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0027EE, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0027EF, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002983, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002984, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002985, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002986, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002987, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002988, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002989, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00298A, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00298B, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00298C, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00298D, 3, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00298E, 1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00298F, -1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002990, -3, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002991, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002992, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002993, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002994, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002995, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002996, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002997, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002998, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0029D8, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0029D9, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0029DA, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0029DB, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x0029FC, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x0029FD, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002E22, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002E23, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002E24, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002E25, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002E26, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002E27, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x002E28, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x002E29, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x003008, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x003009, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00300A, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00300B, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00300C, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00300D, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00300E, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00300F, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x003010, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x003011, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x003014, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x003015, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x003016, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x003017, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x003018, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x003019, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00301A, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00301B, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00FE59, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00FE5A, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00FE5B, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00FE5C, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00FE5D, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00FE5E, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00FF08, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00FF09, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00FF3B, 2, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00FF3D, -2, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00FF5B, 2, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00FF5D, -2, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00FF5F, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00FF60, -1, MGBIDI_BRACKET_CLOSE },
|
||||
{ 0x00FF62, 1, MGBIDI_BRACKET_OPEN },
|
||||
{ 0x00FF63, -1, MGBIDI_BRACKET_CLOSE },
|
||||
};
|
||||
|
||||
static const BIDICHAR_MIRROR_MAP __mg_unicode_mirror_table[] =
|
||||
|
||||
@@ -44,11 +44,13 @@ for i, f in enumerate (files):
|
||||
|
||||
if i == 1:
|
||||
t = fields[2]
|
||||
v = [int (fields[1], 16), fields[2]]
|
||||
else:
|
||||
t = fields[1]
|
||||
v = fields[1]
|
||||
|
||||
for u in range (start, end + 1):
|
||||
data[i][u] = t
|
||||
data[i][u] = v
|
||||
values[i][t] = values[i].get (t, 0) + end - start + 1
|
||||
|
||||
# The unassigned code points that default to AL are in the ranges:
|
||||
@@ -233,16 +235,17 @@ print ("{")
|
||||
d = data[1]
|
||||
uu = sorted (d.keys())
|
||||
for u in uu:
|
||||
v = d[u]
|
||||
v = v.strip()
|
||||
if cmp(v, 'o') == 0:
|
||||
bracket_type = "BIDICHAR_BRACKET_OPEN"
|
||||
elif cmp(v, 'c') == 0:
|
||||
bracket_type = "BIDICHAR_BRACKET_CLOSE"
|
||||
v0 = d[u][0]
|
||||
v1 = d[u][1]
|
||||
v1 = v1.strip()
|
||||
if cmp(v1, 'o') == 0:
|
||||
bracket_type = "MGBIDI_BRACKET_OPEN"
|
||||
elif cmp(v1, 'c') == 0:
|
||||
bracket_type = "MGBIDI_BRACKET_CLOSE"
|
||||
else:
|
||||
bracket_type = "BIDICHAR_BRACKET_NONE"
|
||||
bracket_type = "MGBIDI_BRACKET_NONE"
|
||||
|
||||
print (" { 0x%06X, %s }," % (u, bracket_type, ))
|
||||
print (" { 0x%06X, %d, %s }," % (u, v0 - u, bracket_type, ))
|
||||
|
||||
print ("};")
|
||||
print ("")
|
||||
|
||||
@@ -292,8 +292,8 @@ gen_brackets_tab (
|
||||
"#define PACKTAB_UINT32 Uint32\n\n");
|
||||
|
||||
key_bytes = max_dist <= 0x7f ? 1 : max_dist < 0x7fff ? 2 : 4;
|
||||
key_type = key_bytes == 1 ? "Int8" : key_bytes == 2 ?
|
||||
"Int16" : "Int32";
|
||||
key_type = key_bytes == 1 ? "Sint8" : key_bytes == 2 ?
|
||||
"Sint16" : "Sint32";
|
||||
|
||||
if (!pack_table
|
||||
(table, MGBIDI_UNICODE_CHARS, key_bytes, 0, max_depth, 1, NULL,
|
||||
|
||||
@@ -183,8 +183,8 @@ gen_brackets_tab (
|
||||
"#define PACKTAB_UINT32 Uint32\n\n");
|
||||
|
||||
key_bytes = 1;
|
||||
key_type = key_bytes == 1 ? "Int8" : key_bytes == 2 ?
|
||||
"Int16" : "Int32";
|
||||
key_type = key_bytes == 1 ? "Sint8" : key_bytes == 2 ?
|
||||
"Sint16" : "Sint32";
|
||||
|
||||
if (!pack_table
|
||||
(table, MGBIDI_UNICODE_CHARS, key_bytes, 0, max_depth, 1, NULL,
|
||||
|
||||
@@ -186,8 +186,8 @@ gen_mirroring_tab (
|
||||
"#define PACKTAB_UINT32 Uint32\n\n");
|
||||
|
||||
key_bytes = max_dist <= 0x7f ? 1 : max_dist < 0x7fff ? 2 : 4;
|
||||
key_type = key_bytes == 1 ? "Int8" : key_bytes == 2 ?
|
||||
"Int16" : "Int32";
|
||||
key_type = key_bytes == 1 ? "Sint8" : key_bytes == 2 ?
|
||||
"Sint16" : "Sint32";
|
||||
|
||||
if (!pack_table
|
||||
(table, MGBIDI_UNICODE_CHARS, key_bytes, 0, max_depth, 1, NULL,
|
||||
|
||||
@@ -58,17 +58,22 @@ extern "C" {
|
||||
#define DBGLOG4(s, t1, t2, t3)
|
||||
#endif
|
||||
|
||||
typedef struct _TYPERUN TYPERUN;
|
||||
|
||||
typedef struct _BIDICHAR_TYPE_MAP {
|
||||
Uchar32 chv; // Starting code point of Unicode character
|
||||
Uint16 count; // Total number of Unicode characters of same type starting from chv
|
||||
Uint16 type; // Type of Unicode characters
|
||||
} BIDICHAR_TYPE_MAP;
|
||||
|
||||
typedef struct _TYPERUN TYPERUN;
|
||||
#define MGBIDI_BRACKET_NONE 0
|
||||
#define MGBIDI_BRACKET_CLOSE 1
|
||||
#define MGBIDI_BRACKET_OPEN 2
|
||||
|
||||
// NOTE: It is enough to use Uint16 for Unicode bracket table
|
||||
typedef struct _BIDICHAR_BRACKET {
|
||||
Uint16 chv;
|
||||
Sint8 bracket_off;
|
||||
Uint8 type;
|
||||
} BIDICHAR_BRACKET;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user