return StyleMonitor(dynamic_cast<Internal::Adaptor::StyleMonitor*>(handle.GetObjectPtr()));
}
+bool StyleMonitor::EnsureFontClientCreated()
+{
+ return GetImplementation(*this).EnsureFontClientCreated();
+}
+
std::string StyleMonitor::GetDefaultFontFamily() const
{
return GetImplementation(*this).GetDefaultFontFamily();
static StyleMonitor DownCast(BaseHandle handle);
public: // Style Information
+
+ /**
+ * @brief Ensure the font client has been created.
+ *
+ * If font client doesn't exist, create it and set default values.
+ * @return true if the font client has been created.
+ */
+ bool EnsureFontClientCreated();
+
/**
* @brief Retrieves the default font family.
* @return The default font family.
StyleMonitor::StyleMonitor()
: mDefaultFontSize(-1)
{
- mFontClient = TextAbstraction::FontClient::Get();
- GetSystemDefaultFontFamily(mFontClient, mDefaultFontFamily);
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "StyleMonitor::StyleMonitor::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str());
- mDefaultFontSize = mFontClient.GetDefaultFontSize();
}
StyleMonitor::~StyleMonitor()
{
}
+bool StyleMonitor::EnsureFontClientCreated()
+{
+ if(!mFontClient)
+ {
+ mFontClient = TextAbstraction::FontClient::Get();
+ GetSystemDefaultFontFamily(mFontClient, mDefaultFontFamily);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "StyleMonitor::StyleMonitor::DefaultFontFamily(%s)\n", mDefaultFontFamily.c_str());
+ mDefaultFontSize = mFontClient.GetDefaultFontSize();
+ }
+
+ return mFontClient != nullptr ? true : false;
+}
+
void StyleMonitor::StyleChanged(StyleChange::Type styleChange)
{
switch(styleChange)
{
case StyleChange::DEFAULT_FONT_CHANGE:
{
- if(mFontClient)
+ if(EnsureFontClientCreated())
{
mFontClient.ResetSystemDefaults();
GetSystemDefaultFontFamily(mFontClient, mDefaultFontFamily);
case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
{
- mDefaultFontSize = mFontClient.GetDefaultFontSize();
+ if(EnsureFontClientCreated())
+ {
+ mDefaultFontSize = mFontClient.GetDefaultFontSize();
+ }
break;
}