New TextUtilities interface. 95/35495/4
authorVictor Cebollada <v.cebollada@samsung.com>
Mon, 16 Feb 2015 14:27:50 +0000 (14:27 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Mon, 16 Feb 2015 16:34:26 +0000 (16:34 +0000)
Change-Id: I9ba573cceece22ff9339eead684027e9f2833096
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
21 files changed:
dali-toolkit/dali-toolkit.h
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/multi-language-support-impl.h
dali-toolkit/public-api/file.list
dali-toolkit/public-api/text/bidirectional-support.cpp
dali-toolkit/public-api/text/bidirectional-support.h
dali-toolkit/public-api/text/line-run.h [new file with mode: 0644]
dali-toolkit/public-api/text/logical-model.cpp
dali-toolkit/public-api/text/logical-model.h
dali-toolkit/public-api/text/multi-language-support.cpp
dali-toolkit/public-api/text/multi-language-support.h
dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.cpp
dali-toolkit/public-api/text/segmentation.cpp
dali-toolkit/public-api/text/segmentation.h
dali-toolkit/public-api/text/shaper.cpp [new file with mode: 0644]
dali-toolkit/public-api/text/shaper.h [new file with mode: 0644]
dali-toolkit/public-api/text/text-controller.cpp
dali-toolkit/public-api/text/text-controller.h
dali-toolkit/public-api/text/text-definitions.h
dali-toolkit/public-api/text/visual-model.cpp
dali-toolkit/public-api/text/visual-model.h

index 350043e..c04d98b 100644 (file)
 #include <dali-toolkit/public-api/text/character-run.h>
 #include <dali-toolkit/public-api/text/character-set-conversion.h>
 #include <dali-toolkit/public-api/text/font-run.h>
+#include <dali-toolkit/public-api/text/line-run.h>
 #include <dali-toolkit/public-api/text/logical-model.h>
 #include <dali-toolkit/public-api/text/multi-language-support.h>
 #include <dali-toolkit/public-api/text/script.h>
+#include <dali-toolkit/public-api/text/script-run.h>
 #include <dali-toolkit/public-api/text/segmentation.h>
+#include <dali-toolkit/public-api/text/shaper.h>
 #include <dali-toolkit/public-api/text/text-controller.h>
 #include <dali-toolkit/public-api/text/text-definitions.h>
 #include <dali-toolkit/public-api/text/text-view.h>
index 4143b03..8e89473 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/public-api/adaptor-framework/singleton-service.h>
+#include <dali/public-api/text-abstraction/font-client.h>
 #include <dali-toolkit/public-api/text/logical-model.h>
 #include <dali-toolkit/public-api/text/font-run.h>
 #include <dali-toolkit/public-api/text/script.h>
 #include <dali-toolkit/public-api/text/script-run.h>
 #include <dali/integration-api/debug.h>
 
+// EXTERNAL INCLUDES
+#include <memory.h>
+
 namespace Dali
 {
 
@@ -179,10 +183,10 @@ Text::MultilanguageSupport MultilanguageSupport::Get()
   return multilanguageSupportHandle;
 }
 
-void MultilanguageSupport::SetScripts( LogicalModel& model )
+void MultilanguageSupport::SetScripts( const Vector<Character>& text,
+                                       Vector<ScriptRun>& 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<Character> 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<ScriptRun> 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<Character>::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<Character>& text,
+                                          const Vector<ScriptRun>& scripts,
+                                          Vector<FontRun>& 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<Character> 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<FontRun> definedFonts = fonts;
+  fonts.Clear();
 
-  // 2) Retrieve any font previously set.
-
-  const Length numberOfFontRuns = model.GetNumberOfFontRuns( 0u, numberOfCharacters );
-
-  Vector<FontRun> 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<ScriptRun> 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<FontRun> 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<FontRun>::ConstIterator fontRunIt = fontRuns.Begin();
-  Vector<FontRun>::ConstIterator fontRunEndIt = fontRuns.End();
-  Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
-  Vector<ScriptRun>::ConstIterator scriptRunEndIt = scriptRuns.End();
+  Vector<FontRun>::ConstIterator fontRunIt = definedFonts.Begin();
+  Vector<FontRun>::ConstIterator fontRunEndIt = definedFonts.End();
+  Vector<ScriptRun>::ConstIterator scriptRunIt = scripts.Begin();
+  Vector<ScriptRun>::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
index f527031..a424cd0 100644 (file)
@@ -93,12 +93,14 @@ public:
   /**
    * @copydoc Dali::MultilanguageSupport::SetScripts()
    */
-  void SetScripts( LogicalModel& model );
-
+  void SetScripts( const Vector<Character>& text,
+                   Vector<ScriptRun>& scripts );
   /**
    * @copydoc Dali::MultilanguageSupport::ValidateFonts()
    */
-  void ValidateFonts( LogicalModel& model );
+  void ValidateFonts( const Vector<Character>& text,
+                      const Vector<ScriptRun>& scripts,
+                      Vector<FontRun>& fonts );
 
 private:
   Vector<FontId>                  mDefaultFontPerScriptCache; ///< Caches the default font for a script.
index b8f75bc..97d37ec 100755 (executable)
@@ -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 \
index d328511..c3b2a52 100644 (file)
@@ -27,12 +27,15 @@ namespace Toolkit
 namespace Text
 {
 
-void SetBidirectionalInfo( LogicalModel& model )
+void SetBidirectionalInfo( const Vector<Character>& text,
+                           const Vector<LineBreakInfo>& lineBreakInfo,
+                           Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo )
 {
 }
 
-void ReorderLines( LogicalModel& logicalModel,
-                   const VisualModel& visualModel )
+void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
+                   const Vector<CharacterRun>& lineRuns,
+                   Vector<BidirectionalLineInfoRun>& lineInfoRuns )
 {
 }
 
index 5cb557e..178c319 100644 (file)
@@ -19,7 +19,9 @@
  */
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/text/text-definitions.h>
+#include <dali/public-api/common/dali-vector.h>
+#include <dali-toolkit/public-api/text/bidirectional-line-info-run.h>
+#include <dali-toolkit/public-api/text/bidirectional-paragraph-info-run.h>
 
 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<Character>& text,
+                           const Vector<LineBreakInfo>& lineBreakInfo,
+                           Vector<BidirectionalParagraphInfoRun>& 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<BidirectionalParagraphInfoRun>& bidirectionalInfo,
+                   const Vector<CharacterRun>& lineRuns,
+                   Vector<BidirectionalLineInfoRun>& 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 (file)
index 0000000..22582d3
--- /dev/null
@@ -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 <dali-toolkit/public-api/text/text-definitions.h>
+
+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__
index db30d05..6d22f3a 100644 (file)
 #include <dali-toolkit/public-api/text/logical-model.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/public-api/text/bidirectional-line-info-run.h>
+#include <dali-toolkit/public-api/text/bidirectional-paragraph-info-run.h>
 #include <dali-toolkit/public-api/text/font-run.h>
 #include <dali-toolkit/public-api/text/script-run.h>
 
 // EXTERNAL INCLUDES
 #include <memory.h>
-#include <stdlib.h>
 
 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<Character>& 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<Character>& 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,
index f573014..059a38b 100644 (file)
  *
  */
 
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/intrusive-ptr.h>
-
 // INTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/common/intrusive-ptr.h>
+#include <dali/public-api/object/ref-object.h>
 #include <dali-toolkit/public-api/text/text-definitions.h>
 
 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:
 
   /**
index 1eb6805..205b39b 100644 (file)
@@ -48,14 +48,20 @@ MultilanguageSupport MultilanguageSupport::Get()
   return Internal::MultilanguageSupport::Get();
 }
 
-void MultilanguageSupport::SetScripts( LogicalModel& model )
+void MultilanguageSupport::SetScripts( const Vector<Character>& text,
+                                       Vector<ScriptRun>& scripts )
 {
-  GetImplementation( *this ).SetScripts( model );
+  GetImplementation( *this ).SetScripts( text,
+                                         scripts );
 }
 
-void MultilanguageSupport::ValidateFonts( LogicalModel& model )
+void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
+                                          const Vector<ScriptRun>& scripts,
+                                          Vector<FontRun>& fonts )
 {
-  GetImplementation( *this ).ValidateFonts( model );
+  GetImplementation( *this ).ValidateFonts( text,
+                                            scripts,
+                                            fonts );
 }
 
 } // namespace Text
index dbd2552..7fb7f58 100644 (file)
  */
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/text/text-definitions.h>
-
-// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/object/base-handle.h>
+#include <dali-toolkit/public-api/text/font-run.h>
+#include <dali-toolkit/public-api/text/script-run.h>
 
 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<Character>& text,
+                   Vector<ScriptRun>& 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<Character>& text,
+                      const Vector<ScriptRun>& scripts,
+                      Vector<FontRun>& fonts );
 };
 
 } // namespace Text
