X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=text%2Fdali%2Finternal%2Ftext-abstraction%2Ffont-client-plugin-impl.h;h=936a159fdb87bf00c557a3d56ad7de0013974597;hb=refs%2Fchanges%2F43%2F153543%2F1;hp=768d68fdf407437e1a38fea2eb49171c5dd92bd4;hpb=6c71453197486ea9766c64a840899f5ed7d41415;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 768d68f..936a159 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. }; /** @@ -111,17 +116,20 @@ struct FontClient::Plugin FaceIndex face, const FontMetrics& metrics, float fixedWidth, - float fixedHeight ); + 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 @@ -189,9 +197,15 @@ struct FontClient::Plugin PointSize26Dot6 GetPointSize( FontId id ); /** + * @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. @@ -199,6 +213,7 @@ struct FontClient::Plugin * @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 ); @@ -221,23 +236,18 @@ struct FontClient::Plugin /** * @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 ); /** - * @see Dali::TextAbstraction::FontClient::GetFontId( const FontDescription& preferredFontDescription, 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. + * @copydoc Dali::TextAbstraction::FontClient::GetFontId( const FontDescription& preferredFontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex ) */ FontId GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, - PointSize26Dot6 actualPointSize, FaceIndex faceIndex ); /** @@ -287,14 +297,14 @@ struct FontClient::Plugin bool GetVectorMetrics( GlyphInfo* array, uint32_t size, bool horizontal ); /** - * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data ) + * @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 ); + void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth ); /** - * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex ) + * @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::TextAbstraction::FontClient::CreateVectorBlob() @@ -311,22 +321,28 @@ struct FontClient::Plugin */ bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ); + /** + * @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory() + */ + bool AddCustomFontDirectory( const char* path ); + 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. @@ -335,7 +351,7 @@ private: * * @return The pattern. */ - _FcPattern* CreateFontFamilyPattern( const FontDescription& fontDescription ); + _FcPattern* CreateFontFamilyPattern( const FontDescription& fontDescription ) const; /** * Retrieves the fonts present in the platform. @@ -371,7 +387,6 @@ 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. * @@ -379,7 +394,6 @@ private: */ FontId CreateFont( const FontPath& path, PointSize26Dot6 requestedPointSize, - PointSize26Dot6 actualPointSize, FaceIndex faceIndex, bool cacheDescription ); @@ -421,9 +435,11 @@ 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 identifier and font point size'. @@ -453,8 +469,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. @@ -466,6 +483,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. @@ -484,12 +510,14 @@ 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 mValidatedFontCache; ///< Caches indices to the vector of font descriptions for a given font. FontList mFontDescriptionCache; ///< Caches font descriptions for the validated font. + 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. @@ -505,4 +533,4 @@ private: } // namespace Dali -#endif // __DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H__ +#endif // DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H