X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-impl.cpp;h=f64c266441853e69a296e7b86044bd225aa0368c;hp=468ab0c103124b5e82bc790d7854741f237060d7;hb=9598e692217c5fb541d862a3957b3efd5fd5171d;hpb=26cacf71e74fab984c12bc77485920f4573b97ec diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 468ab0c..f64c266 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -38,28 +39,6 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS"); #endif -/** - * @brief Some characters can be shaped in more than one glyph. - * This struct is used to retrieve metrics from these group of glyphs. - */ -struct GlyphMetrics -{ - GlyphMetrics() - : fontHeight( 0.f ), - advance( 0.f ), - ascender( 0.f ), - xBearing( 0.f ) - {} - - ~GlyphMetrics() - {} - - float fontHeight; ///< The font's height of that glyphs. - float advance; ///< The sum of all the advances of all the glyphs. - float ascender; ///< The font's ascender. - float xBearing; ///< The x bearing of the first glyph. -}; - } // namespace namespace Dali @@ -71,41 +50,6 @@ namespace Toolkit namespace Text { -/** - * @brief Get some glyph's metrics of a group of glyphs formed as a result of shaping one character. - * - * @param[in] glyphIndex The index to the first glyph. - * @param[in] numberOfGlyphs The number of glyphs. - * @param[out] glyphMetrics Some glyph metrics (font height, advance, ascender and x bearing). - * @param[in] visualModel The visual model. - * @param[in] metrics Used to access metrics from FontClient. - */ -void GetGlyphsMetrics( GlyphIndex glyphIndex, - Length numberOfGlyphs, - GlyphMetrics& glyphMetrics, - VisualModelPtr& visualModel, - MetricsPtr& metrics ) -{ - const GlyphInfo* glyphsBuffer = visualModel->mGlyphs.Begin(); - - const GlyphInfo& firstGlyph = *( glyphsBuffer + glyphIndex ); - - Text::FontMetrics fontMetrics; - metrics->GetFontMetrics( firstGlyph.fontId, fontMetrics ); - - glyphMetrics.fontHeight = fontMetrics.height; - glyphMetrics.advance = firstGlyph.advance; - glyphMetrics.ascender = fontMetrics.ascender; - glyphMetrics.xBearing = firstGlyph.xBearing; - - for( unsigned int i = 1u; i < numberOfGlyphs; ++i ) - { - const GlyphInfo& glyphInfo = *( glyphsBuffer + glyphIndex + i ); - - glyphMetrics.advance += glyphInfo.advance; - } -} - EventData::EventData( DecoratorPtr decorator ) : mDecorator( decorator ), mImfManager(), @@ -1980,6 +1924,9 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, // Get the glyphs per character table. const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin(); + // Get the glyph's info buffer. + const GlyphInfo* const glyphInfoBuffer = mVisualModel->mGlyphs.Begin(); + // If the vector is void, there is no right to left characters. const bool hasRightToLeftCharacters = NULL != visualToLogicalBuffer; @@ -2018,7 +1965,7 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, GetGlyphsMetrics( firstLogicalGlyphIndex, numberOfGlyphs, glyphMetrics, - mVisualModel, + glyphInfoBuffer, mMetrics ); // Get the position of the first glyph. @@ -2197,6 +2144,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical, const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin(); const CharacterIndex* const glyphsToCharactersBuffer = mVisualModel->mGlyphsToCharacters.Begin(); const Vector2* const glyphPositionsBuffer = mVisualModel->mGlyphPositions.Begin(); + const GlyphInfo* const glyphInfoBuffer = mVisualModel->mGlyphs.Begin(); // Convert the cursor position into the glyph position. const GlyphIndex primaryGlyphIndex = *( charactersToGlyphBuffer + index ); @@ -2208,7 +2156,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical, GetGlyphsMetrics( primaryGlyphIndex, primaryNumberOfGlyphs, glyphMetrics, - mVisualModel, + glyphInfoBuffer, mMetrics ); // Whether to add the glyph's advance to the cursor position. @@ -2298,7 +2246,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical, GetGlyphsMetrics( secondaryGlyphIndex, secondaryNumberOfGlyphs, glyphMetrics, - mVisualModel, + glyphInfoBuffer, mMetrics ); // Set the secondary cursor's position.