index 702eddb..aecb6d7 100644 (file)
 // CLASS HEADER
 #include <dali-toolkit/public-api/text/rendering/basic/text-basic-renderer.h>
 
-// EXTERNAL INCLUDES
-#include <dali/dali.h>
-
 // INTERNAL INCLUDES
+#include <dali/public-api/text-abstraction/font-client.h>
+#include <dali/public-api/actors/mesh-actor.h>
+#include <dali/public-api/images/atlas.h>
+#include <dali/public-api/geometry/mesh.h>
 #include <dali-toolkit/public-api/text/rendering/shaders/text-basic-shader.h>
 
 using namespace Dali;
index 88455d2..3fa7450 100644 (file)
@@ -27,11 +27,13 @@ namespace Toolkit
 namespace Text
 {
 
-void SetLineBreakInfo( LogicalModel& model )
+void SetLineBreakInfo( const Vector<Character>& text,
+                       Vector<LineBreakInfo>& lineBreakInfo )
 {
 }
 
-void SetWordBreakInfo( LogicalModel& model )
+void SetWordBreakInfo( const Vector<Character>& text,
+                       Vector<WordBreakInfo>& wordBreakInfo )
 {
 }
 
index 85198c5..fa95ff9 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 // INTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
 #include <dali-toolkit/public-api/text/text-definitions.h>
 
 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<Character>& text,
+                       Vector<LineBreakInfo>& 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<Character>& text,
+                       Vector<WordBreakInfo>& 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 (file)
index 0000000..3be21ab
--- /dev/null
@@ -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 <dali-toolkit/public-api/text/shaper.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+void ShapeText( const Vector<Character>& text,
+                const Vector<LineBreakInfo>& lineBreakInfo,
+                const Vector<ScriptRun>& scripts,
+                const Vector<FontRun>& fonts,
+                Vector<GlyphInfo>& glyphs,
+                Vector<CharacterIndex>& characterIndices,
+                Vector<Length>& 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 (file)
index 0000000..3381610
--- /dev/null
@@ -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 <dali/public-api/common/dali-vector.h>
+#include <dali-toolkit/public-api/text/font-run.h>
+#include <dali-toolkit/public-api/text/script-run.h>
+
+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<Character>& text,
+                const Vector<LineBreakInfo>& lineBreakInfo,
+                const Vector<ScriptRun>& scripts,
+                const Vector<FontRun>& fonts,
+                Vector<GlyphInfo>& glyphs,
+                Vector<CharacterIndex>& characterIndices,
+                Vector<Length>& charactersPerGlyph );
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_SHAPER_H__
index a5763d5..6fe0f33 100644 (file)
@@ -25,6 +25,8 @@
 #include <dali-toolkit/public-api/text/character-set-conversion.h>
 #include <dali-toolkit/public-api/text/layouts/layout-engine.h>
 #include <dali-toolkit/public-api/text/logical-model.h>
+#include <dali-toolkit/public-api/text/multi-language-support.h>
+#include <dali-toolkit/public-api/text/script-run.h>
 #include <dali-toolkit/public-api/text/text-view.h>
 #include <dali-toolkit/public-api/text/visual-model.h>
 
@@ -91,9 +93,23 @@ bool Controller::Relayout( const Vector2& size )
     const uint8_t* utf8 = reinterpret_cast<const uint8_t*>( text.c_str() );
 
     Length characterCount = Utf8ToUtf32( utf8, text.size(), &utf32Characters[0] );
+    utf32Characters.Resize( characterCount );
+
+    Vector<ScriptRun> scripts;
+    MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
+
+    multilanguageSupport.SetScripts( utf32Characters,
+                                     scripts );
+
+    Vector<FontRun> 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 );
index 42ef0d6..3155015 100644 (file)
  *
  */
 
