From: Bowon Ryu Date: Wed, 19 Jun 2024 06:58:44 +0000 (+0900) Subject: Add support custom font directory in async text X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b212e7ca8774b954ca3803421d334165b67159c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Add support custom font directory in async text ApplyCustomFontDirectories should be called after all AsyncTextModule(FontClient) are created Change-Id: Ib8ba7b6faaec996c24661870c43d22696aac9850 Signed-off-by: Bowon Ryu --- diff --git a/dali-toolkit/internal/text/async-text/async-text-loader-impl.cpp b/dali-toolkit/internal/text/async-text/async-text-loader-impl.cpp index 9bf9f69..bc5b702 100644 --- a/dali-toolkit/internal/text/async-text/async-text-loader-impl.cpp +++ b/dali-toolkit/internal/text/async-text/async-text-loader-impl.cpp @@ -61,13 +61,11 @@ AsyncTextLoader::AsyncTextLoader() : mModule(), mTextModel(), mMetrics(), - mCustomFontDirectories(), mNumberOfCharacters(0u), mFitActualEllipsis(true), mIsTextDirectionRTL(false), mIsTextMirrored(false), mModuleClearNeeded(false), - mCustomFontDirAddNeeded(false), mMutex() { DALI_LOG_RELEASE_INFO("-->AsyncTextLoader::AsyncTextLoader\n"); @@ -103,38 +101,6 @@ bool AsyncTextLoader::IsModuleClearNeeded() 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() { diff --git a/dali-toolkit/internal/text/async-text/async-text-loader-impl.h b/dali-toolkit/internal/text/async-text/async-text-loader-impl.h index d0b9ea2..b72ec83 100644 --- a/dali-toolkit/internal/text/async-text/async-text-loader-impl.h +++ b/dali-toolkit/internal/text/async-text/async-text-loader-impl.h @@ -72,31 +72,6 @@ public: */ 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 /** @@ -209,13 +184,11 @@ private: Text::Layout::Engine mLayoutEngine; Text::TypesetterPtr mTypesetter; - std::vector 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 diff --git a/dali-toolkit/internal/text/async-text/async-text-loader.cpp b/dali-toolkit/internal/text/async-text/async-text-loader.cpp index 760b072..2f8db7f 100644 --- a/dali-toolkit/internal/text/async-text/async-text-loader.cpp +++ b/dali-toolkit/internal/text/async-text/async-text-loader.cpp @@ -55,31 +55,6 @@ bool AsyncTextLoader::IsModuleClearNeeded() 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(); diff --git a/dali-toolkit/internal/text/async-text/async-text-loader.h b/dali-toolkit/internal/text/async-text/async-text-loader.h index 992c3c2..49435c8 100644 --- a/dali-toolkit/internal/text/async-text/async-text-loader.h +++ b/dali-toolkit/internal/text/async-text/async-text-loader.h @@ -288,45 +288,6 @@ public: 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. diff --git a/dali-toolkit/internal/text/async-text/async-text-manager-impl.cpp b/dali-toolkit/internal/text/async-text/async-text-manager-impl.cpp index 63ec7b1..16eb590 100644 --- a/dali-toolkit/internal/text/async-text/async-text-manager-impl.cpp +++ b/dali-toolkit/internal/text/async-text/async-text-manager-impl.cpp @@ -61,6 +61,9 @@ AsyncTextManager::AsyncTextManager() { 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() @@ -111,24 +114,6 @@ void AsyncTextManager::OnLocaleChanged(std::string locale) } } -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; @@ -142,11 +127,6 @@ Text::AsyncTextLoader AsyncTextManager::GetAvailableLoader() loader.ClearModule(); loader.SetModuleClearNeeded(false); } - if(loader.IsCustomFontDirectoryAddNeeded()) - { - loader.AddCustomFontDirectories(); - loader.SetCustomFontDirectoryAddNeeded(false); - } mAvailableLoaders.pop_back(); mRunningLoaders.push_back(loader); diff --git a/dali-toolkit/internal/text/async-text/async-text-manager-impl.h b/dali-toolkit/internal/text/async-text/async-text-manager-impl.h index 8db1233..7e9eff6 100644 --- a/dali-toolkit/internal/text/async-text/async-text-manager-impl.h +++ b/dali-toolkit/internal/text/async-text/async-text-manager-impl.h @@ -65,17 +65,6 @@ public: 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);