/*
- * 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.
const TextAbstraction::FontDescription& description,
PointSize26Dot6 size ) const
{
- for( Vector<FontId>::ConstIterator it = mFonts.Begin(),
- endIt = mFonts.End();
+ for( std::vector<CacheItem>::const_iterator it = mFonts.begin(),
+ endIt = mFonts.end();
it != endIt;
++it )
{
- const FontId fontId = *it;
- TextAbstraction::FontDescription fontDescription;
- fontClient.GetDescription( fontId, fontDescription );
-
- if( ( size == fontClient.GetPointSize( fontId ) ) &&
- ( description.weight == fontDescription.weight ) &&
- ( description.width == fontDescription.width ) &&
- ( description.slant == fontDescription.slant ) )
+ const CacheItem& item = *it;
+
+ if( ( ( TextAbstraction::FontWeight::NONE == description.weight ) || ( description.weight == item.description.weight ) ) &&
+ ( ( TextAbstraction::FontWidth::NONE == description.width ) || ( description.width == item.description.width ) ) &&
+ ( ( TextAbstraction::FontSlant::NONE == description.slant ) || ( description.slant == item.description.slant ) ) &&
+ ( size == fontClient.GetPointSize( item.fontId ) ) &&
+ ( description.family.empty() || ( description.family == item.description.family ) ) )
{
- return fontId;
+ return item.fontId;
}
}
return 0u;
}
+void DefaultFonts::Cache( const TextAbstraction::FontDescription& description, FontId fontId )
+{
+ CacheItem item;
+ item.description = description;
+ item.fontId = fontId;
+ mFonts.push_back( item );
+}
+
MultilanguageSupport::MultilanguageSupport()
: mDefaultFontPerScriptCache(),
mValidFontsPerScriptCache()
// At this point the character common for all scripts has no font assigned.
// If there is a valid previously cached default font for it, use that one.
fontId = cachedDefaultFontId;
- isValidFont = true;
}
}
else
if( isValidFont &&
isEmojiScript )
{
- const PixelData bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
-
- // For color emojis, the font is valid if the bitmap is RGBA.
- isValidFont = bitmap && ( Pixel::BGRA8888 == bitmap.GetPixelFormat() );
+ // For color emojis, the font is valid if the glyph is a color glyph (the bitmap is RGBA).
+ isValidFont = fontClient.IsColorGlyph( fontId, glyphIndex );
}
// If there is a valid font, cache it.
*( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
}
}
- defaultFontsPerScript->mFonts.PushBack( fontId );
+ defaultFontsPerScript->Cache( currentFontDescription, fontId );
}
} // !isValidFont (3)
} // !isValidFont (2)