-#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) 2016 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.
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/buffer-image.h>
+#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/object/base-handle.h>
#include <dali/devel-api/text-abstraction/font-list.h>
#include <dali/devel-api/text-abstraction/text-abstraction-definitions.h>
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 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.
*/
*
* 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 );
/**
*
* 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] 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] 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( FontId preferredFont,
- Character charcode,
- PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE,
+ 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,
+ 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] 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 FontDescription& fontDescription,
- PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE,
+ 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.
- * @param[in] desiredFixedSize The metrics for fixed-size fonts will be scaled to this desired size (in pixels).
*/
- void GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize = 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 );
* @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] desiredFixedSize The metrics for fixed-size fonts will be scaled to this desired size (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, GlyphType type, bool horizontal = true );
+
+ /**
+ * @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 identifier of the font.
+ * @param[in] glyphIndex The index of a glyph within the specified font.
+ * @param[out] data The bitmap data.
*/
- bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal = true, int desiredFixedSize = 0 );
+ void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, GlyphBufferData& data );
/**
* @brief Create a bitmap representation of a glyph.
*
- * @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.
+ *
* @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 );
/**
* @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.
/**
* @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 );
public: // Not intended for application developers
/**
} // namespace Dali
-#endif // __DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_H__
+#endif // DALI_PLATFORM_TEXT_ABSTRACTION_FONT_CLIENT_H