Text segmentation interface added.
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / text / logical-model.h
index f62e6b2..2d8a66a 100644 (file)
@@ -33,8 +33,10 @@ namespace Toolkit
 namespace Text
 {
 
+struct FontRun;
 class LogicalModel;
 typedef IntrusivePtr<LogicalModel> LogicalModelPtr;
+struct ScriptRun;
 
 /**
  * @brief A logical text model contains layout independent information.
@@ -83,6 +85,198 @@ public:
                 Character* text,
                 Length numberOfCharacters ) const;
 
+  // Language support interface.
+
+  /**
+   * Sets the script runs.
+   *
+   * Replaces any scripts previously set.
+   *
+   * A run is a group of consecutive characters. A script run contains the script for a run.
+   *
+   * @param[in] scripts Pointer to a buffer with all the script runs.
+   * @param[in] numberOfRuns The number of script runs.
+   */
+  void SetScripts( const ScriptRun* const scripts,
+                   Length numberOfRuns );
+
+  /**
+   * Retrieves the number of script runs for the given range of characters.
+   *
+   * A run is a group of consecutive characters. A script run contains the script for a run.
+   *
+   * @param[in] characterIndex Index to the first character.
+   * @param[in] numberOfCharacters The number of characters.
+   *
+   * @return The number of script runs.
+   */
+  Length GetNumberOfScriptRuns( CharacterIndex characterIndex,
+                                Length numberOfCharacters ) const;
+
+  /**
+   * Retrieves the script runs for the given range of characters.
+   *
+   * The @p scriptRuns buffer needs to be big enough to copy the number of script runs.
+   * Call GetNumberOfScriptRuns() to retrieve the number of script runs.
+   *
+   * @param[out] scriptRuns Pointer to a buffer where the script runs are copied.
+   * @param[in] characterIndex Index to the first character.
+   * @param[in] numberOfCharacters The number of characters.
+   */
+  void GetScriptRuns( ScriptRun* scriptRuns,
+                      CharacterIndex characterIndex,
+                      Length numberOfCharacters ) const;
+
+  /**
+   * Retrieves the script for the given character index.
+   *
+   * @param[in] characterIndex Index to the character.
+   *
+   * @return The character's script.
+   */
+  Script GetScript( CharacterIndex characterIndex ) const;
+
+  /**
+   * Sets the font runs.
+   *
+   * Replaces any fonts previously set.
+   *
+   * A run is a group of consecutive characters. A font run contains the font id for a run.
+   *
+   * @param[in] fonts Pointer to a buffer with all the font runs.
+   * @param[in] numberOfRuns The number of font runs.
+   */
+  void SetFonts( const FontRun* const fonts,
+                 Length numberOfRuns );
+
+  /**
+   * Retrieves the number of font runs for the given range of characters.
+   *
+   * A run is a group of consecutive characters. A font run contains the font id for a run.
+   *
+   * @param[in] characterIndex Index to the first character.
+   * @param[in] numberOfCharacters The number of characters.
+   *
+   * @return The number of font runs.
+   */
+  Length GetNumberOfFontRuns( CharacterIndex characterIndex,
+                              Length numberOfCharacters ) const;
+
+  /**
+   * Retrieves the font runs for the given range of characters.
+   *
+   * The @p fontRuns buffer needs to be big enough to copy the number of font runs.
+   * Call GetNumberOfFontRuns() to retrieve the number of font runs.
+   *
+   * @param[out] fontRuns Pointer to a buffer where the font runs are copied.
+   * @param[in] characterIndex Index to the first character.
+   * @param[in] numberOfCharacters The number of characters.
+   */
+  void GetFontRuns( FontRun* fontRuns,
+                    CharacterIndex characterIndex,
+                    Length numberOfCharacters ) const;
+
+  /**
+   * Retrieves the font id for the given character index.
+   *
+   * @param[in] characterIndex Index to the first character.
+   *
+   * @return The font id.
+   */
+  FontId GetFont( CharacterIndex characterIndex ) const;
+
+  // Break info interface.
+
+  /**
+   * Sets the line break info.
+   *
+   * See GetLineBreakInfo() to get how the line break info is encoded.
+   *
+   * Replaces any line break info previously set.
+   *
+   * @param[in] lineBreakInfo Pointer to a buffer with the line break info.
+   * @param[in] length The size of the buffer.
+   */
+  void SetLineBreakInfo( const LineBreakInfo* const lineBreakInfo,
+                         Length length );
+
+  /**
+   * Retrieves the line break info in the given buffer.
+   *
+   * The size of the @p lineBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
+   *
+   * Possible values for LineBreakInfo are:
+   *
+   *  - 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.
+   *
+     @verbatim
+     i.e. Hello big\nworld produces:
+          2222212220 22220
+     @endverbatim
+   *
+   * @param[out] lineBreakInfo Pointer to a buffer where the line break info is copied.
+   * @param[in] characterIndex Index to the first line break info item.
+   * @param[in] numberOfItems The number of items to be copied.
+   */
+  void GetLineBreakInfo( LineBreakInfo* lineBreakInfo,
+                         CharacterIndex characterIndex,
+                         Length numberOfItems ) const;
+
+  /**
+   * Retrieves the line break info for the given item index.
+   *
+   * @param[in] characterIndex Index to the line break info item.
+   */
+  LineBreakInfo GetLineBreakInfo( CharacterIndex characterIndex ) const;
+
+  /**
+   * Sets the word break info.
+   *
+   * See GetWordBreakInfo() to get how the word break info is encoded.
+   *
+   * Replaces any word break info previously set.
+   *
+   * @param[in] wordBreakInfo Pointer to a buffer with the word break info.
+   * @param[in] length The size of the buffer.
+   */
+  void SetWordBreakInfo( const WordBreakInfo* const wordBreakInfo,
+                         Length length );
+
+  /**
+   * Retrieves the word break info in the given buffer.
+   *
+   * The size of the @p wordBreakInfo buffer needs to be big enough to copy the @p numberOfItems.
+   *
+   * The size of the buffer has to be big enough to store the whole word break info per character.
+   * Call GetNumberOfCharacters() to get the number of characters.
+   *
+   * Possible values for WordBreakInfo are:
+   *
+   * - 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.
+   *
+     @verbatim
+     i.e. Hello big\nworld produces:
+          1111001100 11110
+     @endverbatim
+   *
+   * @param[out] wordBreakInfo Pointer to a buffer where the word break info is copied.
+   * @param[in] characterIndex Index to the first word break info item.
+   * @param[in] numberOfItems The number of items to be copied.
+   */
+  void GetWordBreakInfo( WordBreakInfo* wordBreakInfo,
+                         CharacterIndex characterIndex,
+                         Length numberOfItems ) const;
+
+  /**
+   * Retrieves the word break info for the given item index.
+   *
+   * @param[in] characterIndex Index to the word break info item.
+   */
+  WordBreakInfo GetWordBreakInfo( CharacterIndex characterIndex ) const;
+
 protected:
 
   /**