X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=text%2Fdali%2Fdevel-api%2Ftext-abstraction%2Ffont-client.h;h=c3a30fa6a0e1bda3d6cbb95838160365cad39a69;hb=01a4891a7625e7bccef3e40fa5d7fe4115bfb73f;hp=326622cb68a3e8316a9c37465cefee1ba5c22fb5;hpb=ad5f138178f0879ec24c1f0eac5c18793b8879ce;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/text/dali/devel-api/text-abstraction/font-client.h b/text/dali/devel-api/text-abstraction/font-client.h index 326622c..c3a30fa 100644 --- a/text/dali/devel-api/text-abstraction/font-client.h +++ b/text/dali/devel-api/text-abstraction/font-client.h @@ -2,7 +2,7 @@ #define DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_H /* - * Copyright (c) 2016 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. @@ -64,6 +64,29 @@ class DALI_IMPORT_API FontClient : public BaseHandle public: static const PointSize26Dot6 DEFAULT_POINT_SIZE; ///< The default point size. + /** + * @brief Struct used to retrieve the glyph's bitmap. + */ + struct GlyphBufferData + { + /** + * @brief Constructor. + * + * Initializes struct members to their defaults. + */ + GlyphBufferData(); + + /** + * @brief Destructor. + */ + ~GlyphBufferData(); + + unsigned char* buffer; ///< The glyph's bitmap buffer data. + unsigned int width; ///< The width of the bitmap. + unsigned int height; ///< The height of the bitmap. + Pixel::Format format; ///< The pixel's format of the bitmap. + }; + public: /** @@ -105,6 +128,12 @@ public: //////////////////////////////////////// /** + * @brief Clear all caches in FontClient + * + */ + void ClearCache(); + + /** * @brief Set the DPI of the target window. * * @note Multiple windows are not currently supported. @@ -123,6 +152,15 @@ public: void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi ); /** + * @brief Called by Dali to retrieve the default font size for the platform. + * + * This is an accessibility size, which is mapped to a UI Control specific point-size in stylesheets. + * For example if zero the smallest size, this could potentially map to TextLabel point-size 8. + * @return The default font size. + */ + int GetDefaultFontSize(); + + /** * @brief Called when the user changes the system defaults. * * @post Previously cached system defaults are removed. @@ -132,50 +170,62 @@ public: /** * @brief Retrieve the list of default fonts supported by the system. * - * @param[out] defaultFonts A list of default font paths, family & style strings. + * @param[out] defaultFonts A list of default font paths, family, width, weight and slant. */ void GetDefaultFonts( FontList& defaultFonts ); /** - * @brief Retrieve the active default font from the system + * @brief Retrieve the active default font from the system. * - * @param[out] fontDescription font structure describing the default font + * @param[out] fontDescription font structure describing the default font. */ void GetDefaultPlatformFontDescription( FontDescription& fontDescription ); /** * @brief Retrieve the list of fonts supported by the system. * - * @param[out] systemFonts A list of font paths, family & style strings. + * @param[out] systemFonts A list of font paths, family, width, weight and slant. */ void GetSystemFonts( FontList& systemFonts ); /** * @brief Retrieves the font description of a given font @p id. * - * @param[in] id The font id. - * @param[out] fontDescription The path, family & style describing the font. + * @param[in] id The font identifier. + * @param[out] fontDescription The path, family & style (width, weight and slant) describing the font. */ void GetDescription( FontId id, FontDescription& fontDescription ); /** * @brief Retrieves the font point size of a given font @p id. * - * @param[in] id The font id. + * @param[in] id The font identifier. * * @return The point size in 26.6 fractional points. */ PointSize26Dot6 GetPointSize( FontId id ); /** + * @brief Whether the given @p character is supported by the font. + * + * @param[in] fontId The id of the font. + * @param[in] character The character. + * + * @return @e true if the character is supported by the font. + */ + bool IsCharacterSupportedByFont( FontId fontId, Character character ); + + /** * @brief Find the default font for displaying a UTF-32 character. * * This is useful when localised strings are provided for multiple languages * i.e. when a single default font does not work for all languages. + * * @param[in] charcode The character for which a font is needed. * @param[in] requestedPointSize The point size in 26.6 fractional points; the default point size is 12*64. - * @param[in] preferColor True if a color font is preferred. - * @return A valid font ID, or zero if the font does not exist. + * @param[in] preferColor @e true if a color font is preferred. + * + * @return A valid font identifier, or zero if the font does not exist. */ FontId FindDefaultFont( Character charcode, PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE, @@ -186,15 +236,17 @@ public: * * This is useful when localised strings are provided for multiple languages * i.e. when a single default font does not work for all languages. - * @param[in] preferredFont The preferred font which may not provide a glyph for charcode. - * The fallback-font will be the closest match to preferredFont, which does support the required glyph. + * * @param[in] charcode The character for which a font is needed. + * @param[in] preferredFontDescription Description of the preferred font which may not provide a glyph for @p charcode. + * The fallback-font will be the closest match to @p preferredFontDescription, which does support the required glyph. * @param[in] requestedPointSize The point size in 26.6 fractional points; the default point size is 12*64. - * @param[in] preferColor True if a color font is preferred. - * @return A valid font ID, or zero if the font does not exist. + * @param[in] preferColor @e true if a color font is preferred. + * + * @return A valid font identifier, or zero if the font does not exist. */ - FontId FindFallbackFont( FontId preferredFont, - Character charcode, + FontId FindFallbackFont( Character charcode, + const FontDescription& preferredFontDescription, PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE, bool preferColor = false ); @@ -204,23 +256,24 @@ public: * @param[in] path The path to a font file. * @param[in] requestedPointSize The point size in 26.6 fractional points; the default point size is 12*64. * @param[in] faceIndex The index of the font face (optional). - * @return A valid font ID, or zero if the font does not exist. + * + * @return A valid font identifier, or zero if the font does not exist. */ FontId GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE, FaceIndex faceIndex = 0 ); /** - * @brief Retrieve the unique identifier for a font. + * @brief Retrieves a unique font identifier for a given description. * - * @note It the font style is not empty, it will be used instead the font weight and font slant slant. - * - * @param[in] fontDescription A font description. + * @param[in] preferredFontDescription Description of the preferred font. + * The font will be the closest match to @p preferredFontDescription. * @param[in] requestedPointSize The point size in 26.6 fractional points; the default point size is 12*64. * @param[in] faceIndex The index of the font face (optional). - * @return A valid font ID, or zero if the font does not exist. + * + * @return A valid font identifier, or zero if no font is found. */ - FontId GetFontId( const FontDescription& fontDescription, + FontId GetFontId( const FontDescription& preferredFontDescription, PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE, FaceIndex faceIndex = 0 ); @@ -269,7 +322,7 @@ public: /** * @brief Query the metrics for a font. * - * @param[in] fontId The ID of the font for the required glyph. + * @param[in] fontId The identifier of the font for the required glyph. * @param[out] metrics The font metrics. */ void GetFontMetrics( FontId fontId, FontMetrics& metrics ); @@ -277,8 +330,9 @@ public: /** * @brief Retrieve the glyph index for a UTF-32 character code. * - * @param[in] fontId The ID of the font for the required glyph. + * @param[in] fontId The identifier of the font for the required glyph. * @param[in] charcode The UTF-32 character code. + * * @return The glyph index, or zero if the character code is undefined. */ GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ); @@ -287,29 +341,46 @@ public: * @brief Retrieve the metrics for a series of glyphs. * * @param[in,out] array An array of glyph-info structures with initialized FontId & GlyphIndex values. - * It may contain the advance and an offset set into the bearing from the shaping tool. - * On return, the glyph's size value will be initialized. The bearing value will be updated by adding the font's glyph bearing to the one set by the shaping tool. + * It may contain the advance and an offset set into the bearing from the shaping tool. + * On return, the glyph's size value will be initialized. The bearing value will be updated by adding the font's glyph bearing to the one set by the shaping tool. * @param[in] size The size of the array. * @param[in] type The type of glyphs used for rendering; either bitmaps or vectors. * @param[in] horizontal True for horizontal layouts (set to false for vertical layouting). - * @return True if all of the requested metrics were found. + * + * @return @e true if all of the requested metrics were found. */ bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal = true ); /** * @brief Create a bitmap representation of a glyph. * - * @param[in] fontId The ID of the font. + * @note The caller is responsible for deallocating the bitmap data @p data.buffer using delete[]. + * + * @param[in] fontId The identifier of the font. + * @param[in] glyphIndex The index of a glyph within the specified font. + * @param[in] softwareItalic Whether glyph needs software support to draw italic style. + * @param[in] softwareBold Whether glyph needs software support to draw bold style. + * @param[out] data The bitmap data. + * @param[in] outlineWidth The width of the glyph outline in pixels. + */ + void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool softwareItalic, bool softwareBold, GlyphBufferData& data, int outlineWidth ); + + /** + * @brief Create a bitmap representation of a glyph. + * + * @param[in] fontId The identifier of the font. * @param[in] glyphIndex The index of a glyph within the specified font. + * @param[in] outlineWidth The width of the glyph outline in pixels. + * * @return A valid BufferImage, or an empty handle if the glyph could not be rendered. */ - PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex ); + PixelData CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth ); /** * @brief Create a vector representation of a glyph. * * @note This feature requires highp shader support and is not available on all platforms - * @param[in] fontId The ID of the font. + * @param[in] fontId The identifier of the font. * @param[in] glyphIndex The index of a glyph within the specified font. * @param[out] blob A blob of data; this is owned by FontClient and should be copied by the caller of CreateVectorData(). * @param[out] blobLength The length of the blob data, or zero if the blob creation failed. @@ -332,6 +403,25 @@ public: */ const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize ); + /** + * @brief Whether the given glyph @p glyphIndex is a color glyph. + * + * @param[in] fontId The font id. + * @param[in] glyphIndex The glyph index. + * + * @return @e true if the glyph is a color one. + */ + bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex ); + + /** + * @brief Add custom fonts directory + * + * @param[in] path to the fonts directory + * + * @return true if the fonts can be added. + */ + bool AddCustomFontDirectory( const FontPath& path ); + public: // Not intended for application developers /** * @brief This constructor is used by FontClient::Get().