return GetImplementation(*this).GetPointSize( id );
}
-FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor )
+FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor )
{
- return GetImplementation(*this).FindDefaultFont( charcode, pointSize, preferColor );
+ return GetImplementation(*this).FindDefaultFont( charcode, requestedPointSize, preferColor );
}
-FontId FontClient::FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 pointSize, bool preferColor )
+FontId FontClient::FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor )
{
- return GetImplementation(*this).FindFallbackFont( preferredFont, charcode, pointSize, preferColor );
+ return GetImplementation(*this).FindFallbackFont( preferredFont, charcode, requestedPointSize, preferColor );
}
-FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
+FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
{
- return GetImplementation(*this).GetFontId( path, pointSize, faceIndex );
+ return GetImplementation(*this).GetFontId( path, requestedPointSize, faceIndex );
}
FontId FontClient::GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FaceIndex faceIndex )
{
return GetImplementation(*this).GetFontId( fontDescription,
- pointSize,
+ requestedPointSize,
faceIndex );
}
GetImplementation(*this).GetFixedSizes( fontDescription, sizes );
}
-void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize )
+void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
{
- GetImplementation(*this).GetFontMetrics( fontId, metrics, desiredFixedSize );
+ GetImplementation(*this).GetFontMetrics( fontId, metrics );
}
GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
return GetImplementation(*this).GetGlyphIndex( fontId, charcode );
}
-bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal, int desiredFixedSize )
+bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
{
- return GetImplementation(*this).GetGlyphMetrics( array, size, type, horizontal, desiredFixedSize );
+ return GetImplementation(*this).GetGlyphMetrics( array, size, type, horizontal );
}
BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
GetImplementation(*this).CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
}
-const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 pointSize )
+const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
{
- return GetImplementation(*this).GetEllipsisGlyph( pointSize );
+ return GetImplementation(*this).GetEllipsisGlyph( requestedPointSize );
}
FontClient::FontClient( Internal::FontClient* internal )
* 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] 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.
*/
FontId FindDefaultFont( Character charcode,
- PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE,
+ PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE,
bool preferColor = false );
/**
* @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] 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.
*/
FontId FindFallbackFont( FontId preferredFont,
Character charcode,
- PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE,
+ 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.
*/
FontId GetFontId( const FontPath& path,
- PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE,
+ PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE,
FaceIndex faceIndex = 0 );
/**
* @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] 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.
*/
FontId GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 pointSize = DEFAULT_POINT_SIZE,
+ PointSize26Dot6 requestedPointSize = DEFAULT_POINT_SIZE,
FaceIndex faceIndex = 0 );
/**
*
* @param[in] fontId The ID 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] 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.
*/
- bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal = true, int desiredFixedSize = 0 );
+ bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal = true );
/**
* @brief Create a bitmap representation of a glyph.
/**
* @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 );
public: // Not intended for application developers
/**
mPlugin->GetSystemFonts( systemFonts );
}
-FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor )
+FontId FontClient::FindDefaultFont( Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor )
{
CreatePlugin();
- return mPlugin->FindDefaultFont( charcode, pointSize, preferColor );
+ return mPlugin->FindDefaultFont( charcode, requestedPointSize, preferColor );
}
-FontId FontClient::FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 pointSize, bool preferColor )
+FontId FontClient::FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor )
{
CreatePlugin();
- return mPlugin->FindFallbackFont( preferredFont, charcode, pointSize, preferColor );
+ return mPlugin->FindFallbackFont( preferredFont, charcode, requestedPointSize, preferColor );
}
bool FontClient::IsScalable( const FontPath& path )
mPlugin->GetFixedSizes( fontDescription, sizes );
}
-FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
+FontId FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
{
CreatePlugin();
- return mPlugin->GetFontId( path, pointSize, faceIndex );
+ return mPlugin->GetFontId( path,
+ requestedPointSize,
+ requestedPointSize,
+ faceIndex );
}
FontId FontClient::GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FaceIndex faceIndex )
{
CreatePlugin();
return mPlugin->GetFontId( fontDescription,
- pointSize,
+ requestedPointSize,
+ requestedPointSize,
faceIndex );
}
-void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize )
+void FontClient::GetFontMetrics( FontId fontId, FontMetrics& metrics )
{
CreatePlugin();
- return mPlugin->GetFontMetrics( fontId, metrics, desiredFixedSize );
+ return mPlugin->GetFontMetrics( fontId, metrics );
}
GlyphIndex FontClient::GetGlyphIndex( FontId fontId, Character charcode )
return mPlugin->GetGlyphIndex( fontId, charcode );
}
-bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal, int desiredFixedSize )
+bool FontClient::GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal )
{
CreatePlugin();
- return mPlugin->GetGlyphMetrics( array, size, type, horizontal, desiredFixedSize );
+ return mPlugin->GetGlyphMetrics( array, size, type, horizontal );
}
BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
return mPlugin->CreateVectorBlob( fontId, glyphIndex, blob, blobLength, nominalWidth, nominalHeight );
}
-const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 pointSize )
+const GlyphInfo& FontClient::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
{
CreatePlugin();
- return mPlugin->GetEllipsisGlyph( pointSize );
+ return mPlugin->GetEllipsisGlyph( requestedPointSize );
}
void FontClient::CreatePlugin()
/**
* @copydoc Dali::FontClient::FindDefaultFont()
*/
- FontId FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor );
+ FontId FindDefaultFont( Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor );
/**
* @copydoc Dali::FontClient::FindFallbackFont()
*/
- FontId FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 pointSize, bool preferColor );
+ FontId FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor );
/**
- * @copydoc Dali::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
+ * @copydoc Dali::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
*/
- FontId GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex );
+ FontId GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex );
/**
- * @copydoc Dali::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 pointSize, FaceIndex faceIndex )
+ * @copydoc Dali::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
*/
FontId GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FaceIndex faceIndex );
/**
/**
* @copydoc Dali::FontClient::GetFontMetrics()
*/
- void GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize );
+ void GetFontMetrics( FontId fontId, FontMetrics& metrics );
/**
* @copydoc Dali::FontClient::GetGlyphIndex()
/**
* @copydoc Dali::FontClient::GetGlyphMetrics()
*/
- bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal, int desiredFixedSize );
+ bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal );
/**
* @copydoc Dali::FontClient::CreateBitmap()
/**
* @copydoc Dali::FontClient::GetEllipsisGlyph()
*/
- const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize );
+ const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize );
private:
* Conversion from Fractional26.6 to float
*/
const float FROM_266 = 1.0f / 64.0f;
+const float POINTS_PER_INCH = 72.f;
const std::string FONT_FORMAT( "TrueType" );
const std::string DEFAULT_FONT_FAMILY_NAME( "Tizen" );
}
FontClient::Plugin::FontIdCacheItem::FontIdCacheItem( FontDescriptionId validatedFontId,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FontId fontId )
: validatedFontId( validatedFontId ),
- pointSize( pointSize ),
+ requestedPointSize( requestedPointSize ),
fontId( fontId )
{
}
FontClient::Plugin::CacheItem::CacheItem( FT_Face ftFace,
const FontPath& path,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FaceIndex face,
const FontMetrics& metrics )
: mFreeTypeFace( ftFace ),
mPath( path ),
- mPointSize( pointSize ),
+ mRequestedPointSize( requestedPointSize ),
mFaceIndex( face ),
mMetrics( metrics ),
mFixedWidthPixels( 0.0f ),
FontClient::Plugin::CacheItem::CacheItem( FT_Face ftFace,
const FontPath& path,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FaceIndex face,
const FontMetrics& metrics,
float fixedWidth,
float fixedHeight )
: mFreeTypeFace( ftFace ),
mPath( path ),
- mPointSize( pointSize ),
+ mRequestedPointSize( requestedPointSize ),
mFaceIndex( face ),
mMetrics( metrics ),
mFixedWidthPixels( fixedWidth ),
if( id > 0u &&
index < mFontCache.size() )
{
- return ( *( mFontCache.begin() + index ) ).mPointSize;
+ return ( *( mFontCache.begin() + index ) ).mRequestedPointSize;
}
else
{
FontId FontClient::Plugin::FindFontForCharacter( const FontList& fontList,
Character charcode,
- PointSize26Dot6 requestedSize,
+ PointSize26Dot6 requestedPointSize,
bool preferColor )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::FindFontForCharacter\n");
GetFixedSizes( description,
fixedSizes );
+ PointSize26Dot6 actualPointSize = requestedPointSize;
+
const Vector< PointSize26Dot6 >::SizeType count = fixedSizes.Count();
+
if( 0 != count )
{
- // If the font is not scalable, pick the largest size <= requestedSize
- PointSize26Dot6 size = fixedSizes[0];
+ // If the font is not scalable, pick the largest size <= requestedPointSize
+ actualPointSize = fixedSizes[0];
for( unsigned int i=1; i<count; ++i )
{
- if( fixedSizes[i] <= requestedSize &&
- fixedSizes[i] > size )
+ if( fixedSizes[i] <= requestedPointSize &&
+ fixedSizes[i] > actualPointSize )
{
- size = fixedSizes[i];
+ actualPointSize = fixedSizes[i];
}
}
- requestedSize = size;
}
fontId = GetFontId( description,
- requestedSize,
+ requestedPointSize,
+ actualPointSize,
0u );
if( preferColor )
}
FontId FontClient::Plugin::FindDefaultFont( Character charcode,
- PointSize26Dot6 requestedSize,
+ PointSize26Dot6 requestedPointSize,
bool preferColor )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::FindDefaultFont DefaultFontsList(%s)\n", (mDefaultFonts.empty()?"empty":"created") );
// Traverse the list of default fonts.
// Check for each default font if supports the character.
- fontId = FindFontForCharacter( mDefaultFonts, charcode, requestedSize, preferColor );
+ fontId = FindFontForCharacter( mDefaultFonts, charcode, requestedPointSize, preferColor );
return fontId;
}
FontId FontClient::Plugin::FindFallbackFont( FontId preferredFont,
Character charcode,
- PointSize26Dot6 requestedSize,
+ PointSize26Dot6 requestedPointSize,
bool preferColor )
{
// The font id to be returned.
if( fontList )
{
- fontId = FindFontForCharacter( *fontList, charcode, requestedSize, preferColor );
+ fontId = FindFontForCharacter( *fontList, charcode, requestedPointSize, preferColor );
}
return fontId;
}
FontId FontClient::Plugin::GetFontId( const FontPath& path,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
+ PointSize26Dot6 actualPointSize,
FaceIndex faceIndex,
bool cacheDescription )
{
if( NULL != mFreeTypeLibrary )
{
FontId foundId(0);
- if( FindFont( path, pointSize, faceIndex, foundId ) )
+ if( FindFont( path, requestedPointSize, faceIndex, foundId ) )
{
id = foundId;
}
else
{
- id = CreateFont( path, pointSize, faceIndex, cacheDescription );
+ id = CreateFont( path, requestedPointSize, actualPointSize, faceIndex, cacheDescription );
}
}
}
FontId FontClient::Plugin::GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
+ PointSize26Dot6 actualPointSize,
FaceIndex faceIndex )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "FontClient::Plugin::GetFontId font family(%s)\n", fontDescription.family.c_str() );
validatedFontId );
}
- // Check if exists a pair 'validatedFontId, pointSize' in the cache.
- if( !FindFont( validatedFontId, pointSize, fontId ) )
+ // Check if exists a pair 'validatedFontId, requestedPointSize' in the cache.
+ if( !FindFont( validatedFontId, requestedPointSize, fontId ) )
{
// Retrieve the font file name path.
const FontDescription& description = *( mFontDescriptionCache.begin() + validatedFontId );
// Retrieve the font id. Do not cache the description as it has been already cached.
fontId = GetFontId( description.path,
- pointSize,
+ requestedPointSize,
+ actualPointSize,
faceIndex,
false );
- // Cache the pair 'validatedFontId, pointSize' to improve the following queries.
+ // Cache the pair 'validatedFontId, requestedPointSize' to improve the following queries.
mFontIdCache.push_back( FontIdCacheItem( validatedFontId,
- pointSize,
+ requestedPointSize,
fontId ) );
}
}
void FontClient::Plugin::GetFontMetrics( FontId fontId,
- FontMetrics& metrics,
- int desiredFixedSize )
+ FontMetrics& metrics )
{
- if( fontId > 0 &&
- fontId-1 < mFontCache.size() )
+ if( ( fontId > 0 ) &&
+ ( fontId - 1u < mFontCache.size() ) )
{
const CacheItem& font = mFontCache[fontId-1];
metrics = font.mMetrics;
// Adjust the metrics if the fixed-size font should be down-scaled
- if( font.mIsFixedSizeBitmap &&
- ( desiredFixedSize > 0 ) )
+ if( font.mIsFixedSizeBitmap )
{
- float scaleFactor = static_cast<float>(desiredFixedSize) / static_cast<float>(font.mFixedHeightPixels);
+ const float desiredFixedSize = static_cast<float>( font.mRequestedPointSize ) * FROM_266 / POINTS_PER_INCH * mDpiVertical;
+
+ if( desiredFixedSize > 0.f )
+ {
+ const float scaleFactor = desiredFixedSize / static_cast<float>( font.mFixedHeightPixels );
- metrics.ascender *= scaleFactor;
- metrics.descender *= scaleFactor;
- metrics.height *= scaleFactor;
- metrics.underlinePosition *= scaleFactor;
- metrics.underlineThickness *= scaleFactor;
+ metrics.ascender = floorf( metrics.ascender * scaleFactor );
+ metrics.descender = floorf( metrics.descender * scaleFactor );
+ metrics.height = floorf( metrics.height * scaleFactor );
+ metrics.underlinePosition = floorf( metrics.underlinePosition * scaleFactor );
+ metrics.underlineThickness = floorf( metrics.underlineThickness * scaleFactor );
+ }
}
}
else
bool FontClient::Plugin::GetGlyphMetrics( GlyphInfo* array,
uint32_t size,
GlyphType type,
- bool horizontal,
- int desiredFixedSize )
+ bool horizontal )
{
if( VECTOR_GLYPH == type )
{
- return GetVectorMetrics( array, size, horizontal, desiredFixedSize );
+ return GetVectorMetrics( array, size, horizontal );
}
- return GetBitmapMetrics( array, size, horizontal, desiredFixedSize );
+ return GetBitmapMetrics( array, size, horizontal );
}
bool FontClient::Plugin::GetBitmapMetrics( GlyphInfo* array,
uint32_t size,
- bool horizontal,
- int desiredFixedSize )
+ bool horizontal )
{
bool success( true );
for( unsigned int i=0; i<size; ++i )
{
- FontId fontId = array[i].fontId;
+ GlyphInfo& glyph = array[i];
+
+ FontId fontId = glyph.fontId;
if( fontId > 0 &&
fontId-1 < mFontCache.size() )
// Check to see if we should be loading a Fixed Size bitmap?
if ( font.mIsFixedSizeBitmap )
{
- int error = FT_Load_Glyph( ftFace, array[i].index, FT_LOAD_COLOR );
+ int error = FT_Load_Glyph( ftFace, glyph.index, FT_LOAD_COLOR );
if ( FT_Err_Ok == error )
{
- array[i].width = font.mFixedWidthPixels;
- array[i].height = font.mFixedHeightPixels;
- array[i].advance = font.mFixedWidthPixels;
- array[i].xBearing = 0.0f;
- array[i].yBearing = font.mFixedHeightPixels;
+ glyph.width = font.mFixedWidthPixels;
+ glyph.height = font.mFixedHeightPixels;
+ glyph.advance = font.mFixedWidthPixels;
+ glyph.xBearing = 0.0f;
+ glyph.yBearing = font.mFixedHeightPixels;
// Adjust the metrics if the fixed-size font should be down-scaled
- if( desiredFixedSize > 0 )
+ const float desiredFixedSize = static_cast<float>( font.mRequestedPointSize ) * FROM_266 / POINTS_PER_INCH * mDpiVertical;
+
+ if( desiredFixedSize > 0.f )
{
- float scaleFactor = static_cast<float>(desiredFixedSize) / static_cast<float>(font.mFixedHeightPixels);
+ const float scaleFactor = desiredFixedSize / static_cast<float>( font.mFixedHeightPixels );
- array[i].width *= scaleFactor;
- array[i].height *= scaleFactor;
- array[i].advance *= scaleFactor;
- array[i].xBearing *= scaleFactor;
- array[i].yBearing *= scaleFactor;
+ glyph.width = floorf( glyph.width * scaleFactor );
+ glyph.height = floorf( glyph.height * scaleFactor );
+ glyph.advance = floorf( glyph.advance * scaleFactor );
+ glyph.xBearing = floorf( glyph.xBearing * scaleFactor );
+ glyph.yBearing = floorf( glyph.yBearing * scaleFactor );
- array[i].scaleFactor = scaleFactor;
+ glyph.scaleFactor = scaleFactor;
}
}
else
else
#endif
{
- int error = FT_Load_Glyph( ftFace, array[i].index, FT_LOAD_DEFAULT );
+ int error = FT_Load_Glyph( ftFace, glyph.index, FT_LOAD_DEFAULT );
if( FT_Err_Ok == error )
{
- array[i].width = static_cast< float >( ftFace->glyph->metrics.width ) * FROM_266;
- array[i].height = static_cast< float >( ftFace->glyph->metrics.height ) * FROM_266 ;
+ glyph.width = static_cast< float >( ftFace->glyph->metrics.width ) * FROM_266;
+ glyph.height = static_cast< float >( ftFace->glyph->metrics.height ) * FROM_266 ;
if( horizontal )
{
- array[i].xBearing += static_cast< float >( ftFace->glyph->metrics.horiBearingX ) * FROM_266;
- array[i].yBearing += static_cast< float >( ftFace->glyph->metrics.horiBearingY ) * FROM_266;
+ glyph.xBearing += static_cast< float >( ftFace->glyph->metrics.horiBearingX ) * FROM_266;
+ glyph.yBearing += static_cast< float >( ftFace->glyph->metrics.horiBearingY ) * FROM_266;
}
else
{
- array[i].xBearing += static_cast< float >( ftFace->glyph->metrics.vertBearingX ) * FROM_266;
- array[i].yBearing += static_cast< float >( ftFace->glyph->metrics.vertBearingY ) * FROM_266;
+ glyph.xBearing += static_cast< float >( ftFace->glyph->metrics.vertBearingX ) * FROM_266;
+ glyph.yBearing += static_cast< float >( ftFace->glyph->metrics.vertBearingY ) * FROM_266;
}
}
else
bool FontClient::Plugin::GetVectorMetrics( GlyphInfo* array,
uint32_t size,
- bool horizontal,
- int desiredFixedSize )
+ bool horizontal )
{
#ifdef ENABLE_VECTOR_BASED_TEXT_RENDERING
bool success( true );
mVectorFontCache->GetGlyphMetrics( font.mVectorFontId, array[i] );
// Vector metrics are in EMs, convert to pixels
- float scale = (static_cast<float>(font.mPointSize)/64.0f) * mDpiVertical/72.0f;
+ const float scale = ( static_cast<float>( font.mRequestedPointSize ) * FROM_266 ) * static_cast<float>( mDpiVertical ) / POINTS_PER_INCH;
array[i].width *= scale;
array[i].height *= scale;
array[i].xBearing *= scale;
#endif
}
-const GlyphInfo& FontClient::Plugin::GetEllipsisGlyph( PointSize26Dot6 pointSize )
+const GlyphInfo& FontClient::Plugin::GetEllipsisGlyph( PointSize26Dot6 requestedPointSize )
{
// First look into the cache if there is an ellipsis glyph for the requested point size.
for( Vector<EllipsisItem>::ConstIterator it = mEllipsisCache.Begin(),
{
const EllipsisItem& item = *it;
- if( fabsf( item.size - pointSize ) < Math::MACHINE_EPSILON_1000 )
+ if( fabsf( item.requestedPointSize - requestedPointSize ) < Math::MACHINE_EPSILON_1000 )
{
// Use the glyph in the cache.
return item.glyph;
mEllipsisCache.PushBack( EllipsisItem() );
EllipsisItem& item = *( mEllipsisCache.End() - 1u );
- item.size = pointSize;
+ item.requestedPointSize = requestedPointSize;
// Find a font for the ellipsis glyph.
item.glyph.fontId = FindDefaultFont( ELLIPSIS_CHARACTER,
- pointSize,
+ requestedPointSize,
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 );
- GetBitmapMetrics( &item.glyph, 1u, true, 0 );
+ GetBitmapMetrics( &item.glyph, 1u, true );
return item.glyph;
}
}
FontId FontClient::Plugin::CreateFont( const FontPath& path,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
+ PointSize26Dot6 actualPointSize,
FaceIndex faceIndex,
bool cacheDescription )
{
// Ensure this size is available
for ( int i = 0; i < ftFace->num_fixed_sizes; ++i )
{
- if ( static_cast<FT_Pos>(pointSize) == ftFace->available_sizes[ i ].size )
+ if ( static_cast<FT_Pos>( actualPointSize ) == ftFace->available_sizes[ i ].size )
{
// Tell Freetype to use this size
error = FT_Select_Size( ftFace, i );
0.0f,
0.0f );
- mFontCache.push_back( CacheItem( ftFace, path, pointSize, faceIndex, metrics, fixedWidth, fixedHeight ) );
+ mFontCache.push_back( CacheItem( ftFace, path, requestedPointSize, faceIndex, metrics, fixedWidth, fixedHeight ) );
id = mFontCache.size();
if( cacheDescription )
{
- CacheFontPath( ftFace, id, pointSize, path );
+ CacheFontPath( ftFace, id, requestedPointSize, path );
}
+
return id;
}
}
sizes << ftFace->available_sizes[ i ].size;
}
DALI_LOG_ERROR( "FreeType Font: %s, does not contain Bitmaps of size: %d. Available sizes are: %s\n",
- path.c_str(), pointSize, sizes.str().c_str() );
+ path.c_str(), actualPointSize, sizes.str().c_str() );
}
else
{
error = FT_Set_Char_Size( ftFace,
0,
- pointSize,
+ actualPointSize,
mDpiHorizontal,
mDpiVertical );
static_cast< float >( ftFace->underline_position ) * FROM_266,
static_cast< float >( ftFace->underline_thickness ) * FROM_266 );
- mFontCache.push_back( CacheItem( ftFace, path, pointSize, faceIndex, metrics ) );
+ mFontCache.push_back( CacheItem( ftFace, path, requestedPointSize, faceIndex, metrics ) );
id = mFontCache.size();
if( cacheDescription )
{
- CacheFontPath( ftFace, id, pointSize, path );
+ CacheFontPath( ftFace, id, requestedPointSize, path );
}
}
else
{
- DALI_LOG_ERROR( "FreeType Set_Char_Size error: %d for pointSize %d\n", error, pointSize );
+ DALI_LOG_ERROR( "FreeType Set_Char_Size error: %d for pointSize %d\n", error, actualPointSize );
}
}
}
}
bool FontClient::Plugin::FindFont( const FontPath& path,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FaceIndex faceIndex,
FontId& fontId ) const
{
{
const CacheItem& cacheItem = *it;
- if( cacheItem.mPointSize == pointSize &&
+ if( cacheItem.mRequestedPointSize == requestedPointSize &&
cacheItem.mFaceIndex == faceIndex &&
cacheItem.mPath == path )
{
}
bool FontClient::Plugin::FindFont( FontDescriptionId validatedFontId,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FontId& fontId )
{
fontId = 0u;
const FontIdCacheItem& item = *it;
if( ( validatedFontId == item.validatedFontId ) &&
- ( pointSize == item.pointSize ) )
+ ( requestedPointSize == item.requestedPointSize ) )
{
fontId = item.fontId;
return true;
FcPatternDestroy( fontFamilyPattern );
}
-void FontClient::Plugin::CacheFontPath( FT_Face ftFace, FontId id, PointSize26Dot6 pointSize, const FontPath& path )
+void FontClient::Plugin::CacheFontPath( FT_Face ftFace, FontId id, PointSize26Dot6 requestedPointSize, const FontPath& path )
{
FontDescription description;
description.path = path;
mValidatedFontCache.push_back( item );
- // Cache the pair 'validatedFontId, pointSize' to improve the following queries.
+ // Cache the pair 'validatedFontId, requestedPointSize' to improve the following queries.
mFontIdCache.push_back( FontIdCacheItem( validatedFontId,
- pointSize,
+ requestedPointSize,
id ) );
}
}
struct FontIdCacheItem
{
FontIdCacheItem( FontDescriptionId validatedFontId,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FontId fontId );
- FontDescriptionId validatedFontId; ///< Index to the vector with font descriptions.
- PointSize26Dot6 pointSize; ///< The font point size.
- FontId fontId; ///< The font id.
+ FontDescriptionId validatedFontId; ///< Index to the vector with font descriptions.
+ PointSize26Dot6 requestedPointSize; ///< The font point size.
+ FontId fontId; ///< The font id.
};
/**
{
CacheItem( FT_Face ftFace,
const FontPath& path,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FaceIndex face,
const FontMetrics& metrics );
CacheItem( FT_Face ftFace,
const FontPath& path,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FaceIndex face,
const FontMetrics& metrics,
float fixedWidth,
float fixedHeight );
- FT_Face mFreeTypeFace; ///< The FreeType face.
- FontPath mPath; ///< The path to the font file name.
- PointSize26Dot6 mPointSize; ///< The font point size.
- FaceIndex mFaceIndex; ///< The face index.
- FontMetrics mMetrics; ///< The font metrics.
- FT_Short mFixedWidthPixels; ///< The height in pixels (fixed size bitmaps only)
- FT_Short mFixedHeightPixels; ///< The height in pixels (fixed size bitmaps only)
- unsigned int mVectorFontId; ///< The ID of the equivalent vector-based font
- bool mIsFixedSizeBitmap; ///< Whether the font has fixed size bitmaps.
+ FT_Face mFreeTypeFace; ///< The FreeType face.
+ FontPath mPath; ///< The path to the font file name.
+ PointSize26Dot6 mRequestedPointSize; ///< The font point size.
+ FaceIndex mFaceIndex; ///< The face index.
+ FontMetrics mMetrics; ///< The font metrics.
+ FT_Short mFixedWidthPixels; ///< The height in pixels (fixed size bitmaps only)
+ FT_Short mFixedHeightPixels; ///< The height in pixels (fixed size bitmaps only)
+ unsigned int mVectorFontId; ///< The ID of the equivalent vector-based font
+ bool mIsFixedSizeBitmap; ///< Whether the font has fixed size bitmaps.
};
struct EllipsisItem
{
- PointSize26Dot6 size;
+ PointSize26Dot6 requestedPointSize;
GlyphInfo glyph;
};
*/
FontId FindFontForCharacter( const FontList& fontList,
Character charcode,
- PointSize26Dot6 requestedSize,
+ PointSize26Dot6 requestedPointSize,
bool preferColor );
/**
* @copydoc Dali::FontClient::FindDefaultFont()
*/
- FontId FindDefaultFont( Character charcode, PointSize26Dot6 pointSize, bool preferColor );
+ FontId FindDefaultFont( Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor );
/**
* @copydoc Dali::FontClient::FindFallbackFont()
*/
- FontId FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 requestedSize, bool preferColor );
+ FontId FindFallbackFont( FontId preferredFont, Character charcode, PointSize26Dot6 requestedPointSize, bool preferColor );
/**
- * @see Dali::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex )
+ * @see Dali::FontClient::GetFontId( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
*
+ * @param[in] actualPointSize The actual point size. In case of emojis the @p requestedPointSize is used to build the metrics and cache the font and the @p actualPointSize is used to load the glyph.
* @param[in] cacheDescription Whether to cache the font description.
*/
- FontId GetFontId( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex, bool cacheDescription = true );
+ FontId GetFontId( const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ PointSize26Dot6 actualPointSize,
+ FaceIndex faceIndex,
+ bool cacheDescription = true );
/**
- * @copydoc Dali::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 pointSize, FaceIndex faceIndex )
+ * @copydoc Dali::FontClient::GetFontId( const FontDescription& fontDescription, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex )
*/
FontId GetFontId( const FontDescription& fontDescription,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
+ PointSize26Dot6 actualPointSize,
FaceIndex faceIndex );
/**
/**
* @copydoc Dali::FontClient::GetFontMetrics()
*/
- void GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize );
+ void GetFontMetrics( FontId fontId, FontMetrics& metrics );
/**
* @copydoc Dali::FontClient::GetGlyphIndex()
/**
* @copydoc Dali::FontClient::GetGlyphMetrics()
*/
- bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal, int desiredFixedSize );
+ bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, GlyphType type, bool horizontal );
/**
* Helper for GetGlyphMetrics when using bitmaps
*/
- bool GetBitmapMetrics( GlyphInfo* array, uint32_t size, bool horizontal, int desiredFixedSize );
+ bool GetBitmapMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
/**
* Helper for GetGlyphMetrics when using vectors
*/
- bool GetVectorMetrics( GlyphInfo* array, uint32_t size, bool horizontal, int desiredFixedSize );
+ bool GetVectorMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
/**
* @copydoc Dali::FontClient::CreateBitmap()
/**
* @copydoc Dali::FontClient::GetEllipsisGlyph()
*/
- const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 pointSize );
+ const GlyphInfo& GetEllipsisGlyph( PointSize26Dot6 requestedPointSize );
private:
* @brief Creates a font.
*
* @param[in] path The path to the font file name.
- * @param[in] pointSize The font point size.
+ * @param[in] requestedPointSize The requested point size.
+ * @param[in] actualPointSize The actual point size (for color emojis).
* @param[in] faceIndex A face index.
* @param[in] cacheDescription Whether to cache the font description.
*
* @return The font id.
*/
- FontId CreateFont( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex, bool cacheDescription );
-
- /**
- * @brief Creates a fixed size font
- *
- * @param[in] path The path to the font file name.
- * @param[in] pointSize The font point size( must be an available size ).
- * @param[in] faceIndex A face index.
- * @param[in] cacheDescription Whether to cache the font description.
- *
- * @return The font id.
- */
- FontId CreateFixedSizeFont( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex, bool cacheDescription );
+ FontId CreateFont( const FontPath& path,
+ PointSize26Dot6 requestedPointSize,
+ PointSize26Dot6 actualPointSize,
+ FaceIndex faceIndex,
+ bool cacheDescription );
/**
*
* If there is one , if writes the font id in the param @p fontId.
*
* @param[in] path Path to the font file name.
- * @param[in] pointSize The font point size.
+ * @param[in] requestedPointSize The font point size.
* @param[in] faceIndex The face index.
* @param[out] fontId The font id.
*
* @return @e true if there triplet is found.
*/
- bool FindFont( const FontPath& path, PointSize26Dot6 pointSize, FaceIndex faceIndex, FontId& fontId ) const;
+ bool FindFont( const FontPath& path, PointSize26Dot6 requestedPointSize, FaceIndex faceIndex, FontId& fontId ) const;
/**
* @brief Finds in the cache a cluster 'font family, font width, font weight, font slant'
* If there is one it writes the font id in the param @p fontId.
*
* @param[in] validatedFontId Index to the vector with font descriptions.
- * @param[in] pointSize The font point size.
+ * @param[in] requestedPointSize The font point size.
* @param[out] fontId The font id.
*
* @return @e true if the pair is found.
*/
bool FindFont( FontDescriptionId validatedFontId,
- PointSize26Dot6 pointSize,
+ PointSize26Dot6 requestedPointSize,
FontId& fontId );
/**
*
* @param[in] ftFace The FreeType face.
* @param[in] id The font identifier.
- * @param[in] pointSize The font point size.
+ * @param[in] requestedPointSize The font point size.
* @param[in] path Path to the font file name.
*/
- void CacheFontPath( FT_Face ftFace, FontId id, PointSize26Dot6 pointSize, const FontPath& path );
+ void CacheFontPath( FT_Face ftFace, FontId id, PointSize26Dot6 requestedPointSize, const FontPath& path );
private: