Shaping interface methods added. 89/34789/9
authorVictor Cebollada <v.cebollada@samsung.com>
Mon, 2 Feb 2015 17:35:18 +0000 (17:35 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Wed, 4 Feb 2015 18:11:55 +0000 (18:11 +0000)
Change-Id: I8ed59eba8e7f6387a53dcfbd19b4a8277957e96a
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
text/dali/internal/text-abstraction/shaping-impl.cpp
text/dali/internal/text-abstraction/shaping-impl.h
text/dali/public-api/text-abstraction/shaping.cpp
text/dali/public-api/text-abstraction/shaping.h
text/dali/public-api/text-abstraction/text-abstraction-definitions.h

index 44f4c27..fed5d29 100644 (file)
@@ -66,6 +66,19 @@ TextAbstraction::Shaping Shaping::Get()
   return shapingHandle;
 }
 
+Length Shaping::Shape( const Character* const text,
+                       Length numberOfCharacters,
+                       FontId fontId,
+                       Script script )
+{
+  return 0u;
+}
+
+void Shaping::GetGlyphs( GlyphInfo* glyphInfo,
+                         CharacterIndex* glyphToCharacterMap )
+{
+}
+
 } // namespace Internal
 
 } // namespace TextAbstraction
index 1e47f03..575600f 100644 (file)
@@ -55,6 +55,20 @@ public:
    */
   static TextAbstraction::Shaping Get();
 
+  /**
+   * @copydoc Dali::Shaping::Shape()
+   */
+  Length Shape( const Character* const text,
+                Length numberOfCharacters,
+                FontId fontId,
+                Script script );
+
+  /**
+   * @copydoc Dali::Shaping::GetGlyphs()
+   */
+  void GetGlyphs( GlyphInfo* glyphInfo,
+                  CharacterIndex* glyphToCharacterMap );
+
 private:
 
   // Undefined copy constructor.
index 2339adc..2336797 100644 (file)
@@ -45,6 +45,23 @@ Shaping Shaping::Get()
   return Internal::Shaping::Get();
 }
 
+Length Shaping::Shape( const Character* const text,
+                       Length numberOfCharacters,
+                       FontId fontId,
+                       Script script )
+{
+  return GetImplementation( *this ).Shape( text,
+                                           numberOfCharacters,
+                                           fontId,
+                                           script );
+}
+
+void Shaping::GetGlyphs( GlyphInfo* glyphInfo,
+                         CharacterIndex* glyphToCharacterMap )
+{
+  GetImplementation( *this ).GetGlyphs( glyphInfo,
+                                        glyphToCharacterMap );
+}
 
 } // namespace TextAbstraction
 
index 1562bc1..3e0570f 100644 (file)
  * limitations under the License.
  *
  */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/text-abstraction/text-abstraction.h>
+
+// EXTERNAL INCLUDES
 #include <dali/public-api/object/base-handle.h>
 
 namespace Dali
@@ -32,14 +37,25 @@ class Shaping;
 
 } // Internal
 
