add flag legacy_bidi in CHARSETOPS structure, and tune unicode_bidi_type operation for legacy BIDI algorithm.

This commit is contained in:
Vincent Wei
2023-07-05 11:59:36 +08:00
parent 695c55e464
commit 50ae4b9b44
4 changed files with 62 additions and 5 deletions
+2 -1
View File
@@ -15,7 +15,7 @@
* 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) 2002~2023, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
@@ -868,6 +868,7 @@ static CHARSETOPS CharsetOps_iso8859_6 = {
3,
FONT_CHARSET_ISO8859_6,
0,
1,
iso8859_6_len_first_char,
iso8859_6_get_char_value,
iso8859_6_get_shaped_char_value,
+31 -2
View File
@@ -15,7 +15,7 @@
* 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) 2002~2023, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
@@ -239,10 +239,36 @@ static const BidiType linear_enum_to_bidi_type[] = {
#undef _UNIBIDI_ADD_TYPE
};
/* Since 5.0.13: this function only returns BidiType which
is recognizable by the legacy BIDI algorithm. */
static BidiType unicode_bidi_char_type(Achar32 ch)
{
ch = REAL_ACHAR(ch);
return linear_enum_to_bidi_type[UNIBIDI_GET_BIDI_TYPE(ch)];
BidiType bt = linear_enum_to_bidi_type[UNIBIDI_GET_BIDI_TYPE(ch)];
switch (bt) {
case BIDI_TYPE_LTR:
case BIDI_TYPE_RTL:
case BIDI_TYPE_AL:
case BIDI_TYPE_EN:
case BIDI_TYPE_AN:
case BIDI_TYPE_ET:
case BIDI_TYPE_CS:
case BIDI_TYPE_NSM:
case BIDI_TYPE_BN:
case BIDI_TYPE_BS:
case BIDI_TYPE_SS:
case BIDI_TYPE_WS:
case BIDI_TYPE_ON:
case BIDI_TYPE_SOT:
case BIDI_TYPE_EOT:
return bt;
default:
_DBG_PRINTF("Not recognizable for char (0x%04x): %u\n", ch, bt);
break;
}
return BIDI_TYPE_WS;
}
BidiType GUIAPI UCharGetBidiType(Uchar32 uc)
@@ -628,6 +654,7 @@ CHARSETOPS __mg_CharsetOps_utf8 = {
6,
FONT_CHARSET_UTF8,
0,
0,
utf8_len_first_char,
utf8_get_char_value,
NULL,
@@ -854,6 +881,7 @@ CHARSETOPS __mg_CharsetOps_utf16le = {
4,
FONT_CHARSET_UTF16LE,
0,
0,
utf16le_len_first_char,
utf16le_get_char_value,
NULL,
@@ -1080,6 +1108,7 @@ CHARSETOPS __mg_CharsetOps_utf16be = {
4,
FONT_CHARSET_UTF16BE,
0,
0,
utf16be_len_first_char,
utf16be_get_char_value,
NULL,
+25 -1
View File
@@ -15,7 +15,7 @@
* 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) 2002~2023, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
@@ -235,6 +235,7 @@ static CHARSETOPS CharsetOps_ascii = {
1,
FONT_CHARSET_US_ASCII,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -298,6 +299,7 @@ static CHARSETOPS CharsetOps_iso8859_1 = {
1,
FONT_CHARSET_ISO8859_1,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -409,6 +411,7 @@ static CHARSETOPS CharsetOps_iso8859_2 = {
1,
FONT_CHARSET_ISO8859_2,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -521,6 +524,7 @@ static CHARSETOPS CharsetOps_iso8859_3 = {
1,
FONT_CHARSET_ISO8859_3,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -634,6 +638,7 @@ static CHARSETOPS CharsetOps_iso8859_4 = {
1,
FONT_CHARSET_ISO8859_4,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -728,6 +733,7 @@ static CHARSETOPS CharsetOps_iso8859_5 = {
1,
FONT_CHARSET_ISO8859_5,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -886,6 +892,7 @@ static CHARSETOPS CharsetOps_iso8859_7 = {
1,
FONT_CHARSET_ISO8859_7,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -1159,6 +1166,7 @@ static CHARSETOPS CharsetOps_iso8859_8 = {
2, // This is a trick for bidi reorder only implemented for MBC.
FONT_CHARSET_ISO8859_8,
0,
1,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -1260,6 +1268,7 @@ static CHARSETOPS CharsetOps_iso8859_9 = {
1,
FONT_CHARSET_ISO8859_9,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -1373,6 +1382,7 @@ static CHARSETOPS CharsetOps_iso8859_10 = {
1,
FONT_CHARSET_ISO8859_10,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -1485,6 +1495,7 @@ static CHARSETOPS CharsetOps_iso8859_11 = {
1,
FONT_CHARSET_ISO8859_11,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -1597,6 +1608,7 @@ static CHARSETOPS CharsetOps_iso8859_13 = {
1,
FONT_CHARSET_ISO8859_13,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -1709,6 +1721,7 @@ static CHARSETOPS CharsetOps_iso8859_14 = {
1,
FONT_CHARSET_ISO8859_14,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -1820,6 +1833,7 @@ static CHARSETOPS CharsetOps_iso8859_15 = {
1,
FONT_CHARSET_ISO8859_15,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -1970,6 +1984,7 @@ static CHARSETOPS CharsetOps_iso8859_16 = {
1,
FONT_CHARSET_ISO8859_16,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -2167,6 +2182,7 @@ static CHARSETOPS CharsetOps_gb2312_0 = {
2,
FONT_CHARSET_GB2312_0,
0,
0,
gb2312_0_len_first_char,
gb2312_0_get_char_value,
NULL,
@@ -2324,6 +2340,7 @@ static CHARSETOPS CharsetOps_gbk = {
2,
FONT_CHARSET_GBK,
0,
0,
gbk_len_first_char,
gbk_get_char_value,
NULL,
@@ -2592,6 +2609,7 @@ static CHARSETOPS CharsetOps_gb18030_0 = {
4,
FONT_CHARSET_GB18030_0,
0,
0,
gb18030_0_len_first_char,
gb18030_0_get_char_value,
NULL,
@@ -2749,6 +2767,7 @@ static CHARSETOPS CharsetOps_big5 = {
2,
FONT_CHARSET_BIG5,
0,
0,
big5_len_first_char,
big5_get_char_value,
NULL,
@@ -2895,6 +2914,7 @@ static CHARSETOPS CharsetOps_ksc5601_0 = {
2,
FONT_CHARSET_EUCKR,
0,
0,
ksc5601_0_len_first_char,
ksc5601_0_get_char_value,
NULL,
@@ -3019,6 +3039,7 @@ static CHARSETOPS CharsetOps_jisx0201_0 = {
1,
FONT_CHARSET_JISX0201_0,
0,
0,
jisx0201_0_len_first_char,
jisx0201_0_get_char_value,
NULL,
@@ -3162,6 +3183,7 @@ static CHARSETOPS CharsetOps_jisx0208_0 = {
2,
FONT_CHARSET_JISX0208_0,
0,
0,
jisx0208_0_len_first_char,
jisx0208_0_get_char_value,
NULL,
@@ -3247,6 +3269,7 @@ static CHARSETOPS CharsetOps_jisx0201_1 = {
1,
FONT_CHARSET_JISX0201_1,
0,
0,
sb_len_first_char,
sb_get_char_value,
NULL,
@@ -3418,6 +3441,7 @@ static CHARSETOPS CharsetOps_jisx0208_1 = {
2,
FONT_CHARSET_JISX0208_1,
0,
0,
jisx0208_1_len_first_char,
jisx0208_1_get_char_value,
NULL,
+4 -1
View File
@@ -15,7 +15,7 @@
* 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) 2002~2023, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
@@ -209,6 +209,9 @@ struct _CHARSETOPS
/** Default character. */
Achar32 def_char_value;
/** Whether use legacy BIDI algorithm (Since 5.0.13). */
unsigned legacy_bidi:1;
/** The method to get the length of the first character. */
int (*len_first_char) (const unsigned char* mstr, int mstrlen);