X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=text%2Fdali%2Fdevel-api%2Ftext-abstraction%2Ffont-client.h;h=cf0c0b109ad739d5082b881ca06b411e8f68dff7;hb=e73fcc5f736570476070b8a46d2e62663f03ef63;hp=f069bd3582d7cbf4a0c30f1fce87cb599e35e5db;hpb=5a9caec92927aab9cbc40f4f9b81a7fde8f612e9;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 f069bd3..cf0c0b1 100644 --- a/text/dali/devel-api/text-abstraction/font-client.h +++ b/text/dali/devel-api/text-abstraction/font-client.h @@ -1,8 +1,8 @@ -#ifndef __DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_H__ -#define __DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_H__ +#ifndef DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_H +#define DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_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. @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -63,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: /** @@ -122,81 +146,129 @@ public: void GetDpi( unsigned int& horizontalDpi, unsigned int& verticalDpi ); /** - * Set the default font family and its style that should be used by the font client. + * @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. * - * @param[in] fontFamilyName The default name of the font's family. - * @param[in] fontStyle The default font's style. + * @post Previously cached system defaults are removed. */ - void SetDefaultFontFamily( const std::string& fontFamilyName, - const std::string& fontStyle ); + void ResetSystemDefaults(); /** * @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. + * + * @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 Find an appropriate font for displaying a UTF-32 character. + * @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] pointSize 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] requestedPointSize The point size in 26.6 fractional points; the default point size is 12*64. + * @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 pointSize = DEFAULT_POINT_SIZE, + PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE, bool preferColor = false ); /** + * @brief Find a fallback-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] 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 @e true if a color font is preferred. + * + * @return A valid font identifier, or zero if the font does not exist. + */ + FontId FindFallbackFont( Character charcode, + const FontDescription& preferredFontDescription, + PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE, + bool preferColor = false ); + + /** * @brief Retrieve the unique identifier for a font. * * @param[in] path The path to a font file. - * @param[in] pointSize The point size in 26.6 fractional points; the default point size is 12*64. + * @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 pointSize = DEFAULT_POINT_SIZE, FaceIndex faceIndex = 0 ); + 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. * - * @param[in] fontFamily The font family name. - * @param[in] fontStyle The font style. - * @param[in] pointSize The point size in 26.6 fractional points; the default point size is 12*64. + * @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 FontFamily& fontFamily, - const FontStyle& fontStyle, - PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE, + FontId GetFontId( const FontDescription& preferredFontDescription, + PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE, FaceIndex faceIndex = 0 ); /** @@ -210,11 +282,13 @@ public: /** * @brief Check to see if a font is scalable. * - * @param[in] fontFamily The font family name. - * @param[in] style The font style. + * @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. + * * @return true if scalable */ - bool IsScalable( const FontFamily& fontFamily, const FontStyle& style ); + bool IsScalable( const FontDescription& fontDescription ); /** * @brief Get a list of sizes available for a fixed size font. @@ -227,12 +301,12 @@ public: /** * @brief Get a list of sizes available for a fixed size font. * - * @param[in] fontFamily The font family name. - * @param[in] style The font style. + * @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[out] sizes A list of the available sizes, if no sizes available will return empty. */ - void GetFixedSizes( const FontFamily& fontFamily, - const FontStyle& style, + void GetFixedSizes( const FontDescription& fontDescription, Dali::Vector< PointSize26Dot6 >& sizes ); //////////////////////////////////////// @@ -242,17 +316,17 @@ 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. - * @param[in] maxFixedSize The metrics for fixed-size fonts will be down-scaled, when exceeding this maximum value in pixels. */ - void GetFontMetrics( FontId fontId, FontMetrics& metrics, int maxFixedSize = 0 ); + void GetFontMetrics( FontId fontId, FontMetrics& metrics ); /** * @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 ); @@ -261,32 +335,84 @@ 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). - * @param[in] maxFixedSize The metrics for fixed-size fonts will be down-scaled, when exceeding this maximum value in pixels. - * @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, bool horizontal = true, int maxFixedSize = 0 ); + bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal = true ); /** - * @brief Render a bitmap representation of a glyph. + * @brief Create a bitmap representation of a glyph. + * + * @note The caller is responsible for deallocating the bitmap data @p data.buffer using delete[]. * - * @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] data The bitmap data. + * @param[in] outlineWidth The width of the glyph outline in pixels. + */ + void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, 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. */ - BufferImage 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 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. + * @param[out] nominalWidth The width of the blob. + * @param[out] nominalHeight The height of the blob. + */ + void CreateVectorBlob( FontId fontId, + GlyphIndex glyphIndex, + VectorBlob*& blob, + unsigned int& blobLength, + unsigned int& nominalWidth, + unsigned int& nominalHeight ); /** * @brief Retrieves the ellipsis glyph for a requested point size. * - * @param[in] pointSize The requested point size. + * @param[in] requestedPointSize The requested point size. * * @return The ellipsis glyph. */ - const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize ); + 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 char* path ); public: // Not intended for application developers /** @@ -301,4 +427,4 @@ public: // Not intended for application developers } // namespace Dali -#endif // __DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_H__ +#endif // DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_H