未验证 提交 d8cad95c 编写于 作者: O openharmony_ci 提交者: Gitee

!825 修复换行异常

Merge pull request !825 from 张兴泰/master
......@@ -21,7 +21,7 @@
#include "font/icu_umutex_stub.h"
#include "rbbidata.h"
#include "ucmndata.h"
#include "utrie2.h"
#include "unicode/ucptrie.h"
using namespace U_ICU_NAMESPACE;
namespace OHOS {
......@@ -57,20 +57,20 @@ uint16_t UILineBreakEngine::GetNextBreakPos(UILineBreakProxy& record)
}
int32_t state = LINE_BREAK_STATE_START;
const RBBIStateTable* rbbStateTable = reinterpret_cast<const RBBIStateTable*>(stateTbl_);
const RBBIStateTableRow16* row =
reinterpret_cast<const RBBIStateTableRow16*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
UTrie2* trie2 = reinterpret_cast<UTrie2*>(lineBreakTrie_);
const RBBIStateTableRow8* row =
reinterpret_cast<const RBBIStateTableRow8*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
UCPTrie* trie = reinterpret_cast<UCPTrie*>(lineBreakTrie_);
for (uint16_t index = 0; index < record.GetStrLen(); ++index) {
uint16_t category = UTRIE2_GET16(trie2, static_cast<uint32_t>(str[index]));
uint16_t category = UCPTRIE_FAST_GET(trie, UCPTRIE_8, str[index]);
// 0x4000: remove the dictionary flag bit
if ((category & 0x4000) != 0) {
// 0x4000: remove the dictionary flag bit
category &= ~0x4000;
}
state = row->fNextState[category];
row = reinterpret_cast<const RBBIStateTableRow16*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
row = reinterpret_cast<const RBBIStateTableRow8*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
int16_t completedRule = row->fAccepting;
if ((completedRule > 0) || (state == LINE_BREAK_STATE_STOP)) {
if ((completedRule > 1) || (state == LINE_BREAK_STATE_STOP)) {
return index;
}
}
......@@ -101,8 +101,8 @@ void UILineBreakEngine::LoadRule()
const RBBIDataHeader* rbbidh = reinterpret_cast<const RBBIDataHeader*>(dataInBytes + dh->dataHeader.headerSize);
stateTbl_ = reinterpret_cast<const RBBIStateTable*>(reinterpret_cast<const char*>(rbbidh) + rbbidh->fFTable);
status = U_ZERO_ERROR;
lineBreakTrie_ = reinterpret_cast<UTrie2*>(
utrie2_openFromSerialized(UTRIE2_16_VALUE_BITS, reinterpret_cast<const uint8_t*>(rbbidh) + rbbidh->fTrie,
lineBreakTrie_ = reinterpret_cast<UCPTrie*>(
ucptrie_openFromBinary(UCPTRIE_TYPE_FAST, UCPTRIE_VALUE_BITS_8, reinterpret_cast<const uint8_t*>(rbbidh) + rbbidh->fTrie,
rbbidh->fTrieLen, nullptr, &status));
if (status != U_ZERO_ERROR) {
return;
......@@ -197,33 +197,33 @@ bool UILineBreakEngine::IsBreakPos(uint32_t unicode, uint16_t fontId, uint8_t fo
return true;
}
const RBBIStateTable* rbbStateTable = reinterpret_cast<const RBBIStateTable*>(stateTbl_);
const RBBIStateTableRow16* row =
reinterpret_cast<const RBBIStateTableRow16*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
const RBBIStateTableRow8* row =
reinterpret_cast<const RBBIStateTableRow8*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
uint16_t utf16 = 0;
if (unicode <= TypedText::MAX_UINT16_LOW_SCOPE) {
utf16 = (unicode & TypedText::MAX_UINT16_LOW_SCOPE);
} else if (unicode <= TypedText::MAX_UINT16_HIGH_SCOPE) {
utf16 = static_cast<uint16_t>(TypedText::UTF16_LOW_PARAM + (unicode & TypedText::UTF16_LOW_MASK)); // low
uint16_t category = UTRIE2_GET16(reinterpret_cast<UTrie2*>(lineBreakTrie_), static_cast<uint32_t>(utf16));
uint16_t category = UCPTRIE_FAST_GET(reinterpret_cast<UCPTrie*>(lineBreakTrie_), UCPTRIE_8, utf16);
// 0x4000: remove the dictionary flag bit
if ((category & 0x4000) != 0) {
// 0x4000: remove the dictionary flag bit
category &= ~0x4000;
}
state = row->fNextState[category];
row = reinterpret_cast<const RBBIStateTableRow16*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
row = reinterpret_cast<const RBBIStateTableRow8*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
utf16 = static_cast<uint16_t>(TypedText::UTF16_HIGH_PARAM1 + (unicode >> TypedText::UTF16_HIGH_SHIFT) -
TypedText::UTF16_HIGH_PARAM2); // high
}
uint16_t category = UTRIE2_GET16(reinterpret_cast<UTrie2*>(lineBreakTrie_), static_cast<uint32_t>(utf16));
uint16_t category = UCPTRIE_FAST_GET(reinterpret_cast<UCPTrie*>(lineBreakTrie_), UCPTRIE_8, utf16);
// 0x4000: remove the dictionary flag bit
if ((category & 0x4000) != 0) {
// 0x4000: remove the dictionary flag bit
category &= ~0x4000;
}
state = row->fNextState[category];
row = reinterpret_cast<const RBBIStateTableRow16*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
return (row->fAccepting > 0 || state == LINE_BREAK_STATE_STOP);
row = reinterpret_cast<const RBBIStateTableRow8*>(rbbStateTable->fTableData + rbbStateTable->fRowLen * state);
return (row->fAccepting > 1 || state == LINE_BREAK_STATE_STOP);
}
} // namespace OHOS
#endif // ENABLE_ICU
......@@ -29,7 +29,7 @@ SOURCES += \
../../../../../../../../third_party/icu/icu4c/source/common/uinvchar.cpp \
../../../../../../../../third_party/icu/icu4c/source/common/ustring.cpp \
../../../../../../../../third_party/icu/icu4c/source/common/utf_impl.cpp \
../../../../../../../../third_party/icu/icu4c/source/common/utrie2.cpp
../../../../../../../../third_party/icu/icu4c/source/common/ucptrie.cpp
INCLUDEPATH += \
../../../../../../../../third_party/icu/icu4c/source/common
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册