-} // TextAbstraction
-
-namespace TextAbstraction
-{
-
 /**
- *   Shaping API
+ * @brief Shaping provides an interface to retrieve glyphs from complex text.
+ *
+ * This module shapes text for a unique font id and script. If the text contains different fonts and scripts
+ * it needs to be split in runs of consecutive characters with the same font id and script.
+ *
+ * @code
+ * Shaping shaping = Shaping::Get();
+ *
+ * // Shapes a number of characters with the given font id and script.
+ * const Length numberOfGlyphs = shaping.Shape( text, numberOfCharacters, fontId, script );
+ *
+ * // Allocate memory to retrieve the glyphs and the character to glyph conversion map.
+ * GlyphInfo* glyphInfo = reinterpret_cast<GlyphInfo*>( malloc( numberOfGlyphs * sizeof( GlyphInfo ) ) );
+ * CharacterIndex* glyphToCharacterMap = reinterpret_cast<CharacterIndex*>( malloc( numberOfGlyphs * sizeof( CharacterIndex ) ) );
  *
+ * // Retrieve the glyphs and the conversion map.
+ * shaping.GetGlyphs( glyphInfo, glyphToCharacterMap );
+ * @endcode
  */
 class DALI_IMPORT_API Shaping : public BaseHandle
 {
@@ -62,9 +78,9 @@ public:
   /**
    * @brief This constructor is used by Shaping::Get().
    *
-   * @param[in] shaping  A pointer to the internal shaping object.
+   * @param[in] implementation A pointer to the internal shaping object.
    */
-  explicit DALI_INTERNAL Shaping( Internal::Shaping* shaping);
+  explicit DALI_INTERNAL Shaping( Internal::Shaping* implementation );
 
   /**
    * @brief Retrieve a handle to the Shaping instance.
@@ -73,6 +89,34 @@ public:
    */
   static Shaping Get();
 
+  /**
+   * Shapes the text.
+   *
+   * Call GetGlyphs() to retrieve the glyphs.
+   *
+   * @param[in] text Pointer to the first character of the text coded in UTF32.
+   * @param[in] numberOfCharacters The number of characters to be shaped
+   * @param[in] fontId The font to be used to shape the text.
+   * @param[in] script The text's script.
+   *
+   * @return The size of the buffer required to get the shaped text.
+   */
+  Length Shape( const Character* const text,
+                Length numberOfCharacters,
+                FontId fontId,
+                Script script );
+
+  /**
+   * Gets the shaped text data.
+   *
+   * @pre @p glyphInfo and @p glyphToCharacterMap must have enough space allocated for the number of glyphs.
+   * Call first Shape() to shape the text and get the number of glyphs.
+   *
+   * @param[out] glyphInfo Vector with indices to the glyph within the font, glyph's metrics and advance.
+   * @param[out] glyphToCharacterMap The glyph to character conversion map.
+   */
+  void GetGlyphs( GlyphInfo* glyphInfo,
+                  CharacterIndex* glyphToCharacterMap );
 };
 
 } // namespace TextAbstraction
index b4e48ab..4f39f68 100644 (file)
@@ -57,6 +57,33 @@ enum
   WORD_NO_BREAK = 1u, ///< Text can't be broken into a new word.
 };
 
+/*
+ * @brief Script is the writing system used by a language.
+ * Typically one script can be used to write different languages although one language could be written in different scrips.
+ */
+enum Script
+{
+  LATIN,      ///< The latin script. Used by many western languages and others around the world.
+  ARABIC,     ///< The arabic script. Used by Arab and Urdu among others.
+  DEVANAGARI, ///< The devanagari script. Used by Hindi, Marathi, Sindhi, Nepali and Sanskrit.
+  BENGALI,    ///< The Bengali script. Used by Bangla, Assamese, Bishnupriya Manipuri, Daphla, Garo, Hallam, Khasi, Mizo, Munda, Naga, Rian, and Santali.
+  GURMUKHI,   ///< The Gurmukhi script. Used by Punjabi.
+  GUJARATI,   ///< The Gujarati script. Used by Gujarati.
+  ORIYA,      ///< The Oriya script. Used by Oriya (Odia), Khondi, and Santali.
+  TAMIL,      ///< The Tamil script. Used by Tamil, Badaga, and Saurashtra.
+  TELUGU,     ///< The Telugu script. Used by Telugu, Gondi, and Lambadi.
+  KANNADA,    ///< The Kannada script. Used by Kannada and Tulu.
+  MALAYALAM,  ///< The Malayalam script. Used by Malayalam.
+  SINHALA,    ///< The Sinhala script. Used by Sinhala and Pali.
+  CJK,        ///< The CJK script. Used by Chinese, Japanese, Korean and Vietnamese(old writing system).
+  HANGUL,     ///< The Hangul jamo script. Used by Korean.
+  KHMER,      ///< The Khmer script. Used by the Khmer language.
+  LAO,        ///< The Lao script. Used by the Lao language.
+  THAI,       ///< The Thai script. Used by the Thai language
+  BURMESE,    ///< The Burmese script. Used by the Burmese (Myanmar) language.
+  UNKNOWN     ///< The script is unknown.
+};
+
 } // namespace TextAbstraction
 
 } // namespace Dali