From: Adeel Kazmi Date: Fri, 28 Aug 2015 11:51:01 +0000 (-0700) Subject: Merge "Fixes some alignment issues." into devel/master X-Git-Tag: dali_1.1.2~16 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=766fdcbec7da7e0bcdc4964c56211b195b257c16;hp=0ba2c873ec2b627f3dd130761c14cc30c32554da Merge "Fixes some alignment issues." into devel/master --- diff --git a/dali-toolkit/devel-api/styling/style-manager.cpp b/dali-toolkit/devel-api/styling/style-manager.cpp index b3a0028..19e2f1f 100644 --- a/dali-toolkit/devel-api/styling/style-manager.cpp +++ b/dali-toolkit/devel-api/styling/style-manager.cpp @@ -58,6 +58,11 @@ void StyleManager::SetOrientation( Orientation orientation ) GetImpl(*this).SetOrientation( orientation ); } +std::string StyleManager::GetDefaultFontFamily() const +{ + return GetImpl(*this).GetDefaultFontFamily(); +} + Orientation StyleManager::GetOrientation() { return GetImpl(*this).GetOrientation(); diff --git a/dali-toolkit/devel-api/styling/style-manager.h b/dali-toolkit/devel-api/styling/style-manager.h index a568bba..a1596e1 100644 --- a/dali-toolkit/devel-api/styling/style-manager.h +++ b/dali-toolkit/devel-api/styling/style-manager.h @@ -115,6 +115,12 @@ public: Orientation GetOrientation(); /** + * @brief Retrieves the default font family. + * @return The default font family. + */ + std::string GetDefaultFontFamily() const; + + /** * @brief Make a request to set the theme JSON file to one that exists in the Toolkit package. * * Multiple requests per event processing cycle can be made, but only the final one will be acted diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index d633e9b..eb12543 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -149,6 +149,9 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr { Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n"); + + if( textField ) { TextField& impl( GetImpl( textField ) ); @@ -210,7 +213,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mController->GetDefaultFontFamily() != fontFamily ) { - impl.mController->SetDefaultFontFamily( fontFamily ); + impl.mController->SetDefaultFontFamily( fontFamily, true ); // "true" as SetProperty means user defined font so don't change when system font changes. } } break; @@ -234,7 +237,7 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mController ) { const float pointSize = value.Get< float >(); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p FONT_STYLE %f\n", impl.mController.Get(), pointSize ); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p POINT_SIZE %f\n", impl.mController.Get(), pointSize ); if( !Equals( impl.mController->GetDefaultPointSize(), pointSize ) ) { @@ -929,12 +932,10 @@ void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange:: { case StyleChange::DEFAULT_FONT_CHANGE: { - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE\n"); - if ( mController->GetDefaultFontFamily() == "" ) - { - // Property system did not set the font so should update it. - // todo instruct text-controller to update model - } + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n"); + std::string newFont = styleManager.GetDefaultFontFamily(); + // Property system did not set the font so should update it. + mController->UpdateAfterFontChange( newFont ); break; } @@ -969,6 +970,8 @@ float TextField::GetHeightForWidth( float width ) void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container ) { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n"); + if( mController->Relayout( size ) || !mRenderer ) { @@ -1130,7 +1133,15 @@ void TextField::OnPan( const PanGesture& gesture ) void TextField::OnLongPress( const LongPressGesture& gesture ) { + // Show the keyboard if it was hidden. + if (!VirtualKeyboard::IsVisible()) + { + VirtualKeyboard::Show(); + } + mController->LongPressEvent( gesture.state, gesture.localPoint.x, gesture.localPoint.y ); + + SetKeyInputFocus(); } bool TextField::OnKeyEvent( const KeyEvent& event ) diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 81a5c97..ce08f89 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -151,7 +151,7 @@ void TextLabel::SetProperty( BaseObject* object, Property::Index index, const Pr if( impl.mController->GetDefaultFontFamily() != fontFamily ) { - impl.mController->SetDefaultFontFamily( fontFamily ); + impl.mController->SetDefaultFontFamily( fontFamily, true ); } } break; diff --git a/dali-toolkit/internal/styling/style-manager-impl.cpp b/dali-toolkit/internal/styling/style-manager-impl.cpp index 08d61fd..41f20e3 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.cpp +++ b/dali-toolkit/internal/styling/style-manager-impl.cpp @@ -100,6 +100,7 @@ Toolkit::StyleManager StyleManager::Get() StyleManager::StyleManager() : mOrientationDegrees( 0 ), // Portrait mDefaultFontSize( -1 ), + mDefaultFontFamily(""), mThemeFile( DEFAULT_THEME ), mFeedbackStyle( NULL ) { @@ -155,6 +156,11 @@ void StyleManager::SetOrientation( Orientation orientation ) } } +std::string StyleManager::GetDefaultFontFamily() const +{ + return mDefaultFontFamily; +} + Orientation StyleManager::GetOrientation() { return mOrientation; @@ -417,6 +423,7 @@ void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange::T { case StyleChange::DEFAULT_FONT_CHANGE: { + mDefaultFontFamily = styleMonitor.GetDefaultFontFamily(); break; } diff --git a/dali-toolkit/internal/styling/style-manager-impl.h b/dali-toolkit/internal/styling/style-manager-impl.h index 86c6d4c..ab5e24d 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.h +++ b/dali-toolkit/internal/styling/style-manager-impl.h @@ -81,6 +81,11 @@ public: Orientation GetOrientation(); /** + * @copydoc Toolkit::StyleManager::GetDefaultFontFamily + */ + std::string GetDefaultFontFamily() const; + + /** * @copydoc Toolkit::StyleManager::SetStyleConstant */ void SetStyleConstant( const std::string& key, const Property::Value& value ); @@ -254,6 +259,8 @@ private: int mDefaultFontSize; ///< Logical size, not a point-size + std::string mDefaultFontFamily; + std::string mThemeFile; ///< The full path of the current theme file Property::Map mThemeBuilderConstants; ///< Contants to give the theme builder diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index 5ee4992..9062b07 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -105,7 +105,6 @@ struct LayoutEngine::Impl mCursorWidth( CURSOR_WIDTH ), mEllipsisEnabled( false ) { - mFontClient = TextAbstraction::FontClient::Get(); } /** @@ -117,7 +116,7 @@ struct LayoutEngine::Impl void UpdateLineHeight( FontId fontId, LineLayout& lineLayout ) { Text::FontMetrics fontMetrics; - mFontClient.GetFontMetrics( fontId, fontMetrics ); + mMetrics->GetFontMetrics( fontId, fontMetrics ); // Sets the maximum ascender. if( fontMetrics.ascender > lineLayout.ascender ) @@ -634,7 +633,7 @@ struct LayoutEngine::Impl const GlyphInfo& glyphInfo = *( layoutParameters.glyphsBuffer + layoutParameters.totalNumberOfGlyphs - 1u ); Text::FontMetrics fontMetrics; - mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics ); + mMetrics->GetFontMetrics( glyphInfo.fontId, fontMetrics ); LineRun lineRun; lineRun.glyphRun.glyphIndex = 0u; @@ -821,7 +820,7 @@ struct LayoutEngine::Impl LayoutEngine::VerticalAlignment mVerticalAlignment; float mCursorWidth; - TextAbstraction::FontClient mFontClient; + IntrusivePtr mMetrics; bool mEllipsisEnabled:1; }; @@ -837,6 +836,11 @@ LayoutEngine::~LayoutEngine() delete mImpl; } +void LayoutEngine::SetMetrics( MetricsPtr& metrics ) +{ + mImpl->mMetrics = metrics; +} + void LayoutEngine::SetLayout( Layout layout ) { mImpl->mLayout = layout; diff --git a/dali-toolkit/internal/text/layouts/layout-engine.h b/dali-toolkit/internal/text/layouts/layout-engine.h index d0f1ab6..f866f3e 100644 --- a/dali-toolkit/internal/text/layouts/layout-engine.h +++ b/dali-toolkit/internal/text/layouts/layout-engine.h @@ -24,6 +24,7 @@ // INTERNAL INCLUDE #include +#include namespace Dali { @@ -74,6 +75,13 @@ public: ~LayoutEngine(); /** + * @brief Provide the wrapper around FontClient used to get metrics + * + * @param[in] metrics Used to get metrics + */ + void SetMetrics( MetricsPtr& metrics ); + + /** * @brief Choose the required layout. * * @param[in] layout The required layout. diff --git a/dali-toolkit/internal/text/metrics.h b/dali-toolkit/internal/text/metrics.h new file mode 100644 index 0000000..147ae79 --- /dev/null +++ b/dali-toolkit/internal/text/metrics.h @@ -0,0 +1,134 @@ +#ifndef __DALI_TOOLKIT_TEXT_METRICS_H__ +#define __DALI_TOOLKIT_TEXT_METRICS_H__ + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace Text +{ + +class Metrics; +typedef IntrusivePtr MetricsPtr; + +/** + * @brief A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics. + */ +class Metrics : public RefObject +{ +public: + + /** + * Create a new Metrics object + */ + static Metrics* New( TextAbstraction::FontClient& fontClient ) + { + return new Metrics( fontClient ); + } + + /** + * @brief Set the maximum Emoji size. + * + * @param[in] emojiSize Emoticons will be scaled to fit this size in pixels. + */ + void SetMaxEmojiSize( int emojiSize ) + { + mEmojiSize = emojiSize; + } + + /** + * @brief Get the maximum Emoji size. + * + * @return The maximum Emoji size. + */ + int GetMaxEmojiSize() const + { + return mEmojiSize; + } + + /** + * @brief Query the metrics for a font. + * + * @param[in] fontId The ID of the font for the required glyph. + * @param[out] metrics The font metrics. + */ + void GetFontMetrics( FontId fontId, FontMetrics& metrics ) + { + mFontClient.GetFontMetrics( fontId, metrics, mEmojiSize ); // inline for performance + } + + /** + * @brief Retrieve the metrics for a series of glyphs. + * + * @param[in,out] array An array of glyph-info structures with initialized FontId & GlyphIndex values. + * It may contain the advance and an offset set into the bearing from the shaping tool. + * On return, the glyph's size value will be initialized. The bearing value will be updated by adding the font's glyph bearing to the one set by the shaping tool. + * @param[in] size The size of the array. + * @return True if all of the requested metrics were found. + */ + bool GetGlyphMetrics( GlyphInfo* array, uint32_t size ) + { + return mFontClient.GetGlyphMetrics( array, size, true, mEmojiSize ); // inline for performance + } + +protected: + + /** + * A reference counted object may only be deleted by calling Unreference() + */ + virtual ~Metrics() {} + +private: + + /** + * Constructor. + */ + Metrics( TextAbstraction::FontClient& fontClient ) + : mFontClient( fontClient ), + mEmojiSize( 0 ) + { + } + + // Undefined + Metrics(const Metrics&); + + // Undefined + Metrics& operator=(const Metrics& rhs); + +private: + + TextAbstraction::FontClient mFontClient; + + int mEmojiSize; +}; + +} // namespace Text + +} // namespace Toolkit + +} // namespace Dali + +#endif // __DALI_TOOLKIT_TEXT_METRICS_H__ diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index d730c9e..bb33981 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -363,7 +363,7 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, // Copy the fonts set by application developers. const Length numberOfFontRuns = fonts.Count(); - const Vector definedFonts = fonts; + const Vector userSetFonts = fonts; fonts.Clear(); // Traverse the characters and validate/set the fonts. @@ -386,8 +386,8 @@ void MultilanguageSupport::ValidateFonts( const Vector& text, TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); // Iterators of the font and script runs. - Vector::ConstIterator fontRunIt = definedFonts.Begin(); - Vector::ConstIterator fontRunEndIt = definedFonts.End(); + Vector::ConstIterator fontRunIt = userSetFonts.Begin(); + Vector::ConstIterator fontRunEndIt = userSetFonts.End(); Vector::ConstIterator scriptRunIt = scripts.Begin(); Vector::ConstIterator scriptRunEndIt = scripts.End(); diff --git a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp index a4fc1d8..026b4d6 100644 --- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp @@ -331,6 +331,16 @@ struct AtlasRenderer::Impl : public ConnectionTracker textCacheEntry.mIndex = glyph.index; newTextCache.PushBack( textCacheEntry ); + // Adjust the vertices if the fixed-size font should be down-scaled + if( glyph.scaleFactor > 0 ) + { + for( unsigned int i=0; imGlyphs.Begin(); const GlyphInfo& firstGlyph = *( glyphsBuffer + glyphIndex ); Text::FontMetrics fontMetrics; - fontClient.GetFontMetrics( firstGlyph.fontId, fontMetrics ); + metrics->GetFontMetrics( firstGlyph.fontId, fontMetrics ); glyphMetrics.fontHeight = fontMetrics.height; glyphMetrics.advance = firstGlyph.advance; @@ -423,7 +423,7 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired ) if( GET_GLYPH_METRICS & operations ) { GlyphInfo* glyphsBuffer = glyphs.Begin(); - mFontClient.GetGlyphMetrics( glyphsBuffer, numberOfGlyphs ); + mMetrics->GetGlyphMetrics( glyphsBuffer, numberOfGlyphs ); // Update the width and advance of all new paragraph characters. for( Vector::ConstIterator it = newParagraphGlyphs.Begin(), endIt = newParagraphGlyphs.End(); it != endIt; ++it ) @@ -487,7 +487,7 @@ float Controller::Impl::GetDefaultFontLineHeight() } Text::FontMetrics fontMetrics; - mFontClient.GetFontMetrics( defaultFontId, fontMetrics ); + mMetrics->GetFontMetrics( defaultFontId, fontMetrics ); return( fontMetrics.ascender - fontMetrics.descender ); } @@ -1462,7 +1462,7 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX, numberOfGlyphs, glyphMetrics, mVisualModel, - mFontClient ); + mMetrics ); const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex ); @@ -1601,7 +1601,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical, primaryNumberOfGlyphs, glyphMetrics, mVisualModel, - mFontClient ); + mMetrics ); // Whether to add the glyph's advance to the cursor position. // i.e if the paragraph is left to right and the logical cursor is zero, the position is the position of the first glyph and the advance is not added, @@ -1691,7 +1691,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical, secondaryNumberOfGlyphs, glyphMetrics, mVisualModel, - mFontClient ); + mMetrics ); // Set the secondary cursor's position. cursorInfo.secondaryPosition.x = -glyphMetrics.xBearing + secondaryPosition.x + ( isCurrentRightToLeft ? 0.f : glyphMetrics.advance ); @@ -1777,7 +1777,7 @@ void Controller::Impl::UpdateCursorPosition() } Text::FontMetrics fontMetrics; - mFontClient.GetFontMetrics( defaultFontId, fontMetrics ); + mMetrics->GetFontMetrics( defaultFontId, fontMetrics ); lineHeight = fontMetrics.ascender - fontMetrics.descender; diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 3073611..e60fe37 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES #include @@ -174,7 +175,9 @@ struct ModifyEvent struct FontDefaults { FontDefaults() - : mDefaultPointSize(0.0f), + : mDefaultFontFamily(""), + mDefaultFontStyle(""), + mDefaultPointSize(0.0f), mFontId(0u) { } @@ -207,13 +210,15 @@ struct Controller::Impl mFontClient(), mClipboard(), mView(), + mMetrics(), mLayoutEngine(), mModifyEvents(), mTextColor( Color::BLACK ), mAlignmentOffset(), mOperationsPending( NO_OPERATION ), mMaximumNumberOfCharacters( 50 ), - mRecalculateNaturalSize( true ) + mRecalculateNaturalSize( true ), + mUserDefinedFontFamily( false) { mLogicalModel = LogicalModel::New(); mVisualModel = VisualModel::New(); @@ -223,6 +228,10 @@ struct Controller::Impl mView.SetVisualModel( mVisualModel ); + // Use this to access FontClient i.e. to get down-scaled Emoji metrics. + mMetrics = Metrics::New( mFontClient ); + mLayoutEngine.SetMetrics( mMetrics ); + // Set the text properties to default mVisualModel->SetUnderlineEnabled( false ); mVisualModel->SetUnderlineHeight( 0.0f ); @@ -468,15 +477,18 @@ struct Controller::Impl FontDefaults* mFontDefaults; ///< Avoid allocating this when the user does not specify a font. EventData* mEventData; ///< Avoid allocating everything for text input until EnableTextInput(). TextAbstraction::FontClient mFontClient; ///< Handle to the font client. - Clipboard mClipboard; ///< Handle to the system clipboard + Clipboard mClipboard; ///< Handle to the system clipboard View mView; ///< The view interface to the rendering back-end. + MetricsPtr mMetrics; ///< A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics. LayoutEngine mLayoutEngine; ///< The layout engine. std::vector mModifyEvents; ///< Temporary stores the text set until the next relayout. Vector4 mTextColor; ///< The regular text color Vector2 mAlignmentOffset; ///< Vertical and horizontal offset of the whole text inside the control due to alignment. OperationsMask mOperationsPending; ///< Operations pending to be done to layout the text. Length mMaximumNumberOfCharacters; ///< Maximum number of characters that can be inserted. + bool mRecalculateNaturalSize:1; ///< Whether the natural size needs to be recalculated. + bool mUserDefinedFontFamily:1; ///< Whether the Font family was Set by the user instead of being left as sytem default }; } // namespace Text diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index ccc60fa..47afc96 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -38,6 +38,7 @@ namespace #endif const float MAX_FLOAT = std::numeric_limits::max(); +const unsigned int POINTS_PER_INCH = 72; const std::string EMPTY_STRING(""); @@ -73,6 +74,8 @@ void Controller::EnableTextInput( DecoratorPtr decorator ) void Controller::SetText( const std::string& text ) { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText\n" ); + // Remove the previously set text ResetText(); @@ -222,7 +225,7 @@ int Controller::GetMaximumNumberOfCharacters() return mImpl->mMaximumNumberOfCharacters; } -void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily ) +void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined ) { if( !mImpl->mFontDefaults ) { @@ -230,7 +233,7 @@ void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily ) } mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily; - + mImpl->mUserDefinedFontFamily = userDefined; // Clear the font-specific data ClearFontData(); @@ -287,6 +290,15 @@ void Controller::SetDefaultPointSize( float pointSize ) mImpl->mFontDefaults->mDefaultPointSize = pointSize; + unsigned int horizontalDpi( 0u ); + unsigned int verticalDpi( 0u ); + mImpl->mFontClient.GetDpi( horizontalDpi, verticalDpi ); + + // Adjust the metrics if the fixed-size font should be down-scaled + int maxEmojiSize( pointSize/POINTS_PER_INCH * verticalDpi ); + DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultPointSize %p setting MaxEmojiSize %d\n", this, maxEmojiSize ); + mImpl->mMetrics->SetMaxEmojiSize( maxEmojiSize ); + // Clear the font-specific data ClearFontData(); @@ -306,6 +318,23 @@ float Controller::GetDefaultPointSize() const return 0.0f; } +void Controller::UpdateAfterFontChange( std::string& newDefaultFont ) +{ + DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange"); + + ClearFontData(); + + if ( !mImpl->mUserDefinedFontFamily ) // If user defined font then should not update when system font changes + { + DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() ); + mImpl->mFontDefaults->mDefaultFontFamily=newDefaultFont; + mImpl->UpdateModel( ALL_OPERATIONS ); + mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED ); + mImpl->mRecalculateNaturalSize = true; + mImpl->RequestRelayout(); + } +} + void Controller::SetTextColor( const Vector4& textColor ) { mImpl->mTextColor = textColor; diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h index 99c2ab0..fa4f966 100644 --- a/dali-toolkit/internal/text/text-controller.h +++ b/dali-toolkit/internal/text/text-controller.h @@ -178,8 +178,9 @@ public: * @brief Set the default font family. * * @param[in] defaultFontFamily The default font family. + * @param[in] userDefined If set by the user */ - void SetDefaultFontFamily( const std::string& defaultFontFamily ); + void SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined ); /** * @brief Retrieve the default font family. @@ -217,6 +218,12 @@ public: float GetDefaultPointSize() const; /** + * @ brief Update the text after a font change + * @param[in] newDefaultFont The new font to change to + */ + void UpdateAfterFontChange( std::string& newDefaultFont ); + + /** * @brief Set the text color * * @param textColor The text color