-// EXTERNAL INCLUDES
+// INTERNAL INCLUDES
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/object/ref-object.h>
-
-// INTERNAL INCLUDES
 #include <dali-toolkit/public-api/text/text-view.h>
 
+// EXTERNAL INCLUDES
+#include <string>
+
 namespace Dali
 {
 
index bf13293..19caf79 100644 (file)
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/text-abstraction/text-abstraction.h>
+#include <dali/public-api/text-abstraction/text-abstraction-definitions.h>
+#include <dali/public-api/text-abstraction/font-metrics.h>
+#include <dali/public-api/text-abstraction/glyph-info.h>
+#include <dali/public-api/text-abstraction/script.h>
 
 namespace Dali
 {
index a8b0f79..da7bcdf 100644 (file)
 // CLASS HEADER
 #include <dali-toolkit/public-api/text/visual-model.h>
 
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/math/vector2.h>
+
 // EXTERNAL INCLUDES
-#include <string.h>
+#include <memory.h>
 #include <vector>
-#include <dali/public-api/math/vector2.h>
 
 namespace Dali
 {
index 406eb21..d47293d 100644 (file)
  *
  */
 
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/intrusive-ptr.h>
-
 // INTERNAL INCLUDES
+#include <dali/public-api/common/intrusive-ptr.h>
+#include <dali/public-api/object/ref-object.h>
 #include <dali-toolkit/public-api/text/text-definitions.h>
 
 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,