fix bug that label word wrap fails for Japanese(#330)
word break error new unicode word break reimplement label word wrap for significant design error
This commit is contained in:
@@ -220,12 +220,14 @@
|
||||
#endif
|
||||
|
||||
#undef _nana_std_has_string_view
|
||||
#undef _nana_std_has_returnable_emplace_back
|
||||
#if ((defined(_MSC_VER) && (_MSC_VER >= 1912) && defined(_MSVC_LANG) && _MSVC_LANG >= 201703)) || \
|
||||
((__cplusplus >= 201703L) && \
|
||||
(defined(__clang__) && (__clang_major__ * 100 + __clang_minor__ >= 400) || \
|
||||
(!defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 701))) \
|
||||
)
|
||||
# define _nana_std_has_string_view
|
||||
# define _nana_std_has_returnable_emplace_back
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Text Token Stream
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include <nana/push_ignore_diagnostic>
|
||||
#include <nana/unicode_bidi.hpp>
|
||||
|
||||
namespace nana{ namespace widgets{ namespace skeletons
|
||||
{
|
||||
@@ -95,10 +96,19 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
return std::stoi(idstr_, nullptr, 0);
|
||||
}
|
||||
private:
|
||||
static bool _m_unicode_word_breakable(wchar_t ch)
|
||||
/*
|
||||
static bool _m_unicode_word_breakable(wchar_t ch) //deprecated
|
||||
{
|
||||
return ((0x4E00 <= ch) && (ch <= 0x9FFF));
|
||||
}
|
||||
*/
|
||||
|
||||
static bool _m_unicode_word_breakable(const wchar_t* ch) noexcept
|
||||
{
|
||||
if (*ch)
|
||||
return unicode_wordbreak(*ch, ch[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Read the data token
|
||||
token _m_token()
|
||||
@@ -112,14 +122,14 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
idstr_.clear();
|
||||
idstr_.append(1, ch);
|
||||
|
||||
if(_m_unicode_word_breakable(ch))
|
||||
if (_m_unicode_word_breakable(iptr_))
|
||||
{
|
||||
++iptr_;
|
||||
return token::data;
|
||||
}
|
||||
|
||||
ch = *++iptr_;
|
||||
while((iptr_ != endptr_) && (ch > 0xFF) && (false == _m_unicode_word_breakable(ch)))
|
||||
while((iptr_ != endptr_) && (ch > 0xFF) && (false == _m_unicode_word_breakable(iptr_)))
|
||||
{
|
||||
idstr_.append(1, ch);
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ namespace nana
|
||||
|
||||
std::vector<unicode_bidi::entity> unicode_reorder(const wchar_t* text, std::size_t length);
|
||||
|
||||
bool unicode_wordbreak(wchar_t left, wchar_t right);
|
||||
|
||||
}
|
||||
#include <nana/pop_ignore_diagnostic>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user