: mPlatformAbstraction(platformAbstraction),
mDefaultFontSize(-1)
{
- mfontClient = TextAbstraction::FontClient::Get();
- GetSystemDefaultFontFamily( mfontClient, mDefaultFontFamily );
+ mFontClient = TextAbstraction::FontClient::Get();
+ GetSystemDefaultFontFamily( mFontClient, mDefaultFontFamily );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "StyleMonitor::StyleMonitor::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str() );
mDefaultFontSize = mPlatformAbstraction.GetDefaultFontSize();
}
{
case StyleChange::DEFAULT_FONT_CHANGE:
{
- GetSystemDefaultFontFamily( mfontClient, mDefaultFontFamily );
+ if ( mFontClient )
+ {
+ mFontClient.ResetSystemDefaults();
+ GetSystemDefaultFontFamily( mFontClient, mDefaultFontFamily );
+ }
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "StyleMonitor::StyleChanged::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str() );
break;
}
Integration::PlatformAbstraction& mPlatformAbstraction; ///< Reference to the PlatformAbstraction (for retrieving defaults)
- TextAbstraction::FontClient mfontClient;
+ TextAbstraction::FontClient mFontClient;
std::string mDefaultFontFamily; ///< The system default font family
std::string mDefaultFontStyle; ///< The default font style
std::string mUserDefinedThemeFilePath; ///< String containing the user defined theme file path
GetImplementation(*this).GetDpi( horizontalDpi, verticalDpi );
}
-void FontClient::SetDefaultFont( const FontDescription& fontDescription )
+void FontClient::ResetSystemDefaults()
{
- GetImplementation(*this).SetDefaultFont( fontDescription );
+ GetImplementation(*this).ResetSystemDefaults();
}
void FontClient::GetDefaultFonts( FontList& defaultFonts )
void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi );
/**
- * Set the default font family and its style that should be used by the font client.
- * The style could be a pair 'font style, font width' or a cluster 'font width, font weight, font slant'.
+ * @brief Called when the user changes the system defaults.
*
- * @param[in] fontDescription Description of the default font.
+ * @post Previously cached system defaults are removed.
*/
- void SetDefaultFont( const FontDescription& fontDescription );
+ void ResetSystemDefaults();
/**
* @brief Retrieve the list of default fonts supported by the system.
verticalDpi = mDpiVertical;
}
-void FontClient::SetDefaultFont( const FontDescription& fontDescription )
+void FontClient::ResetSystemDefaults()
{
CreatePlugin();
- mPlugin->SetDefaultFont( fontDescription );
+ mPlugin->ResetSystemDefaults();
}
void FontClient::GetDefaultFonts( FontList& defaultFonts )
void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi );
/**
- * @copydoc Dali::FontClient::SetDefaultFont()
+ * @copydoc Dali::FontClient::ResetSystemDefaults()
*/
- void SetDefaultFont( const FontDescription& fontDescription );
+ void ResetSystemDefaults();
/**
* @copydoc Dali::FontClient::GetDefaultFonts()
: mFreeTypeLibrary( NULL ),
mDpiHorizontal( horizontalDpi ),
mDpiVertical( verticalDpi ),
+ mDefaultFontDescription(),
mSystemFonts(),
mDefaultFonts(),
mFontCache(),
mValidatedFontCache(),
mFontDescriptionCache( 1u ),
mFontIdCache(),
- mEllipsisCache()
+ mEllipsisCache(),
+ mDefaultFontDescriptionCached( false )
{
int error = FT_Init_FreeType( &mFreeTypeLibrary );
if( FT_Err_Ok != error )
mDpiVertical = verticalDpi;
}
+void FontClient::Plugin::ResetSystemDefaults()
+{
+ mDefaultFontDescriptionCached = false;
+}
+
void FontClient::Plugin::SetFontList( const FontDescription& fontDescription, FontList& fontList )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::SetFontList family(%s)\n", fontDescription.family.c_str() );
FcPatternDestroy( fontFamilyPattern );
}
-void FontClient::Plugin::SetDefaultFont( const FontDescription& fontDescription )
-{
- SetFontList( fontDescription, mDefaultFonts );
-}
-
void FontClient::Plugin::GetDefaultFonts( FontList& defaultFonts )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::GetDefaultFonts mDefaultFonts(%s)\n", ( mDefaultFonts.empty()?"empty":"valid" ) );
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::GetDefaultPlatformFontDescription\n");
- FcInitReinitialize(); // FcInitBringUptoDate did not seem to reload config file as was still getting old default font.
+ if( !mDefaultFontDescriptionCached )
+ {
+ FcInitReinitialize(); // FcInitBringUptoDate did not seem to reload config file as was still getting old default font.
+
+ FcPattern* matchPattern = FcPatternCreate();
+ FcConfigSubstitute(NULL, matchPattern, FcMatchPattern);
+ FcDefaultSubstitute( matchPattern );
- FcPattern* matchPattern = FcPatternCreate();
- FcConfigSubstitute(NULL, matchPattern, FcMatchPattern);
- FcDefaultSubstitute( matchPattern );
+ MatchFontDescriptionToPattern( matchPattern, mDefaultFontDescription );
+ FcPatternDestroy( matchPattern );
+
+ mDefaultFontDescriptionCached = true;
+ }
- MatchFontDescriptionToPattern( matchPattern, fontDescription );
- FcPatternDestroy( matchPattern );
+ fontDescription.path = mDefaultFontDescription.path;
+ fontDescription.family = mDefaultFontDescription.family;
+ fontDescription.width = mDefaultFontDescription.width;
+ fontDescription.weight = mDefaultFontDescription.weight;
+ fontDescription.slant = mDefaultFontDescription.slant;
}
void FontClient::Plugin::GetSystemFonts( FontList& systemFonts )
void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi );
/**
+ * @copydoc Dali::FontClient::ResetSystemDefaults()
+ */
+ void ResetSystemDefaults();
+
+ /**
* @copydoc Dali::FontClient::SetDefaultFont()
*/
void SetDefaultFont( const FontDescription& fontDescription );
FontDescriptionId& validatedFontId );
/**
- * Helper for SetDefaultFont etc.
+ * Helper for GetDefaultFonts etc.
*
* @param[in] fontDescription A font description.
* @param[out] fontList A list of the fonts which are a close match for fontDescription.
unsigned int mDpiHorizontal; ///< Horizontal dpi.
unsigned int mDpiVertical; ///< Vertical dpi.
+ FontDescription mDefaultFontDescription; ///< The cached default font from the system
+
FontList mSystemFonts; ///< Cached system fonts.
FontList mDefaultFonts; ///< Cached default fonts.
std::vector<FontIdCacheItem> mFontIdCache; ///< Caches font ids for the pairs of font point size and the index to the vector with font descriptions of the validated fonts.
Vector<EllipsisItem> mEllipsisCache; ///< Caches ellipsis glyphs for a particular point size.
+
+ bool mDefaultFontDescriptionCached : 1; ///< Whether the default font is cached or not
};
} // namespace Internal