#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.
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:
/**
////////////////////////////////////////
/**
+ * @brief Clear all caches in FontClient
+ *
+ */
+ void ClearCache();
+
+ /**
* @brief Set the DPI of the target window.
*
* @note Multiple windows are not currently supported.
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.
/**
* @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,
*
* 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 );
* @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.
- *
- * @note It the font style is not empty, it will be used instead the font weight and font slant slant.
+ * @brief Retrieves a unique font identifier for a given description.
*
- * @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 );
/**
* @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 );
/**
* @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 );
* @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[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.
*/
- 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.
*/
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().