From 4a1603fde877534184868da65ca520ed67d87dc1 Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Mon, 2 Feb 2015 17:35:18 +0000 Subject: [PATCH] Shaping interface methods added. Change-Id: I8ed59eba8e7f6387a53dcfbd19b4a8277957e96a Signed-off-by: Victor Cebollada --- .../text-abstraction/shaping-impl.cpp | 13 ++++ .../internal/text-abstraction/shaping-impl.h | 14 +++++ .../public-api/text-abstraction/shaping.cpp | 17 ++++++ .../public-api/text-abstraction/shaping.h | 60 ++++++++++++++++--- .../text-abstraction-definitions.h | 27 +++++++++ 5 files changed, 123 insertions(+), 8 deletions(-) diff --git a/text/dali/internal/text-abstraction/shaping-impl.cpp b/text/dali/internal/text-abstraction/shaping-impl.cpp index 44f4c2787..fed5d2954 100644 --- a/text/dali/internal/text-abstraction/shaping-impl.cpp +++ b/text/dali/internal/text-abstraction/shaping-impl.cpp @@ -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 diff --git a/text/dali/internal/text-abstraction/shaping-impl.h b/text/dali/internal/text-abstraction/shaping-impl.h index 1e47f03f2..575600f3b 100644 --- a/text/dali/internal/text-abstraction/shaping-impl.h +++ b/text/dali/internal/text-abstraction/shaping-impl.h @@ -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. diff --git a/text/dali/public-api/text-abstraction/shaping.cpp b/text/dali/public-api/text-abstraction/shaping.cpp index 2339adc19..23367972a 100644 --- a/text/dali/public-api/text-abstraction/shaping.cpp +++ b/text/dali/public-api/text-abstraction/shaping.cpp @@ -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 diff --git a/text/dali/public-api/text-abstraction/shaping.h b/text/dali/public-api/text-abstraction/shaping.h index 1562bc16e..3e0570f1b 100644 --- a/text/dali/public-api/text-abstraction/shaping.h +++ b/text/dali/public-api/text-abstraction/shaping.h @@ -17,6 +17,11 @@ * limitations under the License. * */ + +// INTERNAL INCLUDES +#include + +// EXTERNAL INCLUDES #include 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( malloc( numberOfGlyphs * sizeof( GlyphInfo ) ) ); + * CharacterIndex* glyphToCharacterMap = reinterpret_cast( 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 diff --git a/text/dali/public-api/text-abstraction/text-abstraction-definitions.h b/text/dali/public-api/text-abstraction/text-abstraction-definitions.h index b4e48abb7..4f39f6846 100644 --- a/text/dali/public-api/text-abstraction/text-abstraction-definitions.h +++ b/text/dali/public-api/text-abstraction/text-abstraction-definitions.h @@ -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 -- 2.34.1