From 2dd044328238768ae8b27a223cb7d0f5cda53513 Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Mon, 16 Feb 2015 14:27:50 +0000 Subject: [PATCH 1/1] New TextUtilities interface. Change-Id: I9ba573cceece22ff9339eead684027e9f2833096 Signed-off-by: Victor Cebollada --- dali-toolkit/dali-toolkit.h | 3 + .../internal/text/multi-language-support-impl.cpp | 105 ++++++--------------- .../internal/text/multi-language-support-impl.h | 8 +- dali-toolkit/public-api/file.list | 3 + .../public-api/text/bidirectional-support.cpp | 9 +- .../public-api/text/bidirectional-support.h | 29 +++--- dali-toolkit/public-api/text/line-run.h | 49 ++++++++++ dali-toolkit/public-api/text/logical-model.cpp | 21 +++-- dali-toolkit/public-api/text/logical-model.h | 22 +++-- .../public-api/text/multi-language-support.cpp | 14 ++- .../public-api/text/multi-language-support.h | 27 +++--- .../text/rendering/basic/text-basic-renderer.cpp | 7 +- dali-toolkit/public-api/text/segmentation.cpp | 6 +- dali-toolkit/public-api/text/segmentation.h | 26 ++--- dali-toolkit/public-api/text/shaper.cpp | 44 +++++++++ dali-toolkit/public-api/text/shaper.h | 60 ++++++++++++ dali-toolkit/public-api/text/text-controller.cpp | 16 ++++ dali-toolkit/public-api/text/text-controller.h | 7 +- dali-toolkit/public-api/text/text-definitions.h | 5 +- dali-toolkit/public-api/text/visual-model.cpp | 7 +- dali-toolkit/public-api/text/visual-model.h | 7 +- 21 files changed, 326 insertions(+), 149 deletions(-) create mode 100644 dali-toolkit/public-api/text/line-run.h create mode 100644 dali-toolkit/public-api/text/shaper.cpp create mode 100644 dali-toolkit/public-api/text/shaper.h diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index 350043e..c04d98b 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -118,10 +118,13 @@ #include #include #include +#include #include #include #include +#include #include +#include #include #include #include diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 4143b03..8e89473 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -20,12 +20,16 @@ // INTERNAL INCLUDES #include +#include #include #include #include #include #include +// EXTERNAL INCLUDES +#include + namespace Dali { @@ -179,10 +183,10 @@ Text::MultilanguageSupport MultilanguageSupport::Get() return multilanguageSupportHandle; } -void MultilanguageSupport::SetScripts( LogicalModel& model ) +void MultilanguageSupport::SetScripts( const Vector& text, + Vector& scripts ) { - // 1) Retrieve the text from the model. - const Length numberOfCharacters = model.GetNumberOfCharacters(); + const Length numberOfCharacters = text.Count(); if( 0u == numberOfCharacters ) { @@ -190,14 +194,7 @@ void MultilanguageSupport::SetScripts( LogicalModel& model ) return; } - Vector text; - text.Resize( numberOfCharacters ); - - model.GetText( 0u, - text.Begin(), - numberOfCharacters ); - - // 2) Traverse all characters and set the scripts. + // Traverse all characters and set the scripts. // Stores the current script run. ScriptRun currentScriptRun; @@ -205,16 +202,12 @@ void MultilanguageSupport::SetScripts( LogicalModel& model ) currentScriptRun.characterRun.numberOfCharacters = 0u; currentScriptRun.script = TextAbstraction::UNKNOWN; - // Temporary stores the script runs. - std::vector scriptRuns; - scriptRuns.reserve( numberOfCharacters << 2u ); // To reduce the number of reallocations. + // Reserve some space to reduce the number of reallocations. + scripts.Reserve( numberOfCharacters << 2u ); - for( Vector::ConstIterator it = text.Begin(), - endIt = text.End(); - it != endIt; - ++it ) + for( Length index = 0u; index < numberOfCharacters; ++index ) { - const Character character = *it; + const Character character = *( text.Begin() + index ); Script script = GetCharacterScript( character ); @@ -231,7 +224,7 @@ void MultilanguageSupport::SetScripts( LogicalModel& model ) if( 0u != currentScriptRun.characterRun.numberOfCharacters ) { // Store the script run. - scriptRuns.push_back( currentScriptRun ); + scripts.PushBack( currentScriptRun ); } // Initialize the new one. @@ -247,19 +240,15 @@ void MultilanguageSupport::SetScripts( LogicalModel& model ) if( 0u != currentScriptRun.characterRun.numberOfCharacters ) { // Store the last run. - scriptRuns.push_back( currentScriptRun ); + scripts.PushBack( currentScriptRun ); } - - // 3) Set the script runs into the model. - - model.SetScripts( &scriptRuns[0u], - scriptRuns.size() ); } -void MultilanguageSupport::ValidateFonts( LogicalModel& model ) +void MultilanguageSupport::ValidateFonts( const Vector& text, + const Vector& scripts, + Vector& fonts ) { - // 1) Retrieve the text from the model. - const Length numberOfCharacters = model.GetNumberOfCharacters(); + const Length numberOfCharacters = text.Count(); if( 0u == numberOfCharacters ) { @@ -267,47 +256,19 @@ void MultilanguageSupport::ValidateFonts( LogicalModel& model ) return; } - Vector text; - text.Resize( numberOfCharacters ); - - Character* textBuffer = text.Begin(); - model.GetText( 0u, - textBuffer, - numberOfCharacters ); + // Copy the fonts set by application developers. + const Length numberOfFontRuns = fonts.Count(); + const Vector definedFonts = fonts; + fonts.Clear(); - // 2) Retrieve any font previously set. - - const Length numberOfFontRuns = model.GetNumberOfFontRuns( 0u, numberOfCharacters ); - - Vector fontRuns; - fontRuns.Reserve( numberOfFontRuns ); - - FontRun* fontRunsBuffer = fontRuns.Begin(); - model.GetFontRuns( fontRunsBuffer, - 0u, - numberOfCharacters ); - - // 3) Retrieve the scripts from the model. - - const Length numberOfScriptRuns = model.GetNumberOfScriptRuns( 0u, numberOfCharacters ); - - Vector scriptRuns; - scriptRuns.Reserve( numberOfScriptRuns ); - - ScriptRun* scriptRunsBuffer = scriptRuns.Begin(); - model.GetScriptRuns( scriptRunsBuffer, - 0u, - numberOfCharacters ); - - // 4) Traverse the characters and validate/set the fonts. + // Traverse the characters and validate/set the fonts. // Get the caches. FontId* defaultFontPerScriptCacheBuffer = mDefaultFontPerScriptCache.Begin(); ValidateFontsPerScript** validFontsPerScriptCacheBuffer = mValidFontsPerScriptCache.Begin(); // Stores the validated font runs. - Vector validatedFontRuns; - validatedFontRuns.Reserve( numberOfFontRuns ); + fonts.Reserve( numberOfFontRuns ); // Initializes a validated font run. FontRun currentFontRun; @@ -320,15 +281,15 @@ void MultilanguageSupport::ValidateFonts( LogicalModel& model ) TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); // Iterators of the font and script runs. - Vector::ConstIterator fontRunIt = fontRuns.Begin(); - Vector::ConstIterator fontRunEndIt = fontRuns.End(); - Vector::ConstIterator scriptRunIt = scriptRuns.Begin(); - Vector::ConstIterator scriptRunEndIt = scriptRuns.End(); + Vector::ConstIterator fontRunIt = definedFonts.Begin(); + Vector::ConstIterator fontRunEndIt = definedFonts.End(); + Vector::ConstIterator scriptRunIt = scripts.Begin(); + Vector::ConstIterator scriptRunEndIt = scripts.End(); for( Length index = 0u; index < numberOfCharacters; ++index ) { // Get the character. - const Character character = *( textBuffer + index ); + const Character character = *( text.Begin() + index ); // Get the font for the character. FontId fontId = GetFontId( index, @@ -437,7 +398,7 @@ void MultilanguageSupport::ValidateFonts( LogicalModel& model ) if( 0u != currentFontRun.characterRun.numberOfCharacters ) { // Store the font run. - validatedFontRuns.PushBack( currentFontRun ); + fonts.PushBack( currentFontRun ); } // Initialize the new one. @@ -454,12 +415,8 @@ void MultilanguageSupport::ValidateFonts( LogicalModel& model ) if( 0u != currentFontRun.characterRun.numberOfCharacters ) { // Store the last run. - validatedFontRuns.PushBack( currentFontRun ); + fonts.PushBack( currentFontRun ); } - - // 5) Sets the validated font runs to the model. - model.SetFonts( validatedFontRuns.Begin(), - validatedFontRuns.Count() ); } } // namespace Internal diff --git a/dali-toolkit/internal/text/multi-language-support-impl.h b/dali-toolkit/internal/text/multi-language-support-impl.h index f527031..a424cd0 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.h +++ b/dali-toolkit/internal/text/multi-language-support-impl.h @@ -93,12 +93,14 @@ public: /** * @copydoc Dali::MultilanguageSupport::SetScripts() */ - void SetScripts( LogicalModel& model ); - + void SetScripts( const Vector& text, + Vector& scripts ); /** * @copydoc Dali::MultilanguageSupport::ValidateFonts() */ - void ValidateFonts( LogicalModel& model ); + void ValidateFonts( const Vector& text, + const Vector& scripts, + Vector& fonts ); private: Vector mDefaultFontPerScriptCache; ///< Caches the default font for a script. diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index b8f75bc..97d37ec 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -98,6 +98,7 @@ public_api_src_files = \ $(public_api_src_dir)/text/multi-language-support.cpp \ $(public_api_src_dir)/text/script.cpp \ $(public_api_src_dir)/text/segmentation.cpp \ + $(public_api_src_dir)/text/shaper.cpp \ $(public_api_src_dir)/text/text-controller.cpp \ $(public_api_src_dir)/text/text-view.cpp \ $(public_api_src_dir)/text/text-view-interface.cpp \ @@ -227,11 +228,13 @@ public_api_text_header_files = \ $(public_api_src_dir)/text/character-run.h \ $(public_api_src_dir)/text/character-set-conversion.h \ $(public_api_src_dir)/text/font-run.h \ + $(public_api_src_dir)/text/line-run.h \ $(public_api_src_dir)/text/logical-model.h \ $(public_api_src_dir)/text/multi-language-support.h \ $(public_api_src_dir)/text/script.h \ $(public_api_src_dir)/text/script-run.h \ $(public_api_src_dir)/text/segmentation.h \ + $(public_api_src_dir)/text/shaper.h \ $(public_api_src_dir)/text/text-controller.h \ $(public_api_src_dir)/text/text-definitions.h \ $(public_api_src_dir)/text/text-view.h \ diff --git a/dali-toolkit/public-api/text/bidirectional-support.cpp b/dali-toolkit/public-api/text/bidirectional-support.cpp index d328511..c3b2a52 100644 --- a/dali-toolkit/public-api/text/bidirectional-support.cpp +++ b/dali-toolkit/public-api/text/bidirectional-support.cpp @@ -27,12 +27,15 @@ namespace Toolkit namespace Text { -void SetBidirectionalInfo( LogicalModel& model ) +void SetBidirectionalInfo( const Vector& text, + const Vector& lineBreakInfo, + Vector& bidirectionalInfo ) { } -void ReorderLines( LogicalModel& logicalModel, - const VisualModel& visualModel ) +void ReorderLines( const Vector& bidirectionalInfo, + const Vector& lineRuns, + Vector& lineInfoRuns ) { } diff --git a/dali-toolkit/public-api/text/bidirectional-support.h b/dali-toolkit/public-api/text/bidirectional-support.h index 5cb557e..178c319 100644 --- a/dali-toolkit/public-api/text/bidirectional-support.h +++ b/dali-toolkit/public-api/text/bidirectional-support.h @@ -19,7 +19,9 @@ */ // INTERNAL INCLUDES -#include +#include +#include +#include namespace Dali { @@ -36,14 +38,13 @@ class VisualModel; /** * Sets the bidirectional info into the logical model. * - * Any bidirectional info previously set is removed. - * - * @pre The @p model needs to have a text set. - * @pre The @p model needs to have the line break info set. - * - * @param[in,out] model The text's logical model. + * @param[in] text Vector of UTF-32 characters. + * @param[in] lineBreakInfo The line break info. + * @param[out] bidirectionalInfo Vector with the bidirectional infor for each paragraph. */ -void SetBidirectionalInfo( LogicalModel& model ); +void SetBidirectionalInfo( const Vector& text, + const Vector& lineBreakInfo, + Vector& bidirectionalInfo ); /** * Sets the visual to logical and logical to visual map tables. @@ -51,14 +52,16 @@ void SetBidirectionalInfo( LogicalModel& model ); * Any map tables previously set are removed. * * @pre The @p logicalModel needs to have a text set. - * @pre The @p logicalModel needs to have the line break info set. + * @pre The @p logicalModel needs to have the bidirectional info indices for each paragraph set. * @pre The @p visualModel needs to have the laid-out lines info set. * - * @param[in,out] logicalModel The text's logical model. - * @param[in] visualModel The text's visual model. + * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph. + * @param[in] lineRuns The line runs converted to characters. + * @param[out] lineInfoRuns line runs with the visual to logical and logical to visual conversion maps. */ -void ReorderLines( LogicalModel& logicalModel, - const VisualModel& visualModel ); +void ReorderLines( const Vector& bidirectionalInfo, + const Vector& lineRuns, + Vector& lineInfoRuns ); } // namespace Text diff --git a/dali-toolkit/public-api/text/line-run.h b/dali-toolkit/public-api/text/line-run.h new file mode 100644 index 0000000..22582d3 --- /dev/null +++ b/dali-toolkit/public-api/text/line-run.h @@ -0,0 +1,49 @@ +#ifndef __DALI_TOOLKIT_TEXT_LINE_RUN_H__ +#define __DALI_TOOLKIT_TEXT_LINE_RUN_H__ + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +/** + * @brief LineRun + */ +struct LineRun +{ + GlyphIndex glyphIndex; ///< The initial glyph index. + Length numberOfGlyphs; ///< The number of characters of the run. + // VCC More info to be added. i.e the size, ... +}; + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // __DALI_TOOLKIT_TEXT_LINE_RUN_H__ diff --git a/dali-toolkit/public-api/text/logical-model.cpp b/dali-toolkit/public-api/text/logical-model.cpp index db30d05..6d22f3a 100644 --- a/dali-toolkit/public-api/text/logical-model.cpp +++ b/dali-toolkit/public-api/text/logical-model.cpp @@ -19,12 +19,13 @@ #include // INTERNAL INCLUDES +#include +#include #include #include // EXTERNAL INCLUDES #include -#include namespace Dali { @@ -47,11 +48,12 @@ LogicalModelPtr LogicalModel::New() return LogicalModelPtr( new LogicalModel() ); } -void LogicalModel::SetText( const Character* text, Length length ) +void LogicalModel::SetText( const Character* const text, + Length numberOfCharacters ) { Vector& modelText = mImpl->mText; - modelText.Resize( length ); - memcpy( &modelText[0], text, length*sizeof(Character) ); + modelText.Resize( numberOfCharacters ); + memcpy( modelText.Begin(), text, numberOfCharacters * sizeof( Character ) ); } Length LogicalModel::GetNumberOfCharacters() const @@ -59,10 +61,17 @@ Length LogicalModel::GetNumberOfCharacters() const return mImpl->mText.Count(); } -void LogicalModel::GetText( CharacterIndex characterIndex, Character* text, Length numberOfCharacters ) const +void LogicalModel::GetText( CharacterIndex characterIndex, + Character* text, + Length numberOfCharacters ) const { Vector& modelText = mImpl->mText; - memcpy( text, &modelText[characterIndex], numberOfCharacters*sizeof(Character) ); + memcpy( text, modelText.Begin() + characterIndex, numberOfCharacters * sizeof( Character ) ); +} + +Character LogicalModel::GetCharacter( CharacterIndex characterIndex ) const +{ + return mImpl->mText[characterIndex]; } void LogicalModel::SetScripts( const ScriptRun* const scripts, diff --git a/dali-toolkit/public-api/text/logical-model.h b/dali-toolkit/public-api/text/logical-model.h index f573014..059a38b 100644 --- a/dali-toolkit/public-api/text/logical-model.h +++ b/dali-toolkit/public-api/text/logical-model.h @@ -18,10 +18,10 @@ * */ -// EXTERNAL INCLUDES -#include - // INTERNAL INCLUDES +#include +#include +#include #include namespace Dali @@ -63,10 +63,10 @@ public: * @brief Replaces any text previously set. * * @param[in] text An array of UTF-32 characters. - * @param[in] length The length of the array. + * @param[in] numberOfCharacters The length of the array. */ - void SetText( const Character* text, - Length length ); + void SetText( const Character* const text, + Length numberOfCharacters ); /** * @brief Retrieves the number of characters of the text. @@ -87,6 +87,15 @@ public: Character* text, Length numberOfCharacters ) const; + /** + * Retrieves a character. + * + * @param[in] characterIndex Index to a character. + * + * @return A character. + */ + Character GetCharacter( CharacterIndex characterIndex ) const; + // Language support interface. /** @@ -395,6 +404,7 @@ public: void GetVisualToLogicalMap( CharacterIndex* visualToLogicalMap, CharacterIndex characterIndex, Length numberOfCharacters ) const; + protected: /** diff --git a/dali-toolkit/public-api/text/multi-language-support.cpp b/dali-toolkit/public-api/text/multi-language-support.cpp index 1eb6805..205b39b 100644 --- a/dali-toolkit/public-api/text/multi-language-support.cpp +++ b/dali-toolkit/public-api/text/multi-language-support.cpp @@ -48,14 +48,20 @@ MultilanguageSupport MultilanguageSupport::Get() return Internal::MultilanguageSupport::Get(); } -void MultilanguageSupport::SetScripts( LogicalModel& model ) +void MultilanguageSupport::SetScripts( const Vector& text, + Vector& scripts ) { - GetImplementation( *this ).SetScripts( model ); + GetImplementation( *this ).SetScripts( text, + scripts ); } -void MultilanguageSupport::ValidateFonts( LogicalModel& model ) +void MultilanguageSupport::ValidateFonts( const Vector& text, + const Vector& scripts, + Vector& fonts ) { - GetImplementation( *this ).ValidateFonts( model ); + GetImplementation( *this ).ValidateFonts( text, + scripts, + fonts ); } } // namespace Text diff --git a/dali-toolkit/public-api/text/multi-language-support.h b/dali-toolkit/public-api/text/multi-language-support.h index dbd2552..7fb7f58 100644 --- a/dali-toolkit/public-api/text/multi-language-support.h +++ b/dali-toolkit/public-api/text/multi-language-support.h @@ -19,10 +19,10 @@ */ // INTERNAL INCLUDES -#include - -// EXTERNAL INCLUDES +#include #include +#include +#include namespace Dali { @@ -78,15 +78,13 @@ public: /** * @brief Sets the scripts of the whole text. * - * Any script info previously set is removed. - * * Scripts are used to validate and set default fonts and to shape the text in further steps. * - * @pre The @p model needs to have a text set. - * - * @param[in,out] model The text's logical model. + * @param[in] text Vector of UTF-32 characters. + * @param[out] scripts Vector containing the script runs for the whole text. */ - void SetScripts( LogicalModel& model ); + void SetScripts( const Vector& text, + Vector& scripts ); /** * @brief Validates the character's font of the whole text. @@ -101,12 +99,13 @@ public: * If a font has been set by the application developer, this method checks if the font supports the character. * If it doesn't, this method replaces it by a default one. * - * @pre The @p model needs to have a text set. - * @pre The @p model needs to have the scripts set. - * - * @param[in,out] model The text's logical model. + * @param[in] text Vector of UTF-32 characters. + * @param[in] scripts Vector containing the script runs for the whole text. + * @param[in,out] fonts Initially contains the fonts set by the application developers. Returns the validated fonts. */ - void ValidateFonts( LogicalModel& model ); + void ValidateFonts( const Vector& text, + const Vector& scripts, + Vector& fonts ); }; } // namespace Text diff --git a/dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.cpp b/dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.cpp index 702eddb..aecb6d7 100644 --- a/dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.cpp +++ b/dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.cpp @@ -18,10 +18,11 @@ // CLASS HEADER #include -// EXTERNAL INCLUDES -#include - // INTERNAL INCLUDES +#include +#include +#include +#include #include using namespace Dali; diff --git a/dali-toolkit/public-api/text/segmentation.cpp b/dali-toolkit/public-api/text/segmentation.cpp index 88455d2..3fa7450 100644 --- a/dali-toolkit/public-api/text/segmentation.cpp +++ b/dali-toolkit/public-api/text/segmentation.cpp @@ -27,11 +27,13 @@ namespace Toolkit namespace Text { -void SetLineBreakInfo( LogicalModel& model ) +void SetLineBreakInfo( const Vector& text, + Vector& lineBreakInfo ) { } -void SetWordBreakInfo( LogicalModel& model ) +void SetWordBreakInfo( const Vector& text, + Vector& wordBreakInfo ) { } diff --git a/dali-toolkit/public-api/text/segmentation.h b/dali-toolkit/public-api/text/segmentation.h index 85198c5..fa95ff9 100644 --- a/dali-toolkit/public-api/text/segmentation.h +++ b/dali-toolkit/public-api/text/segmentation.h @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include namespace Dali @@ -30,29 +31,32 @@ namespace Toolkit namespace Text { -class LogicalModel; - /** * Sets line break info. * - * Any line break info previously set is removed. + * Possible values for LineBreakInfo are: * - * @pre The @p model needs to have a text set. + * - 0 is a LINE_MUST_BREAK. Text must be broken into a new line. + * - 1 is a LINE_ALLOW_BREAK. Is possible to break the text into a new line. + * - 2 is a LINE_NO_BREAK. Text can't be broken into a new line. * - * @param[in,out] model The text's logical model. + * @param[in] text Vector of UTF-32 characters. + * @param[out] lineBreakInfo The line break info */ -void SetLineBreakInfo( LogicalModel& model ); +void SetLineBreakInfo( const Vector& text, + Vector& lineBreakInfo ); /** * Sets word break info. * - * Any word break info previously set is removed. - * - * @pre The @p model needs to have a text set. + * - 0 is a WORD_BREAK. Text can be broken into a new word. + * - 1 is a WORD_NO_BREAK. Text can't be broken into a new word. * - * @param[in,out] model The text's logical model. + * @param[in] text Vector of UTF-32 characters. + * @param[out] wordBreakInfo The word break info. */ -void SetWordBreakInfo( LogicalModel& model ); +void SetWordBreakInfo( const Vector& text, + Vector& wordBreakInfo ); } // namespace Text diff --git a/dali-toolkit/public-api/text/shaper.cpp b/dali-toolkit/public-api/text/shaper.cpp new file mode 100644 index 0000000..3be21ab --- /dev/null +++ b/dali-toolkit/public-api/text/shaper.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +void ShapeText( const Vector& text, + const Vector& lineBreakInfo, + const Vector& scripts, + const Vector& fonts, + Vector& glyphs, + Vector& characterIndices, + Vector& charactersPerGlyph ) +{ +} + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali diff --git a/dali-toolkit/public-api/text/shaper.h b/dali-toolkit/public-api/text/shaper.h new file mode 100644 index 0000000..3381610 --- /dev/null +++ b/dali-toolkit/public-api/text/shaper.h @@ -0,0 +1,60 @@ +#ifndef __DALI_TOOLKIT_TEXT_SHAPER_H__ +#define __DALI_TOOLKIT_TEXT_SHAPER_H__ + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +/** + * Shapes the whole text. + * + * @param[in] text Vector of UTF-32 characters. + * @param[in] lineBreakInfo The line break info. + * @param[in] scripts Vector containing the script runs for the whole text. + * @param[in] fonts Vector with validated fonts. + * @param[out] glyphs Vector of glyphs in the visual order. + * @param[out] characterIndices Vector containing the first character in the logical model that each glyph relates to. + * @param[out] charactersPerGlyph Vector containing the number of characters per glyph. + */ +void ShapeText( const Vector& text, + const Vector& lineBreakInfo, + const Vector& scripts, + const Vector& fonts, + Vector& glyphs, + Vector& characterIndices, + Vector& charactersPerGlyph ); + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // __DALI_TOOLKIT_TEXT_SHAPER_H__ diff --git a/dali-toolkit/public-api/text/text-controller.cpp b/dali-toolkit/public-api/text/text-controller.cpp index a5763d5..6fe0f33 100644 --- a/dali-toolkit/public-api/text/text-controller.cpp +++ b/dali-toolkit/public-api/text/text-controller.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -91,9 +93,23 @@ bool Controller::Relayout( const Vector2& size ) const uint8_t* utf8 = reinterpret_cast( text.c_str() ); Length characterCount = Utf8ToUtf32( utf8, text.size(), &utf32Characters[0] ); + utf32Characters.Resize( characterCount ); + + Vector scripts; + MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get(); + + multilanguageSupport.SetScripts( utf32Characters, + scripts ); + + Vector fonts; + multilanguageSupport.ValidateFonts( utf32Characters, + scripts, + fonts ); // Manipulate the logical model mImpl->mLogicalModel->SetText( &utf32Characters[0], characterCount ); + mImpl->mLogicalModel->SetScripts( &scripts[0], scripts.Count() ); + mImpl->mLogicalModel->SetFonts( &fonts[0], fonts.Count() ); // Update the visual model mImpl->mLayoutEngine.UpdateVisualModel( size, *mImpl->mLogicalModel, *mImpl->mVisualModel ); diff --git a/dali-toolkit/public-api/text/text-controller.h b/dali-toolkit/public-api/text/text-controller.h index 42ef0d6..3155015 100644 --- a/dali-toolkit/public-api/text/text-controller.h +++ b/dali-toolkit/public-api/text/text-controller.h @@ -18,13 +18,14 @@ * */ -// EXTERNAL INCLUDES +// INTERNAL INCLUDES #include #include - -// INTERNAL INCLUDES #include +// EXTERNAL INCLUDES +#include + namespace Dali { diff --git a/dali-toolkit/public-api/text/text-definitions.h b/dali-toolkit/public-api/text/text-definitions.h index bf13293..19caf79 100644 --- a/dali-toolkit/public-api/text/text-definitions.h +++ b/dali-toolkit/public-api/text/text-definitions.h @@ -19,7 +19,10 @@ */ // EXTERNAL INCLUDES -#include +#include +#include +#include +#include namespace Dali { diff --git a/dali-toolkit/public-api/text/visual-model.cpp b/dali-toolkit/public-api/text/visual-model.cpp index a8b0f79..da7bcdf 100644 --- a/dali-toolkit/public-api/text/visual-model.cpp +++ b/dali-toolkit/public-api/text/visual-model.cpp @@ -18,10 +18,13 @@ // CLASS HEADER #include +// INTERNAL INCLUDES +#include +#include + // EXTERNAL INCLUDES -#include +#include #include -#include namespace Dali { diff --git a/dali-toolkit/public-api/text/visual-model.h b/dali-toolkit/public-api/text/visual-model.h index 406eb21..d47293d 100644 --- a/dali-toolkit/public-api/text/visual-model.h +++ b/dali-toolkit/public-api/text/visual-model.h @@ -18,10 +18,9 @@ * */ -// EXTERNAL INCLUDES -#include - // INTERNAL INCLUDES +#include +#include #include namespace Dali @@ -63,7 +62,7 @@ public: * * @param[in] glyphs An array of glyphs in the visual order. * @param[in] characterIndices An array containing the first character in the logical model that each glyph relates to. - * @param[in] charactersPerGlyph An array of containing the number of characters per glyph. + * @param[in] charactersPerGlyph An array containing the number of characters per glyph. * @param[in] numberOfGlyphs The number of glyphs. */ void SetGlyphs( const GlyphInfo* glyphs, -- 2.7.4