From 299a44f615130c88513b386eec2ddd60128a54e9 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Fri, 9 Jun 2023 14:00:14 +0900 Subject: [PATCH] [Tizen] Apply font size scale to markup text Change-Id: I1c6467a1ebb42b4604497db12b12052fc7deba80 Signed-off-by: Bowon Ryu --- .../dali-toolkit-test-utils/toolkit-text-utils.cpp | 1 + .../utc-Dali-Text-MultiLanguage.cpp | 66 ++++++++++++++-------- dali-toolkit/devel-api/text/text-utils-devel.cpp | 1 + .../text-controller-impl-model-updater.cpp | 1 + .../text/multi-language-helper-functions.cpp | 3 +- .../text/multi-language-helper-functions.h | 2 + .../internal/text/multi-language-support-impl.cpp | 2 + .../internal/text/multi-language-support-impl.h | 1 + .../internal/text/multi-language-support.cpp | 2 + .../internal/text/multi-language-support.h | 2 + 10 files changed, 58 insertions(+), 23 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp index 046f997..1e4dfe1 100644 --- a/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp +++ b/automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp @@ -229,6 +229,7 @@ void CreateTextModel(const std::string& text, fontDescriptionRuns, fontDescription, TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, characterCount, validFonts); diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp index 559e34e..e74adf7 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp @@ -35,33 +35,35 @@ using namespace Text; // Tests the following functions with different scripts. // -// void MergeFontDescriptions( const Vector& fontDescriptions, -// const TextAbstraction::FontDescription& defaultFontDescription, -// TextAbstraction::PointSize26Dot6 defaultPointSize, -// CharacterIndex characterIndex, -// TextAbstraction::FontDescription& fontDescription, -// TextAbstraction::PointSize26Dot6& fontPointSize, -// bool& isDefaultFont ); +// void MergeFontDescriptions(const Vector& fontDescriptions, +// const TextAbstraction::FontDescription& defaultFontDescription, +// TextAbstraction::PointSize26Dot6 defaultPointSize, +// float fontSizeScale, +// CharacterIndex characterIndex, +// TextAbstraction::FontDescription& fontDescription, +// TextAbstraction::PointSize26Dot6& fontPointSize, +// bool& isDefaultFont); // -// Script GetScript( Length index, -// Vector::ConstIterator& scriptRunIt, -// const Vector::ConstIterator& scriptRunEndIt ); +// Script GetScript(Length index, +// Vector::ConstIterator& scriptRunIt, +// const Vector::ConstIterator& scriptRunEndIt); // // Constructor, destructor and MultilanguageSupport::Get() // -// void MultilanguageSupport::SetScripts( const Vector& text, -// CharacterIndex startIndex, -// Length numberOfCharacters, -// Vector& scripts ); +// void MultilanguageSupport::SetScripts(const Vector& text, +// CharacterIndex startIndex, +// Length numberOfCharacters, +// Vector& scripts); // -// void MultilanguageSupport::ValidateFonts( const Vector& text, -// const Vector& scripts, -// const Vector& fontDescriptions, -// const TextAbstraction::FontDescription& defaultFontDescription, -// TextAbstraction::PointSize26Dot6 defaultFontPointSize, -// CharacterIndex startIndex, -// Length numberOfCharacters, -// Vector& fonts ); +// void MultilanguageSupport::ValidateFonts(const Vector& text, +// const Vector& scripts, +// const Vector& fontDescriptions, +// const TextAbstraction::FontDescription& defaultFontDescription, +// TextAbstraction::PointSize26Dot6 defaultFontPointSize, +// float fontSizeScale, +// CharacterIndex startIndex, +// Length numberOfCharacters, +// Vector& fonts); ////////////////////////////////////////////////////////// @@ -78,6 +80,7 @@ struct MergeFontDescriptionsData Vector fontDescriptionRuns; ///< The font description runs. TextAbstraction::FontDescription defaultFontDescription; ///< The default font description. TextAbstraction::PointSize26Dot6 defaultPointSize; ///< The default point size. + float fontSizeScale; ///< The font's size scale. unsigned int startIndex; ///< The start index. unsigned int numberOfCharacters; ///< The number of characters. Vector expectedFontIds; ///< The expected font ids. @@ -99,6 +102,7 @@ struct ValidateFontsData std::string text; ///< Input text. std::string defaultFont; ///< The default font. unsigned int defaultFontSize; ///< The default font size. + float fontSizeScale; ///< The font's size scale. unsigned int index; ///< The index of the first character to update the script. unsigned int numberOfCharacters; ///< The numbers of characters to update the script. Vector fontDescriptionRuns; ///< The font description runs. @@ -123,6 +127,7 @@ bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data ) MergeFontDescriptions( data.fontDescriptionRuns, data.defaultFontDescription, data.defaultPointSize, + data.fontSizeScale, index, fontDescription, fontPointSize, @@ -290,6 +295,7 @@ bool ValidateFontTest( const ValidateFontsData& data ) data.fontDescriptionRuns, defaultFontDescription, defaultPointSize, + data.fontSizeScale, 0u, numberOfCharacters, fontRuns ); @@ -307,6 +313,7 @@ bool ValidateFontTest( const ValidateFontsData& data ) data.fontDescriptionRuns, defaultFontDescription, defaultPointSize, + data.fontSizeScale, data.index, data.numberOfCharacters, fontRuns ); @@ -594,6 +601,7 @@ int UtcDaliTextMergeFontDescriptions(void) fontDescriptionRuns01, defaultFontDescription01, TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 0u, expectedFontIds01, @@ -604,6 +612,7 @@ int UtcDaliTextMergeFontDescriptions(void) fontDescriptionRuns02, defaultFontDescription02, TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 2u, expectedFontIds02, @@ -614,6 +623,7 @@ int UtcDaliTextMergeFontDescriptions(void) fontDescriptionRuns03, defaultFontDescription03, TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 10u, expectedFontIds03, @@ -1744,6 +1754,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 0u, fontDescriptions01, @@ -1754,6 +1765,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "Hello world", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 11u, fontDescriptions02, @@ -1764,6 +1776,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "Hello world\nhello world\ndemo", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 28u, fontDescriptions03, @@ -1774,6 +1787,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "Hello world\nhello world\ndemo", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 12u, fontDescriptions03, @@ -1784,6 +1798,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "Hello world\nhello world\ndemo", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 12u, 12u, fontDescriptions03, @@ -1794,6 +1809,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "Hello world\nhello world\ndemo", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 24u, 4u, fontDescriptions03, @@ -1804,6 +1820,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "שלום עולם", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 9u, fontDescriptions07, @@ -1814,6 +1831,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "שלום עולם", "/tizen/TizenSansHebrewRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 9u, fontDescriptions08, @@ -1824,6 +1842,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84", "/tizen/BreezeColorEmoji.ttf", EMOJI_FONT_SIZE, + 1.0f, 0u, 4u, fontDescriptions09, @@ -1834,6 +1853,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "Hello world, שלום עולם, hello world, שלום עולם", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 46u, fontDescriptions10, @@ -1844,6 +1864,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "WRC – The Official App", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 22u, fontDescriptions11, @@ -1854,6 +1875,7 @@ int UtcDaliTextMultiLanguageValidateFonts01(void) "Hello \tworld", "/tizen/TizenSansRegular.ttf", TextAbstraction::FontClient::DEFAULT_POINT_SIZE, + 1.0f, 0u, 12u, fontDescriptions12, diff --git a/dali-toolkit/devel-api/text/text-utils-devel.cpp b/dali-toolkit/devel-api/text/text-utils-devel.cpp index 07c89ff..e779fe9 100644 --- a/dali-toolkit/devel-api/text/text-utils-devel.cpp +++ b/dali-toolkit/devel-api/text/text-utils-devel.cpp @@ -293,6 +293,7 @@ void ShapeTextPreprocess(const RendererParameters& textParameters, TextAbstracti fontDescriptionRuns, defaultFontDescription, defaultPointSize, + 1.0f, 0u, numberOfCharacters, validFonts); diff --git a/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp b/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp index c4dd053..3068db5 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-impl-model-updater.cpp @@ -268,6 +268,7 @@ bool ControllerImplModelUpdater::Update(Controller::Impl& impl, OperationsMask o fontDescriptionRuns, defaultFontDescription, defaultPointSize, + impl.GetFontSizeScale(), startIndex, requestedNumberOfCharacters, validFonts); diff --git a/dali-toolkit/internal/text/multi-language-helper-functions.cpp b/dali-toolkit/internal/text/multi-language-helper-functions.cpp index f53bfef..930cb8b 100644 --- a/dali-toolkit/internal/text/multi-language-helper-functions.cpp +++ b/dali-toolkit/internal/text/multi-language-helper-functions.cpp @@ -30,6 +30,7 @@ namespace Text void MergeFontDescriptions(const Vector& fontDescriptions, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultPointSize, + float fontSizeScale, CharacterIndex characterIndex, TextAbstraction::FontDescription& fontDescription, TextAbstraction::PointSize26Dot6& fontPointSize, @@ -133,7 +134,7 @@ void MergeFontDescriptions(const Vector& fontDescripti if(sizeOverriden) { const FontDescriptionRun& fontRun = *(fontDescriptionsBuffer + sizeIndex); - fontPointSize = fontRun.size; + fontPointSize = static_cast(fontRun.size * fontSizeScale); } } } diff --git a/dali-toolkit/internal/text/multi-language-helper-functions.h b/dali-toolkit/internal/text/multi-language-helper-functions.h index 41cb04a..f9992d0 100644 --- a/dali-toolkit/internal/text/multi-language-helper-functions.h +++ b/dali-toolkit/internal/text/multi-language-helper-functions.h @@ -37,6 +37,7 @@ namespace Text * @param[in] fontDescriptions The font's descriptions for the whole text. * @param[in] defaultFontDescription The default font's description. * @param[in] defaultPointSize The default font's point size. + * @param[in] fontSizeScale The font's size scale. * @param[in] characterIndex Index to the character to retrieve its font's description. * @param[out] fontDescription The font's description for the character. * @param[out] fontPointSize The font's point size for the character. @@ -45,6 +46,7 @@ namespace Text void MergeFontDescriptions(const Vector& fontDescriptions, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultPointSize, + float fontSizeScale, CharacterIndex characterIndex, TextAbstraction::FontDescription& fontDescription, TextAbstraction::PointSize26Dot6& fontPointSize, diff --git a/dali-toolkit/internal/text/multi-language-support-impl.cpp b/dali-toolkit/internal/text/multi-language-support-impl.cpp index 79de1e1..1bf3c17 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.cpp +++ b/dali-toolkit/internal/text/multi-language-support-impl.cpp @@ -413,6 +413,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& const Vector& fontDescriptions, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultFontPointSize, + float fontSizeScale, CharacterIndex startIndex, Length numberOfCharacters, Vector& fonts) @@ -493,6 +494,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& MergeFontDescriptions(fontDescriptions, defaultFontDescription, defaultFontPointSize, + fontSizeScale, index, currentFontDescription, currentFontPointSize, diff --git a/dali-toolkit/internal/text/multi-language-support-impl.h b/dali-toolkit/internal/text/multi-language-support-impl.h index cda767a..5dc97fc 100644 --- a/dali-toolkit/internal/text/multi-language-support-impl.h +++ b/dali-toolkit/internal/text/multi-language-support-impl.h @@ -153,6 +153,7 @@ public: const Vector& fontDescriptions, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultFontPointSize, + float fontSizeScale, CharacterIndex startIndex, Length numberOfCharacters, Vector& fonts); diff --git a/dali-toolkit/internal/text/multi-language-support.cpp b/dali-toolkit/internal/text/multi-language-support.cpp index 11ba9c0..fd930c8 100644 --- a/dali-toolkit/internal/text/multi-language-support.cpp +++ b/dali-toolkit/internal/text/multi-language-support.cpp @@ -61,6 +61,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& const Vector& fontDescriptions, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultFontPointSize, + float fontSizeScale, CharacterIndex startIndex, Length numberOfCharacters, Vector& fonts) @@ -70,6 +71,7 @@ void MultilanguageSupport::ValidateFonts(const Vector& fontDescriptions, defaultFontDescription, defaultFontPointSize, + fontSizeScale, startIndex, numberOfCharacters, fonts); diff --git a/dali-toolkit/internal/text/multi-language-support.h b/dali-toolkit/internal/text/multi-language-support.h index 7423820..34b92b8 100644 --- a/dali-toolkit/internal/text/multi-language-support.h +++ b/dali-toolkit/internal/text/multi-language-support.h @@ -110,6 +110,7 @@ public: * @param[in] fontDescriptions The fonts set through the mark-up string or the input style set through the property system. * @param[in] defaultFontDescription The default font's description set through the property system. * @param[in] defaultFontPointSize The default font's point size set through the property system. + * @param[in] fontSizeScale The font's size scale. * @param[in] startIndex The character from where the font info is set. * @param[in] numberOfCharacters The number of characters to set the font. * @param[out] fonts The validated fonts. @@ -119,6 +120,7 @@ public: const Vector& fontDescriptions, const TextAbstraction::FontDescription& defaultFontDescription, TextAbstraction::PointSize26Dot6 defaultFontPointSize, + float fontSizeScale, CharacterIndex startIndex, Length numberOfCharacters, Vector& fonts); -- 2.7.4