X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Ftext%2Ftext-abstraction%2Ffont-client-impl.h;h=ff86fd960e1087b811a38a3b92f2987357f73bec;hb=d676584a4cb6eef8410fd1d7f23fc838ac398f99;hp=37596b41ad9b68c5bb0feb06c562cc00549e2722;hpb=e0a7e95ba0d0d294630d3fe9908d04da2044f063;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/text/text-abstraction/font-client-impl.h b/dali/internal/text/text-abstraction/font-client-impl.h old mode 100755 new mode 100644 index 37596b4..ff86fd9 --- a/dali/internal/text/text-abstraction/font-client-impl.h +++ b/dali/internal/text/text-abstraction/font-client-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_IMPL_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -24,17 +24,15 @@ // INTERNAL INCLUDES #include - struct FT_FaceRec_; namespace Dali { - namespace TextAbstraction { - namespace Internal { +using HarfBuzzFontHandle = void*; ///< @note We don't want to make other class include harfbuzz header. So we will keep harfbuzz font data as HarfBuzzFontHandle. /** * Implementation of the FontClient @@ -42,7 +40,6 @@ namespace Internal class FontClient : public BaseObject { public: - /** * Constructor */ @@ -53,20 +50,67 @@ public: */ ~FontClient(); +public: // API for Dali::TextAbstraction::FontClient used. /** * @copydoc Dali::TextAbstraction::FontClient::Get() */ static Dali::TextAbstraction::FontClient Get(); /** + * @brief This is used to improve application launch performance + * + * @return A pre-initialized FontClient + */ + static Dali::TextAbstraction::FontClient PreInitialize(); + + /** + * @brief This is used to pre-cache FontConfig in order to improve the runtime performance of the application. + * + * @see Dali::TextAbstraction::FontClientPreCache(const FontFamilyList& fallbackFamilyList, const FontFamilyList& extraFamilyList, const FontFamily& localeFamily, bool useThread, bool syncCreation); + */ + static void PreCache(const FontFamilyList& fallbackFamilyList, const FontFamilyList& extraFamilyList, const FontFamily& localeFamily, bool useThread, bool syncCreation); + + /** + * @brief This is used to creates a global font client and pre-caches the FontConfig. + */ + static void PreCacheRun(const FontFamilyList& fallbackFamilyList, const FontFamilyList& extraFamilyList, const FontFamily& localeFamily, bool syncCreation); + + /** + * @brief This is used to pre-load FreeType font face in order to improve the runtime performance of the application. + * + * @see Dali::TextAbstraction:FontClientFontPreLoad(const FontPathList& fontPathList, const FontPathList& memoryFontPathList, bool useThread, bool syncCreation); + */ + static void PreLoad(const FontPathList& fontPathList, const FontPathList& memoryFontPathList, bool useThread, bool syncCreation); + + /** + * @brief This is used to creates a global font client and pre-loads the FreeType font face. + */ + static void PreLoadRun(const FontPathList& fontPathList, const FontPathList& memoryFontPathList, bool syncCreation); + + /** + * @brief Joins font threads, waiting for their execution to complete. + */ + static void JoinFontThreads(); + + /** + * @copydoc Dali::TextAbstraction::FontClient::ClearCache() + */ + void ClearCache(); + + /** + * @copydoc Dali::TextAbstraction::FontClient::ClearCacheOnLocaleChanged() + */ + void ClearCacheOnLocaleChanged(); + + /** * @copydoc Dali::TextAbstraction::FontClient::SetDpi() */ - void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi ); + void SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi); /** * @copydoc Dali::TextAbstraction::FontClient::GetDpi() */ - void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi ); + void GetDpi(unsigned int& horizontalDpi, unsigned int& verticalDpi); /** * @copydoc Dali::TextAbstraction::FontClient::GetDefaultFontSize() @@ -81,144 +125,195 @@ public: /** * @copydoc Dali::TextAbstraction::FontClient::GetDefaultFonts() */ - void GetDefaultFonts( FontList& defaultFonts ); + void GetDefaultFonts(FontList& defaultFonts); + + /** + * @copydoc Dali::TextAbstraction::FontClient::InitDefaultFontDescription() + */ + void InitDefaultFontDescription(); /** * @copydoc Dali::TextAbstraction::FontClient::GetDefaultPlatformFontDescription() */ - void GetDefaultPlatformFontDescription( FontDescription& fontDescription ); + void GetDefaultPlatformFontDescription(FontDescription& fontDescription); /** * @copydoc Dali::TextAbstraction::FontClient::GetSystemFonts() */ - void GetSystemFonts( FontList& systemFonts ); + void GetSystemFonts(FontList& systemFonts); /** * @copydoc Dali::TextAbstraction::FontClient::GetDescription() */ - void GetDescription( FontId id, FontDescription& fontDescription ); + void GetDescription(FontId fontId, FontDescription& fontDescription); /** * @copydoc Dali::TextAbstraction::FontClient::GetPointSize() */ - PointSize26Dot6 GetPointSize( FontId id ); + PointSize26Dot6 GetPointSize(FontId fontId); /** * @copydoc Dali::TextAbstraction::FontClient::IsCharacterSupportedByFont() */ - bool IsCharacterSupportedByFont( FontId fontId, Character character ); + bool IsCharacterSupportedByFont(FontId fontId, Character character); /** * @copydoc Dali::TextAbstraction::FontClient::FindDefaultFont() */ - FontId FindDefaultFont( Character charcode, - PointSize26Dot6 requestedPointSize, - bool preferColor ); + FontId FindDefaultFont(Character charcode, + PointSize26Dot6 requestedPointSize, + bool preferColor); /** * @copydoc Dali::TextAbstraction::FontClient::FindFallbackFont() */ - FontId FindFallbackFont( Character charcode, - const FontDescription& preferredFontDescription, - PointSize26Dot6 requestedPointSize, - bool preferColor ); + FontId FindFallbackFont(Character charcode, + const FontDescription& preferredFontDescription, + PointSize26Dot6 requestedPointSize, + bool preferColor); /** * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex ) */ - FontId GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex ); + FontId GetFontId(const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex); /** * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex ) */ - FontId GetFontId( const FontDescription& fontDescription, - PointSize26Dot6 requestedPointSize, - FaceIndex faceIndex ); + FontId GetFontId(const FontDescription& fontDescription, + PointSize26Dot6 requestedPointSize, + FaceIndex faceIndex); /** * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const BitmapFont& bitmapFont ) */ - FontId GetFontId( const BitmapFont& bitmapFont ); + FontId GetFontId(const BitmapFont& bitmapFont); /** * @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontPath& path ) */ - bool IsScalable( const FontPath& path ); + bool IsScalable(const FontPath& path); /** * @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontDescription& fontDescription ) */ - bool IsScalable( const FontDescription& fontDescription ); + bool IsScalable(const FontDescription& fontDescription); /** * @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes ) */ - void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes ); + void GetFixedSizes(const FontPath& path, Dali::Vector& sizes); /** * @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes() */ - void GetFixedSizes( const FontDescription& fontDescription, - Dali::Vector< PointSize26Dot6 >& sizes ); + void GetFixedSizes(const FontDescription& fontDescription, + Dali::Vector& sizes); /** * @copydoc Dali::TextAbstraction::FontClient::HasItalicStyle() */ - bool HasItalicStyle( FontId fontId ) const; + bool HasItalicStyle(FontId fontId) const; /** * @copydoc Dali::TextAbstraction::FontClient::GetFontMetrics() */ - void GetFontMetrics( FontId fontId, FontMetrics& metrics ); + void GetFontMetrics(FontId fontId, FontMetrics& metrics); /** * @copydoc Dali::TextAbstraction::FontClient::GetGlyphIndex() */ - GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ); + GlyphIndex GetGlyphIndex(FontId fontId, Character charcode); + + /** + * @copydoc Dali::TextAbstraction::FontClient::GetGlyphIndex() + */ + GlyphIndex GetGlyphIndex(FontId fontId, Character charcode, Character variantSelector); /** * @copydoc Dali::TextAbstraction::FontClient::GetGlyphMetrics() */ - bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal ); + bool GetGlyphMetrics(GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal); /** - * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth ) + * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::GlyphBufferData& data, int outlineWidth ) */ - void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth ); + void CreateBitmap(FontId fontId, GlyphIndex glyphIndex, bool isItalicRequired, bool isBoldRequired, Dali::TextAbstraction::GlyphBufferData& data, int outlineWidth); /** * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth ) */ - PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth ); + PixelData CreateBitmap(FontId fontId, GlyphIndex glyphIndex, int outlineWidth); /** * @copydoc Dali::TextAbstraction::FontClient::CreateVectorBlob() */ - void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight ); + void CreateVectorBlob(FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight); /** * @copydoc Dali::TextAbstraction::FontClient::GetEllipsisGlyph() */ - const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize ); + const GlyphInfo& GetEllipsisGlyph(PointSize26Dot6 requestedPointSize); /** * @copydoc Dali::TextAbstraction::FontClient::IsColorGlyph() */ - bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ); + bool IsColorGlyph(FontId fontId, GlyphIndex glyphIndex); /** * @copydoc Dali::TextAbstraction::FontClient::CreateEmbeddedItem() */ - GlyphIndex CreateEmbeddedItem( const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat ); + GlyphIndex CreateEmbeddedItem(const TextAbstraction::FontClient::EmbeddedItemDescription& description, Pixel::Format& pixelFormat); /** + * @copydoc Dali::TextAbstraction::FontClient::EnableAtlasLimitation(bool enabled) + */ + void EnableAtlasLimitation(bool enabled); + + /** + * @copydoc Dali::TextAbstraction::FontClient::IsAtlasLimitationEnabled() + */ + bool IsAtlasLimitationEnabled() const; + + /** + * @copydoc Dali::TextAbstraction::FontClient::GetMaximumTextAtlasSize() + */ + Size GetMaximumTextAtlasSize() const; + + /** + * @copydoc Dali::TextAbstraction::FontClient::GetDefaultTextAtlasSize() + */ + Size GetDefaultTextAtlasSize() const; + + /** + * @copydoc Dali::TextAbstraction::FontClient::GetCurrentMaximumBlockSizeFitInAtlas() + */ + Size GetCurrentMaximumBlockSizeFitInAtlas() const; + + /** + * @copydoc Dali::TextAbstraction::FontClient::SetCurrentMaximumBlockSizeFitInAtlas(const Size& currentMaximumBlockSizeFitInAtlas) + */ + bool SetCurrentMaximumBlockSizeFitInAtlas(const Size& currentMaximumBlockSizeFitInAtlas); + + /** + * @copydoc Dali::TextAbstraction::FontClient::GetNumberOfPointsPerOneUnitOfPointSize() + */ + uint32_t GetNumberOfPointsPerOneUnitOfPointSize() const; + + /** + * @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory() + */ + bool AddCustomFontDirectory(const FontPath& path); + +public: // API for Dali::TextAbstraction::Internal::FontClient used. + /** * @brief Retrieves the pointer to the FreeType Font Face for the given @p fontId. * * @param[in] fontId The font id. * * @return The pointer to the FreeType Font Face. */ - FT_FaceRec_* GetFreetypeFace( FontId fontId ); + FT_FaceRec_* GetFreetypeFace(FontId fontId); /** * @brief Retrieves the type of font. @@ -227,28 +322,48 @@ public: * * @return FACE_FONT if the font has been loaded by FreeType, BITMAP_FONT if it's a font that has been loaded from images or INVALID if it's a non valid font. */ - FontDescription::Type GetFontType( FontId fontId ); + FontDescription::Type GetFontType(FontId fontId); /** - * @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory() + * @brief Get the harfbuzz font data of font. + * + * @param fontId The font id. + * @return The harfbuzz font data, or nullptr if failed. */ - bool AddCustomFontDirectory( const FontPath& path ); + HarfBuzzFontHandle GetHarfBuzzFont(FontId fontId); -private: + /** + * @brief This is used to pre-cache fonts in order to improve the runtime performance of the application. + * + * @param[in] fallbackFamilyList A list of fallback font families to be pre-cached. + * @param[in] extraFamilyList A list of additional font families to be pre-cached. + * @param[in] localeFamily A locale font family to be pre-cached. + */ + void FontPreCache(const FontFamilyList& fallbackFamilyList, const FontFamilyList& extraFamilyList, const FontFamily& localeFamily); /** + * @brief This is used to pre-load FreeType font face in order to improve the runtime performance of the application. + * + * @param[in] fontPathList A list of font paths to be pre-loaded. + * @param[in] memoryFontPathList A list of memory font paths to be pre-loaded. + * @param[in] useThread True if the font client should create thread and perform font pre-loading, false otherwise. + */ + void FontPreLoad(const FontPathList& fontPathList, const FontPathList& memoryFontPathList); + + +private: + /** * Helper for lazy initialization. */ void CreatePlugin(); // Undefined copy constructor. - FontClient( const FontClient& ); + FontClient(const FontClient&); // Undefined assignment constructor. - FontClient& operator=( const FontClient& ); + FontClient& operator=(const FontClient&); private: - struct Plugin; Plugin* mPlugin; @@ -256,20 +371,22 @@ private: unsigned int mDpiHorizontal; unsigned int mDpiVertical; + static Dali::TextAbstraction::FontClient gPreCreatedFontClient; + }; // class FontClient } // namespace Internal inline static Internal::FontClient& GetImplementation(FontClient& fontClient) { - DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" ); + DALI_ASSERT_ALWAYS(fontClient && "fontClient handle is empty"); BaseObject& handle = fontClient.GetBaseObject(); return static_cast(handle); } inline static const Internal::FontClient& GetImplementation(const FontClient& fontClient) { - DALI_ASSERT_ALWAYS( fontClient && "fontClient handle is empty" ); + DALI_ASSERT_ALWAYS(fontClient && "fontClient handle is empty"); const BaseObject& handle = fontClient.GetBaseObject(); return static_cast(handle); }