return mPlugin->CreateBitmap( fontId, glyphIndex );
}
+const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 pointSize )
+{
+ CreatePlugin();
+
+ return mPlugin->GetEllipsisGlyph( pointSize );
+}
+
void FontClient::CreatePlugin()
{
if( !mPlugin )
GlyphIndex GetGlyphIndex( FontId fontId, Character charcode );
/**
- * @copydoc Dali::FontClient::CreateMetrics()
+ * @copydoc Dali::FontClient::GetGlyphMetrics()
*/
bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
*/
BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
+ /**
+ * @copydoc Dali::FontClient::GetEllipsisGlyph()
+ */
+ const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize );
+
private:
/**
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/text-abstraction/glyph-info.h>
#include <dali/integration-api/debug.h>
// EXTERNAL INCLUDES
const std::string FONT_FORMAT( "TrueType" );
const std::string DEFAULT_FONT_FAMILY_NAME( "Tizen" );
const std::string DEFAULT_FONT_STYLE( "Regular" );
+
+const uint32_t ELLIPSIS_CHARACTER = 0x2026;
}
using Dali::Vector;
mFontCache(),
mValidatedFontCache(),
mFontDescriptionCache( 1u ),
- mFontIdCache()
+ mFontIdCache(),
+ mEllipsisCache()
{
int error = FT_Init_FreeType( &mFreeTypeLibrary );
if( FT_Err_Ok != error )
return bitmap;
}
+const GlyphInfo& FontClient::Plugin::GetEllipsisGlyph( PointSize26Dot6 pointSize )
+{
+ // First look into the cache if there is an ellipsis glyph for the requested point size.
+ for( Vector<EllipsisItem>::ConstIterator it = mEllipsisCache.Begin(),
+ endIt = mEllipsisCache.End();
+ it != endIt;
+ ++it )
+ {
+ const EllipsisItem& item = *it;
+
+ if( fabsf( item.size - pointSize ) < Math::MACHINE_EPSILON_1000 )
+ {
+ // Use the glyph in the cache.
+ return item.glyph;
+ }
+ }
+
+ // No glyph has been found. Create one.
+ mEllipsisCache.PushBack( EllipsisItem() );
+ EllipsisItem& item = *( mEllipsisCache.End() - 1u );
+
+ item.size = pointSize;
+
+ // Find a font for the ellipsis glyph.
+ item.glyph.fontId = FindDefaultFont( ELLIPSIS_CHARACTER,
+ pointSize,
+ false );
+
+ // Set the character index to access the glyph inside the font.
+ item.glyph.index = FT_Get_Char_Index( mFontCache[item.glyph.fontId-1].mFreeTypeFace,
+ ELLIPSIS_CHARACTER );
+
+ GetGlyphMetrics( &item.glyph, 1u, true );
+
+ return item.glyph;
+}
+
void FontClient::Plugin::InitSystemFonts()
{
FcFontSet* fontSet = GetFcFontSet();
// INTERNAL INCLUDES
#include <dali/public-api/text-abstraction/font-metrics.h>
+#include <dali/public-api/text-abstraction/glyph-info.h>
#include <dali/internal/text-abstraction/font-client-impl.h>
// EXTERNAL INCLUDES
bool mIsFixedSizeBitmap; ///< Whether the font has fixed size bitmaps.
};
+ struct EllipsisItem
+ {
+ PointSize26Dot6 size;
+ GlyphInfo glyph;
+ };
+
/**
* Constructor.
*
GlyphIndex GetGlyphIndex( FontId fontId, Character charcode );
/**
- * @copydoc Dali::FontClient::CreateMetrics()
+ * @copydoc Dali::FontClient::GetGlyphMetrics()
*/
bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
*/
BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
+ /**
+ * @copydoc Dali::FontClient::GetEllipsisGlyph()
+ */
+ const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize );
+
private:
/**
std::vector<FontDescriptionCacheItem> mValidatedFontCache; ///< Caches indices to the vector of font descriptions for a given 'font family name, font style'.
FontList mFontDescriptionCache; ///< Caches font descriptions for the validated font family name and font style pairs.
std::vector<FontIdCacheItem> mFontIdCache; ///< Caches font ids for the pairs of font point size and the index to the vector with font descriptions of the validated fonts.
+
+ Vector<EllipsisItem> mEllipsisCache; ///< Caches ellipsis glyphs for a particular point size.
};
} // namespace Internal
faceIndex );
}
-void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
+bool FontClient::IsScalable( const FontPath& path )
{
- GetImplementation(*this).GetFontMetrics( fontId, metrics );
+ return GetImplementation(*this).IsScalable( path );;
}
-GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
+bool FontClient::IsScalable( const FontFamily& fontFamily, const FontStyle& style )
{
- return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
+ return GetImplementation(*this).IsScalable( fontFamily, style );
}
-bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal )
+void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
{
- return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal );
+ GetImplementation(*this).GetFixedSizes( path, sizes );
}
-BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
+void FontClient::GetFixedSizes( const FontFamily& fontFamily,
+ const FontStyle& style,
+ Dali::Vector< PointSize26Dot6 >& sizes )
{
- return GetImplementation(*this).CreateBitmap( fontId, glyphIndex );
+ GetImplementation(*this).GetFixedSizes( fontFamily, style, sizes );
}
-bool FontClient::IsScalable( const FontPath& path )
+void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
{
- return GetImplementation(*this).IsScalable( path );;
+ GetImplementation(*this).GetFontMetrics( fontId, metrics );
}
-bool FontClient::IsScalable( const FontFamily& fontFamily, const FontStyle& style )
+GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
{
- return GetImplementation(*this).IsScalable( fontFamily, style );
+ return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
}
-void FontClient::GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes )
+bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal )
{
- GetImplementation(*this).GetFixedSizes( path, sizes );
+ return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal );
}
-void FontClient::GetFixedSizes( const FontFamily& fontFamily,
- const FontStyle& style,
- Dali::Vector< PointSize26Dot6 >& sizes )
+BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
{
- GetImplementation(*this).GetFixedSizes( fontFamily, style, sizes );
+ return GetImplementation(*this).CreateBitmap( fontId, glyphIndex );
+}
+
+const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 pointSize )
+{
+ return GetImplementation(*this).GetEllipsisGlyph( pointSize );
}
FontClient::FontClient( Internal::FontClient* internal )
*/
BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex );
+ /**
+ * @brief Retrieves the ellipsis glyph for a requested point size.
+ *
+ * @param[in] pointSize The requested point size.
+ *
+ * @return The ellipsis glyph.
+ */
+ const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize );
+
public: // Not intended for application developers
/**
* @brief This constructor is used by FontClient::Get().