Passed BidiCharacterTest

This commit is contained in:
Vincent Wei
2019-03-12 09:03:32 +08:00
parent bdd75353d2
commit 5a5d5d3bbb
2 changed files with 27 additions and 18 deletions
+17 -7
View File
@@ -7595,8 +7595,10 @@ typedef Uint8 BidiArabicProp;
/* Is letter: L, R, AL? */
#define BIDI_IS_LETTER(p) (((p) & BIDI_TYPE_MASK) == BIDI_MASK_LETTER)
/* Is number: EN, AN? */
#define BIDI_IS_NUMBER(p) (((p) & BIDI_TYPE_MASK) == BIDI_MASK_NUMBER)
/* Is number separator or terminator: ES, ET, CS? */
#define BIDI_IS_NUMBER_SEPARATOR_OR_TERMINATOR(p) \
(((p) & BIDI_TYPE_MASK) == BIDI_MASK_NUMSEPTER)
@@ -8006,7 +8008,7 @@ MG_EXPORT int GUIAPI UBidiGetParagraphDir(const BidiType *bidi_types, int len);
* \fn BidiLevel GUIAPI UBidiGetParagraphEmbeddingLevels(
* const BidiType *bidi_types,
* const BidiBracketType* bracket_types, int len,
* int *base_dir, BidiLevel *embedding_levels);
* BidiType *paragraph_dir, BidiLevel *embedding_levels);
* \brief Get bidi embedding levels of a paragraph.
*
* This function finds the bidi embedding levels of a single paragraph,
@@ -8022,9 +8024,17 @@ MG_EXPORT int GUIAPI UBidiGetParagraphDir(const BidiType *bidi_types, int len);
* \param bracket_types The pointer to a Uint8 which contains the
bracket types as returned by UStrGetBracketTypes()
* \param len The length of the list.
* \param base_dir requested and resolved paragraph base direction
* \param paragraph_dir requested and resolved paragraph base direction. You
* can pass the following values for base direction:
* - BIDI_PGDIR_LTR\n
* Explicit left to right.
* - BIDI_PGDIR_RTL\n
* Explicit right to left.
* - BIDI_PGDIR_ON\n
* The base direction will be resolved by applying the
* rules P2 and P3, and returned via this parameter.
* \param embedding_levels The pointer to a buffer which will restore
* the embedding levels
* the embedding levels.
*
* \return The Maximum level found plus one, or zero if any error occurred
* (memory allocation failure most probably).
@@ -8034,7 +8044,7 @@ MG_EXPORT int GUIAPI UBidiGetParagraphDir(const BidiType *bidi_types, int len);
MG_EXPORT BidiLevel GUIAPI UBidiGetParagraphEmbeddingLevels(
const BidiType *bidi_types,
const BidiBracketType* bracket_types, int len,
int *base_dir, BidiLevel *embedding_levels);
BidiType *paragraph_dir, BidiLevel *embedding_levels);
/*
* \var typedef void (*CB_REVERSE_EXTRA) (void* extra, int len, int pos)
@@ -8050,7 +8060,7 @@ typedef void (*CB_REVERSE_EXTRA) (void* extra, int len, int pos);
/**
* \fn BidiLevel GUIAPI UBidiReorderLine(Uint32 bidi_flags,
* const BidiType *bidi_types, int len, int off,
* int base_dir, BidiLevel *embedding_levels,
* BidiType paragraph_dir, BidiLevel *embedding_levels,
* Uchar32 *visual_str, int *map,
* void* extra, CB_REVERSE_EXTRA cb_reverse_extra)
* \brief Reorder a line of logical string to visual string.
@@ -8091,7 +8101,7 @@ typedef void (*CB_REVERSE_EXTRA) (void* extra, int len, int pos);
* contains the bracket types as returned by UStrGetBracketTypes()
* \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 paragraph_dir The resolved paragraph base direction.
* \param embedding_levels The embedding levels, as returned by
UBidiGetParagraphEmbeddingLevels()
* \param visual_str The Uchar32 string will be reordered.
@@ -8108,7 +8118,7 @@ typedef void (*CB_REVERSE_EXTRA) (void* extra, int len, int pos);
*/
MG_EXPORT BidiLevel GUIAPI UBidiReorderLine(Uint32 bidi_flags,
const BidiType *bidi_types, int len, int off,
int base_dir, BidiLevel *embedding_levels,
BidiType paragraph_dir, BidiLevel *embedding_levels,
Uchar32 *visual_str, int *indices_map,
void* extra, CB_REVERSE_EXTRA cb_reverse_extra);
+10 -11
View File
@@ -164,7 +164,7 @@ 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 = BIDI_BRACKET_NONE;
register BidiBracketType bracket_type = BIDI_BRACKET_NONE;
if (bracket_types)
bracket_type = bracket_types[i];
@@ -740,11 +740,11 @@ static void free_pairing_nodes(BidiPairingNode *nodes)
BidiLevel UBidiGetParagraphEmbeddingLevels(const BidiType *bidi_types,
const BidiBracketType *bracket_types, const int len,
int *pbase_dir, BidiLevel *embedding_levels)
BidiType *paragraph_dir, BidiLevel *embedding_levels)
{
BidiLevel base_level_per_iso_level[BIDI_MAX_EXPLICIT_LEVEL];
BidiLevel base_level, max_level = 0;
int base_dir;
BidiType base_dir;
BidiRun *main_run_list = NULL, *explicits_list = NULL, *pp;
BOOL status = FALSE;
int max_iso_level = 0;
@@ -764,8 +764,8 @@ BidiLevel UBidiGetParagraphEmbeddingLevels(const BidiType *bidi_types,
/* Find base level */
/* If no strong base_dir was found, resort to the weak direction
that was passed on input. */
base_level = BIDI_DIR_TO_LEVEL (*pbase_dir);
if (!BIDI_IS_STRONG (*pbase_dir))
base_level = BIDI_DIR_TO_LEVEL (*paragraph_dir);
if (!BIDI_IS_STRONG (*paragraph_dir))
/* P2. P3. Search for first strong character and use its direction as
base direction */
{
@@ -783,12 +783,12 @@ BidiLevel UBidiGetParagraphEmbeddingLevels(const BidiType *bidi_types,
else if (valid_isolate_count==0 && BIDI_IS_LETTER (RL_TYPE (pp)))
{
base_level = BIDI_DIR_TO_LEVEL (RL_TYPE (pp));
*pbase_dir = BIDI_LEVEL_TO_DIR (base_level);
// *paragraph_dir = BIDI_LEVEL_TO_DIR (base_level);
break;
}
}
}
base_dir = BIDI_LEVEL_TO_DIR (base_level);
*paragraph_dir = base_dir = BIDI_LEVEL_TO_DIR (base_level);
_DBG_PRINTF (" base level : %c\n", unibidi_char_from_level (base_level));
_DBG_PRINTF (" base dir : %s\n", unibidi_get_bidi_type_name (base_dir));
@@ -1574,8 +1574,7 @@ out:
}
static void
bidi_string_reverse(Uchar32 *str, int len)
static void bidi_string_reverse(Uchar32 *str, int len)
{
int i;
@@ -1599,7 +1598,7 @@ static void index_array_reverse (int *arr, int len)
BidiLevel UBidiReorderLine(Uint32 flags,
const BidiType *bidi_types, int len, int off,
int base_dir, BidiLevel *embedding_levels,
BidiType paragraph_dir, BidiLevel *embedding_levels,
Uchar32 *visual_str, int *map,
void* extra, CB_REVERSE_EXTRA cb_reverse_extra)
{
@@ -1621,7 +1620,7 @@ BidiLevel UBidiReorderLine(Uint32 flags,
4. any sequence of white space characters at the end of the line. */
for (i = off + len - 1; i >= off &&
BIDI_IS_EXPLICIT_OR_BN_OR_WS (bidi_types[i]); i--)
embedding_levels[i] = BIDI_DIR_TO_LEVEL (base_dir);
embedding_levels[i] = BIDI_DIR_TO_LEVEL (paragraph_dir);
}
/* 7. Reordering resolved levels */