ApplyCustomFontDirectories should be called after all AsyncTextModule(FontClient) are created
Change-Id: Ib8ba7b6faaec996c24661870c43d22696aac9850
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
: mModule(),
mTextModel(),
mMetrics(),
- mCustomFontDirectories(),
mNumberOfCharacters(0u),
mFitActualEllipsis(true),
mIsTextDirectionRTL(false),
mIsTextMirrored(false),
mModuleClearNeeded(false),
- mCustomFontDirAddNeeded(false),
mMutex()
{
DALI_LOG_RELEASE_INFO("-->AsyncTextLoader::AsyncTextLoader\n");
return mModuleClearNeeded;
}
-void AsyncTextLoader::AddCustomFontDirectory(const std::string& fontPath)
-{
- mModule.GetFontClient().AddCustomFontDirectory(fontPath);
-}
-
-void AsyncTextLoader::SetCustomFontDirectoryAddNeeded(bool add)
-{
- Dali::Mutex::ScopedLock lock(mMutex);
- mCustomFontDirAddNeeded = add;
-}
-
-bool AsyncTextLoader::IsCustomFontDirectoryAddNeeded()
-{
- return mCustomFontDirAddNeeded;
-}
-
-void AsyncTextLoader::AddCustomFontDirectoryToList(const std::string& fontPath)
-{
- Dali::Mutex::ScopedLock lock(mMutex);
- mCustomFontDirectories.push_back(fontPath);
-}
-
-void AsyncTextLoader::AddCustomFontDirectories()
-{
- for(const auto& path : mCustomFontDirectories)
- {
- AddCustomFontDirectory(path);
- }
- mCustomFontDirectories.clear();
-}
-
-
// Worker thread
void AsyncTextLoader::Initialize()
{
*/
bool IsModuleClearNeeded();
- /**
- * @copydoc Dali::AsyncTextLoader::AddCustomFontDirectory()
- */
- void AddCustomFontDirectory(const std::string& fontPath);
-
- /**
- * @copydoc Dali::AsyncTextLoader::SetCustomFontDirectoryAddNeeded()
- */
- void SetCustomFontDirectoryAddNeeded(bool add);
-
- /**
- * @copydoc Dali::AsyncTextLoader::IsCustomFontDirectoryAddNeeded()
- */
- bool IsCustomFontDirectoryAddNeeded();
-
- /**
- * @copydoc Dali::AsyncTextLoader::AddCustomFontDirectoryToList()
- */
- void AddCustomFontDirectoryToList(const std::string& fontPath);
-
- /**
- * @copydoc Dali::AsyncTextLoader::AddCustomFontDirectories()
- */
- void AddCustomFontDirectories();
-
// Worker thread
/**
Text::Layout::Engine mLayoutEngine;
Text::TypesetterPtr mTypesetter;
- std::vector<std::string> mCustomFontDirectories; // The requested custom font path is added, and if another request comes before the request is processed, it will be added to this list.
Length mNumberOfCharacters;
bool mFitActualEllipsis : 1; // Used to store actual ellipses during TextFit calculations. Do not use it in other sections.
bool mIsTextDirectionRTL : 1; // The direction of the first line after layout completion.
bool mIsTextMirrored : 1;
bool mModuleClearNeeded : 1;
- bool mCustomFontDirAddNeeded : 1;
Mutex mMutex;
}; // class AsyncTextLoader
return GetImplementation(*this).IsModuleClearNeeded();
}
-void AsyncTextLoader::AddCustomFontDirectory(const std::string& fontPath)
-{
- GetImplementation(*this).AddCustomFontDirectory(fontPath);
-}
-
-void AsyncTextLoader::SetCustomFontDirectoryAddNeeded(bool add)
-{
- GetImplementation(*this).SetCustomFontDirectoryAddNeeded(add);
-}
-
-bool AsyncTextLoader::IsCustomFontDirectoryAddNeeded()
-{
- return GetImplementation(*this).IsCustomFontDirectoryAddNeeded();
-}
-
-void AsyncTextLoader::AddCustomFontDirectoryToList(const std::string& fontPath)
-{
- GetImplementation(*this).AddCustomFontDirectoryToList(fontPath);
-}
-
-void AsyncTextLoader::AddCustomFontDirectories()
-{
- GetImplementation(*this).AddCustomFontDirectories();
-}
-
AsyncTextLoader AsyncTextLoader::New()
{
auto asyncTextLoaderImpl = new Internal::AsyncTextLoader();
bool IsModuleClearNeeded();
/**
- * @brief Add custom font directory to module's font client.
- *
- * @param[in] fontPath to the fonts directory.
- */
- void AddCustomFontDirectory(const std::string& fontPath);
-
- /**
- * @brief Sets a flag indicating that custom font directory adding is needed.
- *
- * When the async text loader is available, font directory add is processed on the main thread.
- *
- * @param[in] add Whether to add the directory or not.
- */
- void SetCustomFontDirectoryAddNeeded(bool add);
-
- /**
- * @brief Whether custom font directory adding is needed.
- *
- * @return A flag that indicates whether the custom font directory should be added or not.
- */
- bool IsCustomFontDirectoryAddNeeded();
-
- /**
- * @brief Add custom font directory to list.
- *
- * Store the requested font path list until loader can update the custom font directory in the module's font client.
- *
- * @param[in] fontPath to the fonts directory.
- */
- void AddCustomFontDirectoryToList(const std::string& fontPath);
-
- /**
- * @brief Add custom font directories to module's font client.
- *
- * Add all stored font path list to the font client and clear the list.
- */
- void AddCustomFontDirectories();
-
- /**
* @brief Renders text into a pixel buffer.
*
* @param[in] parameters All options required to render text.
{
Dali::Adaptor::Get().LocaleChangedSignal().Connect(this, &AsyncTextManager::OnLocaleChanged);
}
+
+ // This function should be called after all AsyncTextModule(FontClient) are created.
+ TextAbstraction::FontClient::Get().ApplyCustomFontDirectories();
}
AsyncTextManager::~AsyncTextManager()
}
}
-void AsyncTextManager::AddCustomFontDirectory(const std::string fontPath)
-{
- if(!fontPath.empty())
- {
- for(auto& loader : mAvailableLoaders)
- {
- loader.AddCustomFontDirectory(fontPath);
- }
-
- // When the Loader is in running state, just store the path to list and update it when it becomes available.
- for(auto& loader : mRunningLoaders)
- {
- loader.AddCustomFontDirectoryToList(fontPath);
- loader.SetCustomFontDirectoryAddNeeded(true);
- }
- }
-}
-
bool AsyncTextManager::IsAvailableLoader()
{
return mAvailableLoaders.size() > 0u;
loader.ClearModule();
loader.SetModuleClearNeeded(false);
}
- if(loader.IsCustomFontDirectoryAddNeeded())
- {
- loader.AddCustomFontDirectories();
- loader.SetCustomFontDirectoryAddNeeded(false);
- }
mAvailableLoaders.pop_back();
mRunningLoaders.push_back(loader);
void OnLocaleChanged(std::string locale);
/**
- * @brief Add custom fonts directory to each text loader's font client.
- *
- * For available loaders, immediately call loader's AddCustomFontDirectory.
- * For running loaders, store the path in directory list and
- * call loader's AddCustomFontDirectory on the list when the loader's update is possible.
- *
- * @param[in] fontPath to the fonts directory.
- */
- void AddCustomFontDirectory(const std::string fontPath);
-
- /**
* @copydoc Dali::AsyncTextManager::RequestLoad()
*/
uint32_t RequestLoad(AsyncTextParameters& parameters, TextLoadObserver* observer);