/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
#include <dali/devel-api/common/singleton-service.h>
#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/emoji-helper.h>
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_MULTI_LANGUAGE_SUPPORT");
#endif
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_FONT_PERFORMANCE_MARKER, false);
+
const Dali::Toolkit::Text::Character UTF32_A = 0x0041;
} // namespace
currentScriptRun.isRightToLeft = false;
// Traverse all characters and set the scripts.
- const Length lastCharacter = startIndex + numberOfCharacters;
+ const Length lastCharacter = startIndex + numberOfCharacters - 1u;
- for(Length index = startIndex; index < lastCharacter; ++index)
+ for(Length index = startIndex; index <= lastCharacter; ++index)
{
Character character = *(textBuffer + index);
// script of the first character of the paragraph with a defined script.
// Skip those characters valid for many scripts like white spaces or '\n'.
- bool endOfText = index == lastCharacter;
+ bool endOfText = index > lastCharacter;
//Handle all Emoji Sequence cases
if(IsNewSequence(textBuffer, currentScriptRun.script, index, lastCharacter, script))
// Get the next character.
++index;
- endOfText = index == lastCharacter;
+ endOfText = index > lastCharacter;
if(!endOfText)
{
character = *(textBuffer + index);
return;
}
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_FONTS_VALIDATE");
+
// Find the first index where to insert the font run.
FontRunIndex fontIndex = 0u;
if(0u != startIndex)
Vector<ScriptRun>::ConstIterator scriptRunEndIt = scripts.End();
bool isNewParagraphCharacter = false;
- FontId previousEmojiFontId = 0u;
- TextAbstraction::Script previousScript = TextAbstraction::UNKNOWN;
+ FontId previousEmojiFontId = 0u;
+ FontId currentFontId = 0u;
+ FontId previousFontId = 0u;
+ TextAbstraction::Script previousScript = TextAbstraction::UNKNOWN;
- CharacterIndex lastCharacter = startIndex + numberOfCharacters;
- for(Length index = startIndex; index < lastCharacter; ++index)
+ CharacterIndex lastCharacter = startIndex + numberOfCharacters - 1u;
+ for(Length index = startIndex; index <= lastCharacter; ++index)
{
// Get the current character.
const Character character = *(textBuffer + index);
// Get the font for the current character.
FontId fontId = fontClient.GetFontId(currentFontDescription, currentFontPointSize);
+ currentFontId = fontId;
// Get the script for the current character.
Script script = GetScript(index,
scriptRunEndIt);
#ifdef DEBUG_ENABLED
+ if(gLogFilter->IsEnabledFor(Debug::Verbose))
{
Dali::TextAbstraction::FontDescription description;
fontClient.GetDescription(fontId, description);
}
bool isCommonScript = false;
- bool isEmojiScript = TextAbstraction::IsEmojiScript(script) || TextAbstraction::IsEmojiColorScript(script) || TextAbstraction::IsEmojiTextScript(script);
+ bool isEmojiScript = TextAbstraction::IsOneOfEmojiScripts(script);
if(isEmojiScript && (previousScript == script))
{
}
}
+ if(TextAbstraction::IsSpace(character) &&
+ TextAbstraction::HasLigatureMustBreak(script) &&
+ isValidCachedDefaultFont &&
+ (isDefaultFont || (currentFontId == previousFontId)))
+ {
+ fontId = cachedDefaultFontId;
+ isValidFont = true;
+ }
+
// If the given font is not valid, it means either:
// - there is no cached font for the current script yet or,
// - the user has set a different font than the default one for the current script or,
{
// Use the cached default font for the script if there is one.
fontId = cachedDefaultFontId;
+ isValidFont = true;
}
else
{
}
}
defaultFontsPerScript->Cache(currentFontDescription, fontId);
+ isValidFont = true;
}
}
} // !isValidFont (3)
}
#ifdef DEBUG_ENABLED
+ if(gLogFilter->IsEnabledFor(Debug::Verbose))
{
Dali::TextAbstraction::FontDescription description;
fontClient.GetDescription(fontId, description);
description.path.c_str());
}
#endif
+ if(!isValidFont && !isCommonScript)
+ {
+ Dali::TextAbstraction::FontDescription descriptionForLog;
+ fontClient.GetDescription(fontId, descriptionForLog);
+ DALI_LOG_RELEASE_INFO("Validated font set fail : Character : %x, Script : %s, Font : %s \n",
+ character,
+ Dali::TextAbstraction::ScriptName[script],
+ descriptionForLog.path.c_str());
+ }
// Whether bols style is required.
isBoldRequired = (currentFontDescription.weight >= TextAbstraction::FontWeight::BOLD);
// Whether the current character is a new paragraph character.
isNewParagraphCharacter = TextAbstraction::IsNewParagraph(character);
previousScript = script;
+ previousFontId = currentFontId;
} // end traverse characters.
if(0u != currentFontRun.characterRun.numberOfCharacters)