X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=text%2Fdali%2Finternal%2Ftext-abstraction%2Ffont-client-plugin-impl.h;h=c1e158fa14a5ebecbf7cae7455bb9c4e8e992c90;hb=d8a28c83a0d0671086393c42275e4a2598445db5;hp=4f191a660fe6db7a41ff7f82a7cdc2c339f700d8;hpb=8e0c1a9f28ec10a284feb6c37985be0c3b5266b7;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/text/dali/internal/text-abstraction/font-client-plugin-impl.h b/text/dali/internal/text-abstraction/font-client-plugin-impl.h index 4f191a6..c1e158f 100644 --- a/text/dali/internal/text-abstraction/font-client-plugin-impl.h +++ b/text/dali/internal/text-abstraction/font-client-plugin-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H__ -#define __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H__ +#ifndef DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H +#define DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -33,8 +33,11 @@ class VectorFontCache; #include #include FT_FREETYPE_H #include FT_GLYPH_H +#include FT_OUTLINE_H +#include FT_STROKER_H // forward declarations of font config types. +struct _FcCharSet; struct _FcFontSet; struct _FcPattern; @@ -51,6 +54,7 @@ namespace Internal *@brief Type used for indices addressing the vector with front descriptions of validated fonts. */ typedef uint32_t FontDescriptionId; +typedef Vector<_FcCharSet*> CharacterSetList; /** * @brief FontClient implementation. @@ -62,10 +66,11 @@ struct FontClient::Plugin */ struct FallbackCacheItem { - FallbackCacheItem( const FontDescription& fontDescription, FontList* fallbackFonts ); + FallbackCacheItem( const FontDescription& fontDescription, FontList* fallbackFonts, CharacterSetList* characterSets ); FontDescription fontDescription; ///< The font description. FontList* fallbackFonts; ///< The list of fallback fonts for the given font-description. + CharacterSetList* characterSets; ///< The list of character sets for the given font-description. }; /** @@ -91,37 +96,40 @@ struct FontClient::Plugin FontDescriptionId validatedFontId; ///< Index to the vector with font descriptions. PointSize26Dot6 requestedPointSize; ///< The font point size. - FontId fontId; ///< The font id. + FontId fontId; ///< The font identifier. }; /** * @brief Caches the FreeType face and font metrics of the triplet 'path to the font file name, font point size and face index'. */ - struct CacheItem + struct FontFaceCacheItem { - CacheItem( FT_Face ftFace, - const FontPath& path, - PointSize26Dot6 requestedPointSize, - FaceIndex face, - const FontMetrics& metrics ); - - CacheItem( FT_Face ftFace, - const FontPath& path, - PointSize26Dot6 requestedPointSize, - FaceIndex face, - const FontMetrics& metrics, - float fixedWidth, - float fixedHeight ); + FontFaceCacheItem( FT_Face ftFace, + const FontPath& path, + PointSize26Dot6 requestedPointSize, + FaceIndex face, + const FontMetrics& metrics ); + + FontFaceCacheItem( FT_Face ftFace, + const FontPath& path, + PointSize26Dot6 requestedPointSize, + FaceIndex face, + const FontMetrics& metrics, + float fixedWidth, + float fixedHeight, + bool hasColorTables ); FT_Face mFreeTypeFace; ///< The FreeType face. FontPath mPath; ///< The path to the font file name. PointSize26Dot6 mRequestedPointSize; ///< The font point size. FaceIndex mFaceIndex; ///< The face index. FontMetrics mMetrics; ///< The font metrics. + _FcCharSet* mCharacterSet; ///< Pointer with the range of characters. FT_Short mFixedWidthPixels; ///< The height in pixels (fixed size bitmaps only) FT_Short mFixedHeightPixels; ///< The height in pixels (fixed size bitmaps only) unsigned int mVectorFontId; ///< The ID of the equivalent vector-based font - bool mIsFixedSizeBitmap; ///< Whether the font has fixed size bitmaps. + bool mIsFixedSizeBitmap : 1; ///< Whether the font has fixed size bitmaps. + bool mHasColorTables : 1; ///< Whether the font has color tables. }; struct EllipsisItem @@ -149,116 +157,132 @@ struct FontClient::Plugin ~Plugin(); /** - * @copydoc Dali::FontClient::SetDpi() + * @copydoc Dali::TextAbstraction::FontClient::SetDpi() */ void SetDpi( unsigned int horizontalDpi, unsigned int verticalDpi ); /** - * @copydoc Dali::FontClient::ResetSystemDefaults() + * @copydoc Dali::TextAbstraction::FontClient::ResetSystemDefaults() */ void ResetSystemDefaults(); /** - * @copydoc Dali::FontClient::SetDefaultFont() + * @copydoc Dali::TextAbstraction::FontClient::SetDefaultFont() */ - void SetDefaultFont( const FontDescription& fontDescription ); + void SetDefaultFont( const FontDescription& preferredFontDescription ); /** - * @copydoc Dali::FontClient::GetDefaultPlatformFontDescription() + * @copydoc Dali::TextAbstraction::FontClient::GetDefaultPlatformFontDescription() */ void GetDefaultPlatformFontDescription( FontDescription& fontDescription ); /** - * @copydoc Dali::FontClient::GetDefaultFonts() + * @copydoc Dali::TextAbstraction::FontClient::GetDefaultFonts() */ void GetDefaultFonts( FontList& defaultFonts ); /** - * @copydoc Dali::FontClient::GetSystemFonts() + * @copydoc Dali::TextAbstraction::FontClient::GetSystemFonts() */ void GetSystemFonts( FontList& systemFonts ); /** - * @copydoc Dali::FontClient::GetDescription() + * @copydoc Dali::TextAbstraction::FontClient::GetDescription() */ void GetDescription( FontId id, FontDescription& fontDescription ) const; /** - * @copydoc Dali::FontClient::GetPointSize() + * @copydoc Dali::TextAbstraction::FontClient::GetPointSize() */ PointSize26Dot6 GetPointSize( FontId id ); /** - * @copydoc Dali::FontClient::FindFontForCharacter() + * @copydoc Dali::TextAbstraction::FontClient::IsCharacterSupportedByFont() + */ + bool IsCharacterSupportedByFont( FontId fontId, Character character ); + + /** + * @brief Finds within the @p fontList a font which support the @p carcode. + * + * @param[in] fontList A list of font paths, family, width, weight and slant. + * @param[in] characterSetList A list that contains a character set for each description of the font list. + * @param[in] charcode The character for which a font is needed. + * @param[in] requestedPointSize The point size in 26.6 fractional points. + * @param[in] preferColor @e true if a color font is preferred. + * + * @return A valid font identifier, or zero if no font is found. */ FontId FindFontForCharacter( const FontList& fontList, + const CharacterSetList& characterSetList, Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor ); /** - * @copydoc Dali::FontClient::FindDefaultFont() + * @copydoc Dali::TextAbstraction::FontClient::FindDefaultFont() */ - FontId FindDefaultFont( Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor ); + FontId FindDefaultFont( Character charcode, + PointSize26Dot6 requestedPointSize, + bool preferColor ); /** - * @copydoc Dali::FontClient::FindFallbackFont() + * @copydoc Dali::TextAbstraction::FontClient::FindFallbackFont() */ - FontId FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor ); + FontId FindFallbackFont( Character charcode, + const FontDescription& preferredFontDescription, + PointSize26Dot6 requestedPointSize, + bool preferColor ); /** - * @see Dali::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex ) + * @see Dali::TextAbstraction::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex ) * - * @param[in] actualPointSize The actual point size. In case of emojis the @p requestedPointSize is used to build the metrics and cache the font and the @p actualPointSize is used to load the glyph. * @param[in] cacheDescription Whether to cache the font description. */ FontId GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, - PointSize26Dot6 actualPointSize, FaceIndex faceIndex, - bool cacheDescription = true ); + bool cacheDescription ); /** - * @copydoc Dali::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex ) + * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontDescription& preferredFontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex ) */ FontId GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, - PointSize26Dot6 actualPointSize, FaceIndex faceIndex ); /** - * @copydoc Dali::FontClient::IsScalable( const FontPath& path ) + * @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontPath& path ) */ bool IsScalable( const FontPath& path ); /** - * @copydoc Dali::FontClient::IsScalable( const FontDescription& fontDescription ) + * @copydoc Dali::TextAbstraction::FontClient::IsScalable( const FontDescription& fontDescription ) */ bool IsScalable( const FontDescription& fontDescription ); /** - * @copydoc Dali::FontClient::GetFixedSizes() + * @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes() */ void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes ); /** - * @copydoc Dali::FontClient::GetFixedSizes() + * @copydoc Dali::TextAbstraction::FontClient::GetFixedSizes() */ void GetFixedSizes( const FontDescription& fontDescription, Dali::Vector< PointSize26Dot6 >& sizes ); /** - * @copydoc Dali::FontClient::GetFontMetrics() + * @copydoc Dali::TextAbstraction::FontClient::GetFontMetrics() */ void GetFontMetrics( FontId fontId, FontMetrics& metrics ); /** - * @copydoc Dali::FontClient::GetGlyphIndex() + * @copydoc Dali::TextAbstraction::FontClient::GetGlyphIndex() */ GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ); /** - * @copydoc Dali::FontClient::GetGlyphMetrics() + * @copydoc Dali::TextAbstraction::FontClient::GetGlyphMetrics() */ bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal ); @@ -273,36 +297,47 @@ struct FontClient::Plugin bool GetVectorMetrics( GlyphInfo* array, uint32_t size, bool horizontal ); /** - * @copydoc Dali::FontClient::CreateBitmap() + * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth ) + */ + void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth ); + + /** + * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth ) */ - PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex ); + PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth ); /** - * @copydoc Dali::FontClient::CreateVectorBlob() + * @copydoc Dali::TextAbstraction::FontClient::CreateVectorBlob() */ void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob, unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight ); /** - * @copydoc Dali::FontClient::GetEllipsisGlyph() + * @copydoc Dali::TextAbstraction::FontClient::GetEllipsisGlyph() */ const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize ); + /** + * @copydoc Dali::TextAbstraction::FontClient::IsColorGlyph() + */ + bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ); + private: /** - * Caches the fonts present in the platform. + * @brief Caches the fonts present in the platform. * * Calls GetFcFontSet() to retrieve the fonts. */ void InitSystemFonts(); /** - * Gets the FontDescription which matches the given pattern - * @param[in] pattern pattern to match against - * @param[out] fontDescription the resultant fontDescription that matched - * @return true if match found + * @brief Gets the FontDescription which matches the given pattern. + * @param[in] pattern pattern to match against. + * @param[out] fontDescription the resultant fontDescription that matched. + * @param[out] characterSet The character set for that pattern. + * @return true if match found. */ - bool MatchFontDescriptionToPattern( _FcPattern* pattern, Dali::TextAbstraction::FontDescription& fontDescription ); + bool MatchFontDescriptionToPattern( _FcPattern* pattern, Dali::TextAbstraction::FontDescription& fontDescription, _FcCharSet** characterSet ); /** * @brief Creates a font family pattern used to match fonts. @@ -311,7 +346,7 @@ private: * * @return The pattern. */ - _FcPattern* CreateFontFamilyPattern( const FontDescription& fontDescription ); + _FcPattern* CreateFontFamilyPattern( const FontDescription& fontDescription ) const; /** * Retrieves the fonts present in the platform. @@ -347,33 +382,32 @@ private: * * @param[in] path The path to the font file name. * @param[in] requestedPointSize The requested point size. - * @param[in] actualPointSize The actual point size (for color emojis). * @param[in] faceIndex A face index. * @param[in] cacheDescription Whether to cache the font description. * - * @return The font id. + * @return The font identifier. */ FontId CreateFont( const FontPath& path, PointSize26Dot6 requestedPointSize, - PointSize26Dot6 actualPointSize, FaceIndex faceIndex, bool cacheDescription ); /** + * @brief Copy the FreeType bitmap to the given buffer. * - * @param[in] destBitmap - * @param[in] srcBitmap + * @param[out] data The bitmap data. + * @param[in] srcBitmap The FreeType bitmap. */ - void ConvertBitmap( PixelData& destBitmap, FT_Bitmap srcBitmap ); + void ConvertBitmap( TextAbstraction::FontClient::GlyphBufferData& data, FT_Bitmap srcBitmap ); /** * @brief Finds in the cache if there is a triplet with the path to the font file name, the font point size and the face index. - * If there is one , if writes the font id in the param @p fontId. + * If there is one , if writes the font identifier in the param @p fontId. * * @param[in] path Path to the font file name. * @param[in] requestedPointSize The font point size. * @param[in] faceIndex The face index. - * @param[out] fontId The font id. + * @param[out] fontId The font identifier. * * @return @e true if there triplet is found. */ @@ -396,17 +430,19 @@ private: * * @param[in] fontDescription The font to validate. * @param[out] A valid pointer to a font list, or NULL if not found. + * @param[out] characterSetList A valid pointer to a character set list, or NULL if not found. */ bool FindFallbackFontList( const FontDescription& fontDescription, - FontList*& fontList ); + FontList*& fontList, + CharacterSetList*& characterSetList ); /** - * @brief Finds in the cache a pair 'validated font id and font point size'. - * If there is one it writes the font id in the param @p fontId. + * @brief Finds in the cache a pair 'validated font identifier and font point size'. + * If there is one it writes the font identifier in the param @p fontId. * * @param[in] validatedFontId Index to the vector with font descriptions. * @param[in] requestedPointSize The font point size. - * @param[out] fontId The font id. + * @param[out] fontId The font identifier. * * @return @e true if the pair is found. */ @@ -428,8 +464,9 @@ private: * * @param[in] fontDescription A font description. * @param[out] fontList A list of the fonts which are a close match for fontDescription. + * @param[out] characterSetList A list of the character sets which are a close match for fontDescription. */ - void SetFontList( const FontDescription& fontDescription, FontList& fontList ); + void SetFontList( const FontDescription& fontDescription, FontList& fontList, CharacterSetList& characterSetList ); /** * Caches a font path. @@ -441,6 +478,15 @@ private: */ void CacheFontPath( FT_Face ftFace, FontId id, PointSize26Dot6 requestedPointSize, const FontPath& path ); + /** + * @brief Creates a character set from a given font's @p description. + * + * @param[in] description The font's description. + * + * @return A character set. + */ + _FcCharSet* CreateCharacterSetFromDescription( const FontDescription& description ) const; + private: // Declared private and left undefined to avoid copies. @@ -459,13 +505,15 @@ private: FontList mSystemFonts; ///< Cached system fonts. FontList mDefaultFonts; ///< Cached default fonts. + CharacterSetList mDefaultFontCharacterSets; std::vector mFallbackCache; ///< Cached fallback font lists. - std::vector mFontCache; ///< Caches the FreeType face and font metrics of the triplet 'path to the font file name, font point size and face index'. + std::vector mFontCache; ///< Caches the FreeType face and font metrics of the triplet 'path to the font file name, font point size and face index'. std::vector mValidatedFontCache; ///< Caches indices to the vector of font descriptions for a given font. FontList mFontDescriptionCache; ///< Caches font descriptions for the validated font. - std::vector mFontIdCache; ///< Caches font ids for the pairs of font point size and the index to the vector with font descriptions of the validated fonts. + CharacterSetList mCharacterSetCache; ///< Caches character set lists for the validated font. + std::vector mFontIdCache; ///< Caches font identifiers for the pairs of font point size and the index to the vector with font descriptions of the validated fonts. VectorFontCache* mVectorFontCache; ///< Separate cache for vector data blobs etc. @@ -480,4 +528,4 @@ private: } // namespace Dali -#endif // __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H__ +#endif // DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H