From fa94cbfac0b89a888a5f0acb893cab9c025a8395 Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Thu, 19 Feb 2015 16:50:46 +0000 Subject: [PATCH] Special characters added to the script. Change-Id: I4db6d47b9a221fc5ca835c81929ecf2272166abc Signed-off-by: Victor Cebollada --- .../internal/text/multi-language-support-impl.cpp | 17 ++++++- dali-toolkit/public-api/text/script.cpp | 44 +++++++++++++++++- dali-toolkit/public-api/text/script.h | 54 ++++++++++++++++++++++ 3 files changed, 111 insertions(+), 4 deletions(-) diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 2d1f5e6..e0053c8 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -213,8 +213,21 @@ void MultilanguageSupport::SetScripts( const Vector& text, if( TextAbstraction::UNKNOWN == script ) { - script = TextAbstraction::LATIN; - DALI_ASSERT_DEBUG( !"MultilanguageSupport::SetScripts. Unkown script!" ); + if( IsZeroWidthNonJoiner( character ) || + IsZeroWidthJoiner( character ) || + IsZeroWidthSpace( character ) || + IsLeftToRightMark( character ) || + IsRightToLeftMark( character ) || + IsThinSpace( character ) ) + { + // Keep previous script if the character is a zero width joiner or a zero width non joiner. + script = currentScriptRun.script; + } + else + { + script = TextAbstraction::LATIN; + DALI_ASSERT_DEBUG( !"MultilanguageSupport::SetScripts. Unkown script!" ); + } } if( script != currentScriptRun.script ) diff --git a/dali-toolkit/public-api/text/script.cpp b/dali-toolkit/public-api/text/script.cpp index 8860a14..5cd8c3f 100644 --- a/dali-toolkit/public-api/text/script.cpp +++ b/dali-toolkit/public-api/text/script.cpp @@ -27,6 +27,16 @@ namespace Toolkit namespace Text { +namespace +{ +const unsigned int CHAR_ZWS = 0x200B; ///< Zero width space. +const unsigned int CHAR_ZWNJ = 0x200C; ///< Zero width non joiner. +const unsigned int CHAR_ZWJ = 0x200D; ///< Zero width joiner. +const unsigned int CHAR_LTRM = 0x200E; ///< Left to Right Mark. +const unsigned int CHAR_RTLM = 0x200F; ///< Right to Left Mark. +const unsigned int CHAR_TS = 0x2009; ///< Thin Space. +} // namespace + Script GetCharacterScript( Character character ) { // Latin script: @@ -107,7 +117,7 @@ Script GetCharacterScript( Character character ) // 0x0e00 - 0x0e7f Thai // Burmese script - // 0x1000 - 0x104f Myanmar + // 0x1000 - 0x109f Myanmar if( character <= 0x0cff ) @@ -201,7 +211,7 @@ Script GetCharacterScript( Character character ) { return TextAbstraction::LAO; } - if( ( 0x1000 <= character ) && ( character <= 0x104f ) ) + if( ( 0x1000 <= character ) && ( character <= 0x109f ) ) { return TextAbstraction::BURMESE; } @@ -364,6 +374,36 @@ Script GetCharacterScript( Character character ) return TextAbstraction::UNKNOWN; } +bool IsZeroWidthNonJoiner( Character character ) +{ + return CHAR_ZWNJ == character; +} + +bool IsZeroWidthJoiner( Character character ) +{ + return CHAR_ZWJ == character; +} + +bool IsZeroWidthSpace( Character character ) +{ + return CHAR_ZWS == character; +} + +bool IsLeftToRightMark( Character character ) +{ + return CHAR_LTRM == character; +} + +bool IsRightToLeftMark( Character character ) +{ + return CHAR_RTLM == character; +} + +bool IsThinSpace( Character character ) +{ + return CHAR_TS == character; +} + } // namespace Text } // namespace Toolkit diff --git a/dali-toolkit/public-api/text/script.h b/dali-toolkit/public-api/text/script.h index 7236778..e3f4c63 100644 --- a/dali-toolkit/public-api/text/script.h +++ b/dali-toolkit/public-api/text/script.h @@ -39,6 +39,60 @@ namespace Text */ Script GetCharacterScript( Character character ); +/** + * @brief Whether the character is a zero width non joiner. + * + * @param[in] character The character. + * + * @return @e true if the character is a zero width non joiner. + */ +bool IsZeroWidthNonJoiner( Character character ); + +/** + * @brief Whether the character is a zero width joiner. + * + * @param[in] character The character. + * + * @return @e true if the character is a zero width joiner. + */ +bool IsZeroWidthJoiner( Character character ); + +/** + * @brief Whether the character is a zero width space. + * + * @param[in] character The character. + * + * @return @e true if the character is a zero width space. + */ +bool IsZeroWidthSpace( Character character ); + +/** + * @brief Whether the character is a left to right mark. + * + * @param[in] character The character. + * + * @return @e true if the character is a left to right mark. + */ +bool IsLeftToRightMark( Character character ); + +/** + * @brief Whether the character is a right to left mark. + * + * @param[in] character The character. + * + * @return @e true if the character is a right to left mark. + */ +bool IsRightToLeftMark( Character character ); + +/** + * @brief Whether the character is a thin space. + * + * @param[in] character The character. + * + * @return @e true if the character is a thin space. + */ +bool IsThinSpace( Character character ); + } // namespace Text } // namespace Toolkit -- 2.7.4