* Emojis will use the point size set by the user to calculate their metrics.
Change-Id: I42a1369520df501bf7d73ad0fabe0d879ed40f8e
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
bool IsScalable( const FontDescription& fontDescription ){return true;}
void GetFixedSizes( const FontPath& path, Dali::Vector< PointSize26Dot6>& sizes ){}
void GetFixedSizes( const FontDescription& fontDescription, Dali::Vector< PointSize26Dot6 >& sizes ){}
- void GetFontMetrics( FontId fontId, FontMetrics& metrics, int desiredFixedSize ){}
+ void GetFontMetrics( FontId fontId, FontMetrics& metrics ){}
GlyphIndex GetGlyphIndex( FontId fontId, Character charcode ){return 0;}
- bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal, int desiredFixedSize ){return true;}
+ bool GetGlyphMetrics( GlyphInfo* array, uint32_t size, bool horizontal ){return true;}
BufferImage CreateBitmap( FontId fontId, GlyphIndex glyphIndex ){return BufferImage();}
void CreateVectorBlob( FontId fontId, GlyphIndex glyphIndex, VectorBlob*& blob,
unsigned int& blobLength, unsigned int& nominalWidth, unsigned int& nominalHeight )
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, horizontal, desiredFixedSize );
+ return GetImplementation(*this).GetGlyphMetrics( array, size, horizontal );
}
BufferImage FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex )
typedef IntrusivePtr<Metrics> MetricsPtr;
/**
- * @brief A wrapper around FontClient used to get metrics & potentially down-scaled Emoji metrics.
+ * @brief A wrapper around FontClient used to get metrics.
*/
class Metrics : public RefObject
{
}
/**
- * @brief Set the maximum Emoji size.
- *
- * @param[in] emojiSize Emoticons will be scaled to fit this size in pixels.
- */
- void SetMaxEmojiSize( int emojiSize )
- {
- mEmojiSize = emojiSize;
- }
-
- /**
- * @brief Get the maximum Emoji size.
- *
- * @return The maximum Emoji size.
- */
- int GetMaxEmojiSize() const
- {
- return mEmojiSize;
- }
-
- /**
* @brief Query the metrics for a font.
*
* @param[in] fontId The ID of the font for the required glyph.
*/
void GetFontMetrics( FontId fontId, FontMetrics& metrics )
{
- mFontClient.GetFontMetrics( fontId, metrics, mEmojiSize ); // inline for performance
+ mFontClient.GetFontMetrics( fontId, metrics ); // inline for performance
}
/**
*/
bool GetGlyphMetrics( GlyphInfo* array, uint32_t size )
{
- return mFontClient.GetGlyphMetrics( array, size, mGlyphType, true, mEmojiSize ); // inline for performance
+ return mFontClient.GetGlyphMetrics( array, size, mGlyphType, true ); // inline for performance
}
protected:
*/
Metrics( TextAbstraction::FontClient& fontClient )
: mFontClient( fontClient ),
- mGlyphType( TextAbstraction::BITMAP_GLYPH ),
- mEmojiSize( 0 )
- {
- }
+ mGlyphType( TextAbstraction::BITMAP_GLYPH )
+ {}
// Undefined
Metrics(const Metrics&);
TextAbstraction::FontClient mFontClient;
TextAbstraction::GlyphType mGlyphType;
- int mEmojiSize;
};
} // namespace Text
while( !endOfText &&
( TextAbstraction::COMMON == script ) )
{
+ if( TextAbstraction::EMOJI == currentScriptRun.script )
+ {
+ // Emojis doesn't mix well with characters common to all scripts. Insert the emoji run.
+ scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun );
+ ++scriptIndex;
+
+ // Initialize the new one.
+ currentScriptRun.characterRun.characterIndex = currentScriptRun.characterRun.characterIndex + currentScriptRun.characterRun.numberOfCharacters;
+ currentScriptRun.characterRun.numberOfCharacters = 0u;
+ currentScriptRun.script = TextAbstraction::UNKNOWN;
+ numberOfAllScriptCharacters = 0u;
+ }
+
// Count all these characters to be added into a script.
++numberOfAllScriptCharacters;
character = *( textBuffer + index );
script = TextAbstraction::GetCharacterScript( character );
}
- }
+ } // end while( !endOfText && ( TextAbstraction::COMMON == script ) )
if( endOfText )
{
// Check if it is the first character of a paragraph.
if( isFirstScriptToBeSet &&
( TextAbstraction::UNKNOWN != script ) &&
- ( TextAbstraction::COMMON != script ) )
+ ( TextAbstraction::COMMON != script ) &&
+ ( TextAbstraction::EMOJI != script ) )
{
// Sets the direction of the first valid script.
isParagraphRTL = TextAbstraction::IsRightToLeftScript( script );
currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
numberOfAllScriptCharacters = 0u;
}
+ else if( ( TextAbstraction::UNKNOWN == currentScriptRun.script ) &&
+ ( TextAbstraction::EMOJI == script ) )
+ {
+ currentScriptRun.script = TextAbstraction::LATIN;
+ currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
+ numberOfAllScriptCharacters = 0u;
+ }
if( 0u != currentScriptRun.characterRun.numberOfCharacters )
{
PointSize26Dot6 currentPointSize = defaultPointSize;
FontId currentFontId = 0u;
FontId previousFontId = 0u;
+ bool isPreviousEmojiScript = false;
// Whether it's the first set of characters to be validated.
// Used in case the paragraph starts with characters common to all scripts.
isValidFont = isValidCachedDefaultFont && ( fontId == cachedDefaultFontId );
bool isCommonScript = false;
+ bool isEmojiScript = TextAbstraction::EMOJI == script;
+
+ if( isEmojiScript && !isPreviousEmojiScript )
+ {
+ if( 0u != currentFontRun.characterRun.numberOfCharacters )
+ {
+ // Store the font run.
+ fonts.Insert( fonts.Begin() + fontIndex, currentFontRun );
+ ++fontIndex;
+ }
+
+ // Initialize the new one.
+ currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
+ currentFontRun.characterRun.numberOfCharacters = 0u;
+ currentFontRun.fontId = fontId;
+ }
+
// If the given font is not valid, it means either:
// - there is no cached font for the current script yet or,
if( isCommonScript )
{
if( isValidCachedDefaultFont &&
- ( isDefault || ( currentFontId == previousFontId ) ) )
+ ( isDefault || ( currentFontId == previousFontId ) ) &&
+ !isEmojiScript )
{
// 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.
// Emojis are present in many monochrome fonts; prefer color by default.
if( isValidFont &&
- ( TextAbstraction::EMOJI == script ) )
+ isEmojiScript )
{
const BufferImage bitmap = fontClient.CreateBitmap( fontId, glyphIndex );
// Cache the font.
if( NULL == defaultFontsPerScript )
{
- defaultFontsPerScript = new DefaultFonts();
- *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
+ defaultFontsPerScript = *( defaultFontPerScriptCacheBuffer + script );
+
+ if( NULL == defaultFontsPerScript )
+ {
+ defaultFontsPerScript = new DefaultFonts();
+ *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
+ }
}
defaultFontsPerScript->mFonts.PushBack( fontId );
}
// Whether the current character is a new paragraph character.
isNewParagraphCharacter = TextAbstraction::IsNewParagraph( character );
previousFontId = currentFontId;
+ isPreviousEmojiScript = isEmojiScript;
} // end traverse characters.
if( 0u != currentFontRun.characterRun.numberOfCharacters )
#endif
const float MAX_FLOAT = std::numeric_limits<float>::max();
-const unsigned int POINTS_PER_INCH = 72;
const std::string EMPTY_STRING("");
mImpl->mFontDefaults->mDefaultPointSize = pointSize;
mImpl->mFontDefaults->sizeDefined = true;
- unsigned int horizontalDpi( 0u );
- unsigned int verticalDpi( 0u );
- mImpl->mFontClient.GetDpi( horizontalDpi, verticalDpi );
-
- // Adjust the metrics if the fixed-size font should be down-scaled
- int maxEmojiSize( pointSize/POINTS_PER_INCH * verticalDpi );
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultPointSize %p setting MaxEmojiSize %d\n", this, maxEmojiSize );
- mImpl->mMetrics->SetMaxEmojiSize( maxEmojiSize );
-
// Clear the font-specific data
ClearFontData();