add new API UCharGetBracketType

This commit is contained in:
Vincent Wei
2019-03-07 17:42:47 +08:00
parent e6cb8f272b
commit 5887668b17
3 changed files with 34 additions and 5 deletions

View File

@@ -7470,6 +7470,13 @@ 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
/** The function returns the bracket type of a UNICODE character. */
MG_EXPORT Uint8 GUIAPI UCharGetBracketType(Uchar32 uc);
/** The function returns the mirror character of a UNICODE character. */
MG_EXPORT BOOL GUIAPI UCharGetMirror(Uchar32 uc, Uchar32* mirrored);

View File

@@ -4406,6 +4406,32 @@ 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)
{
@@ -4881,7 +4907,7 @@ Uchar32 GUIAPI UCharToSmallKana (Uchar32 uc)
int mid = TABLESIZE (kana_small_to_full_size_table) / 2;
if (uc < kana_small_to_full_size_table[lower].other
|| uc < kana_small_to_full_size_table[upper].other)
|| uc > kana_small_to_full_size_table[upper].other)
return uc;
do {

View File

@@ -67,10 +67,6 @@ typedef struct _BIDICHAR_TYPE_MAP {
typedef struct _TYPERUN TYPERUN;
#define BIDICHAR_BRACKET_NONE 0
#define BIDICHAR_BRACKET_OPEN 1
#define BIDICHAR_BRACKET_CLOSE 2
// NOTE: It is enough to use Uint16 for Unicode bracket table
typedef struct _BIDICHAR_BRACKET {
Uint16 chv;