* When there are no characters, the line height of the default
font is used to align the text.
Change-Id: I3f7506bac0fe4afd6ccd3fb88e80e449d1e73af7
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
+float Controller::Impl::GetDefaultFontLineHeight()
+{
+ FontId defaultFontId = 0u;
+ if( NULL == mFontDefaults )
+ {
+ defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
+ EMPTY_STRING );
+ }
+ else
+ {
+ defaultFontId = mFontDefaults->GetFontId( mFontClient );
+ }
+
+ Text::FontMetrics fontMetrics;
+ mFontClient.GetFontMetrics( defaultFontId, fontMetrics );
+
+ return( fontMetrics.ascender - fontMetrics.descender );
+}
+
void Controller::Impl::OnCursorKeyEvent( const Event& event )
{
if( NULL == mEventData )
void Controller::Impl::OnCursorKeyEvent( const Event& event )
{
if( NULL == mEventData )
if( isFirstPosition && isLastPosition )
{
if( isFirstPosition && isLastPosition )
{
- // There is zero characters. Get the default font.
-
- FontId defaultFontId = 0u;
- if( NULL == mFontDefaults )
- {
- defaultFontId = mFontClient.GetFontId( EMPTY_STRING,
- EMPTY_STRING );
- }
- else
- {
- defaultFontId = mFontDefaults->GetFontId( mFontClient );
- }
-
- Text::FontMetrics fontMetrics;
- mFontClient.GetFontMetrics( defaultFontId, fontMetrics );
-
- cursorInfo.lineHeight = fontMetrics.ascender - fontMetrics.descender;
+ // There is zero characters. Get the default font's line height.
+ cursorInfo.lineHeight = GetDefaultFontLineHeight();
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
cursorInfo.primaryPosition.x = 1.f;
cursorInfo.primaryCursorHeight = cursorInfo.lineHeight;
cursorInfo.primaryPosition.x = 1.f;
*/
void GetDefaultFonts( Dali::Vector<FontRun>& fonts, Length numberOfCharacters );
*/
void GetDefaultFonts( Dali::Vector<FontRun>& fonts, Length numberOfCharacters );
+ /**
+ * @brief Retrieve the line height of the default font.
+ */
+ float GetDefaultFontLineHeight();
+
void OnCursorKeyEvent( const Event& event );
void OnTapEvent( const Event& event );
void OnCursorKeyEvent( const Event& event );
void OnTapEvent( const Event& event );
// Get the direction of the first character.
const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
// Get the direction of the first character.
const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u );
- const Size& actualSize = mImpl->mVisualModel->GetActualSize();
+ Size actualSize = mImpl->mVisualModel->GetActualSize();
+ if( fabsf( actualSize.height ) < Math::MACHINE_EPSILON_1000 )
+ {
+ // Get the line height of the default font.
+ actualSize.height = mImpl->GetDefaultFontLineHeight();
+ }
// If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();
// If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END;
LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment();