2 * Copyright (c) 2024 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <dali/devel-api/text-abstraction/font-client.h>
23 #include <dali-toolkit/internal/text/character-set-conversion.h>
24 #include <dali-toolkit/internal/text/logical-model-impl.h>
25 #include <dali-toolkit/internal/text/multi-language-helper-functions.h>
26 #include <dali-toolkit/internal/text/multi-language-support.h>
27 #include <dali-toolkit/internal/text/multi-language-support-impl.h>
28 #include <dali-toolkit/internal/text/segmentation.h>
29 #include <dali-toolkit/internal/text/text-run-container.h>
30 #include <dali-toolkit-test-suite-utils.h>
31 #include <dali-toolkit/dali-toolkit.h>
34 using namespace Toolkit;
38 // Tests the following functions with different scripts.
40 // void MergeFontDescriptions(const Vector<FontDescriptionRun>& fontDescriptions,
41 // const TextAbstraction::FontDescription& defaultFontDescription,
42 // TextAbstraction::PointSize26Dot6 defaultPointSize,
43 // float fontSizeScale,
44 // CharacterIndex characterIndex,
45 // TextAbstraction::FontDescription& fontDescription,
46 // TextAbstraction::PointSize26Dot6& fontPointSize,
47 // bool& isDefaultFont);
49 // Script GetScript(Length index,
50 // Vector<ScriptRun>::ConstIterator& scriptRunIt,
51 // const Vector<ScriptRun>::ConstIterator& scriptRunEndIt);
53 // Constructor, destructor and MultilanguageSupport::Get()
55 // void MultilanguageSupport::SetScripts(const Vector<Character>& text,
56 // CharacterIndex startIndex,
57 // Length numberOfCharacters,
58 // Vector<ScriptRun>& scripts);
60 // void MultilanguageSupport::ValidateFonts(const Vector<Character>& text,
61 // const Vector<ScriptRun>& scripts,
62 // const Vector<FontDescriptionRun>& fontDescriptions,
63 // const TextAbstraction::FontDescription& defaultFontDescription,
64 // TextAbstraction::PointSize26Dot6 defaultFontPointSize,
65 // float fontSizeScale,
66 // CharacterIndex startIndex,
67 // Length numberOfCharacters,
68 // Vector<FontRun>& fonts);
70 //////////////////////////////////////////////////////////
75 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
76 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
77 const unsigned int NON_DEFAULT_FONT_SIZE = 40u;
79 struct MergeFontDescriptionsData
81 std::string description; ///< Description of the experiment.
82 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
83 TextAbstraction::FontDescription defaultFontDescription; ///< The default font description.
84 TextAbstraction::PointSize26Dot6 defaultPointSize; ///< The default point size.
85 float fontSizeScale; ///< The font's size scale.
86 unsigned int startIndex; ///< The start index.
87 unsigned int numberOfCharacters; ///< The number of characters.
88 Vector<FontId> expectedFontIds; ///< The expected font ids.
89 Vector<bool> expectedIsDefault; ///< The expected font ids.
94 std::string description; ///< Description of the experiment.
95 std::string text; ///< Input text.
96 unsigned int index; ///< The index of the first character to update the script.
97 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
98 Vector<ScriptRun> scriptRuns; ///< Expected script runs.
101 struct ValidateFontsData
103 std::string description; ///< Description of the experiment.
104 std::string text; ///< Input text.
105 std::string defaultFont; ///< The default font.
106 unsigned int defaultFontSize; ///< The default font size.
107 float fontSizeScale; ///< The font's size scale.
108 unsigned int index; ///< The index of the first character to update the script.
109 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
110 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
111 Vector<FontRun> fontRuns; ///< The expected font runs.
114 //////////////////////////////////////////////////////////
115 bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
117 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
119 Vector<FontId> fontIds;
120 fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
121 Vector<bool> isDefaultFont;
122 isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true );
124 for( unsigned int index = data.startIndex; index < data.startIndex + data.numberOfCharacters; ++index )
126 TextAbstraction::FontDescription fontDescription;
127 TextAbstraction::PointSize26Dot6 fontPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
129 MergeFontDescriptions( data.fontDescriptionRuns,
130 data.defaultFontDescription,
131 data.defaultPointSize,
136 isDefaultFont[index] );
138 if( !isDefaultFont[index] )
140 fontIds[index] = fontClient.GetFontId( fontDescription, fontPointSize );
144 if( fontIds.Count() != data.expectedFontIds.Count() )
146 std::cout << data.description << " Different number of font ids : " << fontIds.Count() << ", expected : " << data.expectedFontIds.Count() << std::endl;
150 for( unsigned int index = 0u; index < fontIds.Count(); ++index )
152 if( fontIds[index] != data.expectedFontIds[index] )
154 std::cout << data.description << " Different font id at index : " << index << ", font id : " << fontIds[index] << ", expected : " << data.expectedFontIds[index] << std::endl;
155 std::cout << " font ids : ";
156 for( unsigned int i=0;i<fontIds.Count();++i)
158 std::cout << fontIds[i] << " ";
160 std::cout << std::endl;
161 std::cout << " expected font ids : ";
162 for( unsigned int i=0;i<data.expectedFontIds.Count();++i)
164 std::cout << data.expectedFontIds[i] << " ";
166 std::cout << std::endl;
170 if( isDefaultFont[index] != data.expectedIsDefault[index] )
172 std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl;
180 bool ScriptsTest( const ScriptsData& data )
182 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
184 // 1) Convert to utf32
185 Vector<Character> utf32;
186 utf32.Resize( data.text.size() );
188 const uint32_t numberOfCharacters = ( data.text.size() == 0 ) ? 0 :
189 Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
193 utf32.Resize( numberOfCharacters );
195 // 2) Set the script info.
196 Vector<ScriptRun> scripts;
197 multilanguageSupport.SetScripts( utf32,
202 if( ( 0u != data.index ) ||
203 ( numberOfCharacters != data.numberOfCharacters ) )
205 // 3) Clear the scripts.
206 ClearCharacterRuns( data.index,
207 data.index + data.numberOfCharacters - 1u,
210 multilanguageSupport.SetScripts( utf32,
212 data.numberOfCharacters,
216 // 4) Compare the results.
218 tet_printf( "Testing %s\n", data.description.c_str() );
219 if( scripts.Count() != data.scriptRuns.Count() )
221 tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
222 for( Vector<ScriptRun>::ConstIterator it = scripts.Begin(); it != scripts.End(); ++it)
224 const ScriptRun& run = *it;
226 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", script : [" << TextAbstraction::ScriptName[run.script] << "]" << std::endl;
231 for( unsigned int index = 0u; index < scripts.Count(); ++index )
233 const ScriptRun& scriptRun1 = scripts[index];
234 const ScriptRun& scriptRun2 = data.scriptRuns[index];
236 if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
238 tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
242 if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
244 tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
248 if( scriptRun1.script != scriptRun2.script )
250 tet_printf("ScriptsTest FAIL: script index: %u, different script. %s, should be %s\n", index, TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
258 bool ValidateFontTest( const ValidateFontsData& data )
260 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
261 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
263 // 1) Convert to utf32
264 Vector<Character> utf32;
265 utf32.Resize( data.text.size() );
267 const uint32_t numberOfCharacters = (data.text.size() == 0 ) ? 0 :
268 Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
271 utf32.Resize( numberOfCharacters );
273 // 2) Set the script info.
274 Vector<ScriptRun> scripts;
275 multilanguageSupport.SetScripts( utf32,
280 char* pathNamePtr = get_current_dir_name();
281 const std::string pathName( pathNamePtr );
284 // Get the default font id.
285 const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
286 data.defaultFontSize );
287 TextAbstraction::FontDescription defaultFontDescription;
288 fontClient.GetDescription( defaultFontId, defaultFontDescription );
290 const TextAbstraction::PointSize26Dot6 defaultPointSize = fontClient.GetPointSize( defaultFontId );
292 Vector<FontRun> fontRuns;
294 // 3) Validate the fonts.
295 multilanguageSupport.ValidateFonts( fontClient,
298 data.fontDescriptionRuns,
299 defaultFontDescription,
306 if( ( 0u != data.index ) ||
307 ( numberOfCharacters != data.numberOfCharacters ) )
309 // 4) Clear the fonts.
310 ClearCharacterRuns( data.index,
311 data.index + data.numberOfCharacters - 1u,
314 multilanguageSupport.ValidateFonts( fontClient,
317 data.fontDescriptionRuns,
318 defaultFontDescription,
322 data.numberOfCharacters,
326 // 5) Compare the results.
327 if( data.fontRuns.Count() != fontRuns.Count() )
329 std::cout << " Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
334 for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
336 const FontRun& run = fontRuns[index];
337 const FontRun& expectedRun = data.fontRuns[index];
339 if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
341 std::cout << " character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
344 if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
346 std::cout << " character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
349 if( run.fontId != expectedRun.fontId )
351 std::cout << " character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
361 int UtcDaliTextGetScript(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliTextGetScript");
366 Script script = TextAbstraction::LATIN;
368 // Text with no scripts.
369 Vector<ScriptRun> scriptRuns;
370 Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
371 script = GetScript( 0u,
375 DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
377 const unsigned int numberOfCharacters = 7u;
379 ScriptRun scriptRun01 =
385 TextAbstraction::LATIN
387 ScriptRun scriptRun02 =
393 TextAbstraction::HEBREW
395 ScriptRun scriptRun03 =
401 TextAbstraction::ARABIC
403 scriptRuns.PushBack( scriptRun01 );
404 scriptRuns.PushBack( scriptRun02 );
405 scriptRuns.PushBack( scriptRun03 );
408 TextAbstraction::Script expectedScripts[]=
410 TextAbstraction::LATIN,
411 TextAbstraction::LATIN,
412 TextAbstraction::HEBREW,
413 TextAbstraction::HEBREW,
414 TextAbstraction::ARABIC,
415 TextAbstraction::ARABIC,
416 TextAbstraction::UNKNOWN
419 scriptRunIt = scriptRuns.Begin();
420 for( unsigned int index = 0u; index < numberOfCharacters; ++index )
422 script = GetScript( index,
426 DALI_TEST_CHECK( expectedScripts[index] == script );
428 DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
430 tet_result(TET_PASS);
434 int UtcDaliTextMergeFontDescriptions(void)
436 ToolkitTestApplication application;
437 tet_infoline(" UtcDaliTextMergeFontDescriptions");
441 char* pathNamePtr = get_current_dir_name();
442 const std::string pathName( pathNamePtr );
445 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
446 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
447 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
448 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
449 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
450 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
452 // To test the font width as GetFontId() with the font file path can't cache the width property.
453 TextAbstraction::FontDescription widthDescription;
454 widthDescription.path = "";
455 widthDescription.family = "DejaVu Serif";
456 widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
457 widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
458 widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
459 fontClient.GetFontId( widthDescription );
463 TextAbstraction::FontDescription defaultFontDescription01;
464 Vector<FontDescriptionRun> fontDescriptionRuns01;
465 Vector<FontId> expectedFontIds01;
466 Vector<bool> expectedIsFontDefault01;
468 TextAbstraction::FontDescription defaultFontDescription02;
469 Vector<FontDescriptionRun> fontDescriptionRuns02;
470 Vector<FontId> expectedFontIds02;
471 expectedFontIds02.PushBack( 0u );
472 expectedFontIds02.PushBack( 0u );
473 Vector<bool> expectedIsFontDefault02;
474 expectedIsFontDefault02.PushBack( true );
475 expectedIsFontDefault02.PushBack( true );
477 TextAbstraction::FontDescription defaultFontDescription03;
478 defaultFontDescription03.family = "DejaVu Serif";
479 Vector<FontDescriptionRun> fontDescriptionRuns03;
481 FontDescriptionRun fontDescription0301 =
487 const_cast<char*>( "DejaVu Sans" ),
489 TextAbstraction::FontWeight::NONE,
490 TextAbstraction::FontWidth::NONE,
491 TextAbstraction::FontSlant::NONE,
492 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
499 FontDescriptionRun fontDescription0302 =
507 TextAbstraction::FontWeight::NONE,
508 TextAbstraction::FontWidth::NONE,
509 TextAbstraction::FontSlant::ITALIC,
510 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
517 FontDescriptionRun fontDescription0303 =
525 TextAbstraction::FontWeight::BOLD,
526 TextAbstraction::FontWidth::NONE,
527 TextAbstraction::FontSlant::NONE,
528 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
535 FontDescriptionRun fontDescription0304 =
543 TextAbstraction::FontWeight::NONE,
544 TextAbstraction::FontWidth::NONE,
545 TextAbstraction::FontSlant::NONE,
546 NON_DEFAULT_FONT_SIZE,
553 FontDescriptionRun fontDescription0305 =
561 TextAbstraction::FontWeight::NONE,
562 TextAbstraction::FontWidth::EXPANDED,
563 TextAbstraction::FontSlant::NONE,
564 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
572 fontDescriptionRuns03.PushBack( fontDescription0301 );
573 fontDescriptionRuns03.PushBack( fontDescription0302 );
574 fontDescriptionRuns03.PushBack( fontDescription0303 );
575 fontDescriptionRuns03.PushBack( fontDescription0304 );
576 fontDescriptionRuns03.PushBack( fontDescription0305 );
578 Vector<FontId> expectedFontIds03;
579 expectedFontIds03.PushBack( 1u );
580 expectedFontIds03.PushBack( 1u );
581 expectedFontIds03.PushBack( 5u );
582 expectedFontIds03.PushBack( 5u );
583 expectedFontIds03.PushBack( 4u );
584 expectedFontIds03.PushBack( 4u );
585 expectedFontIds03.PushBack( 3u );
586 expectedFontIds03.PushBack( 3u );
587 expectedFontIds03.PushBack( 6u );
588 expectedFontIds03.PushBack( 6u );
589 Vector<bool> expectedIsFontDefault03;
590 expectedIsFontDefault03.PushBack( false );
591 expectedIsFontDefault03.PushBack( false );
592 expectedIsFontDefault03.PushBack( false );
593 expectedIsFontDefault03.PushBack( false );
594 expectedIsFontDefault03.PushBack( false );
595 expectedIsFontDefault03.PushBack( false );
596 expectedIsFontDefault03.PushBack( false );
597 expectedIsFontDefault03.PushBack( false );
598 expectedIsFontDefault03.PushBack( false );
599 expectedIsFontDefault03.PushBack( false );
601 const MergeFontDescriptionsData data[] =
605 fontDescriptionRuns01,
606 defaultFontDescription01,
607 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
612 expectedIsFontDefault01
615 "No description runs.",
616 fontDescriptionRuns02,
617 defaultFontDescription02,
618 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
623 expectedIsFontDefault02
626 "Some description runs.",
627 fontDescriptionRuns03,
628 defaultFontDescription03,
629 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
634 expectedIsFontDefault03
637 const unsigned int numberOfTests = 3u;
639 for( unsigned int index = 0u; index < numberOfTests; ++index )
641 if( !MergeFontDescriptionsTest( data[index] ) )
643 tet_result(TET_FAIL);
647 tet_result(TET_PASS);
651 int UtcDaliTextMultiLanguageConstructor(void)
653 ToolkitTestApplication application;
654 tet_infoline(" UtcDaliTextMultiLanguageConstructor");
656 MultilanguageSupport multilanguageSupport;
657 DALI_TEST_CHECK( !multilanguageSupport );
659 MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
660 DALI_TEST_CHECK( multilanguageSupport1 );
662 // To increase coverage.
663 MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
664 DALI_TEST_CHECK( multilanguageSupport2 );
666 DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
668 tet_result(TET_PASS);
672 int UtcDaliTextMultiLanguageSetScripts(void)
674 ToolkitTestApplication application;
675 tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
678 Vector<ScriptRun> scriptRuns00;
681 Vector<ScriptRun> scriptRuns01;
682 ScriptRun scriptRun0100 =
688 TextAbstraction::LATIN
690 scriptRuns01.PushBack( scriptRun0100 );
692 // Mix of LTR '\n'and RTL
693 Vector<ScriptRun> scriptRuns02;
694 ScriptRun scriptRun0200 =
700 TextAbstraction::LATIN
702 ScriptRun scriptRun0201 =
708 TextAbstraction::ARABIC
710 scriptRuns02.PushBack( scriptRun0200 );
711 scriptRuns02.PushBack( scriptRun0201 );
713 // Mix of RTL '\n'and LTR
714 Vector<ScriptRun> scriptRuns03;
715 ScriptRun scriptRun0300 =
721 TextAbstraction::ARABIC
723 ScriptRun scriptRun0301 =
729 TextAbstraction::LATIN
731 scriptRuns03.PushBack( scriptRun0300 );
732 scriptRuns03.PushBack( scriptRun0301 );
734 // White spaces. At the beginning of the text.
735 Vector<ScriptRun> scriptRuns04;
736 ScriptRun scriptRun0400 =
742 TextAbstraction::LATIN
744 scriptRuns04.PushBack( scriptRun0400 );
746 // White spaces. At the end of the text.
747 Vector<ScriptRun> scriptRuns05;
748 ScriptRun scriptRun0500 =
754 TextAbstraction::LATIN
756 scriptRuns05.PushBack( scriptRun0500 );
758 // White spaces. At the middle of the text.
759 Vector<ScriptRun> scriptRuns06;
760 ScriptRun scriptRun0600 =
766 TextAbstraction::LATIN
768 scriptRuns06.PushBack( scriptRun0600 );
770 // White spaces between different scripts.
771 Vector<ScriptRun> scriptRuns07;
772 ScriptRun scriptRun0700 =
778 TextAbstraction::LATIN
780 ScriptRun scriptRun0701 =
786 TextAbstraction::HANGUL
788 scriptRuns07.PushBack( scriptRun0700 );
789 scriptRuns07.PushBack( scriptRun0701 );
791 // White spaces between different scripts and differetn directions. Starting LTR.
792 Vector<ScriptRun> scriptRuns08;
793 ScriptRun scriptRun0800 =
799 TextAbstraction::LATIN
801 ScriptRun scriptRun0801 =
807 TextAbstraction::ARABIC
809 ScriptRun scriptRun0802 =
815 TextAbstraction::HANGUL
817 scriptRuns08.PushBack( scriptRun0800 );
818 scriptRuns08.PushBack( scriptRun0801 );
819 scriptRuns08.PushBack( scriptRun0802 );
821 // White spaces between different scripts and differetn directions. Starting RTL.
822 Vector<ScriptRun> scriptRuns09;
823 ScriptRun scriptRun0900 =
829 TextAbstraction::ARABIC
831 ScriptRun scriptRun0901 =
837 TextAbstraction::LATIN
839 ScriptRun scriptRun0902 =
845 TextAbstraction::HANGUL
847 ScriptRun scriptRun0903 =
853 TextAbstraction::ARABIC
855 scriptRuns09.PushBack( scriptRun0900 );
856 scriptRuns09.PushBack( scriptRun0901 );
857 scriptRuns09.PushBack( scriptRun0902 );
858 scriptRuns09.PushBack( scriptRun0903 );
860 // Paragraphs with different directions.
861 Vector<ScriptRun> scriptRuns10;
862 ScriptRun scriptRun1000 =
868 TextAbstraction::ARABIC
870 ScriptRun scriptRun1001 =
876 TextAbstraction::HEBREW
878 ScriptRun scriptRun1002 =
884 TextAbstraction::ARABIC
886 ScriptRun scriptRun1003 =
892 TextAbstraction::LATIN
894 ScriptRun scriptRun1004 =
900 TextAbstraction::HANGUL
902 ScriptRun scriptRun1005 =
908 TextAbstraction::ARABIC
910 ScriptRun scriptRun1006 =
916 TextAbstraction::LATIN
918 ScriptRun scriptRun1007 =
924 TextAbstraction::HEBREW
926 ScriptRun scriptRun1008 =
932 TextAbstraction::LATIN
934 ScriptRun scriptRun1009 =
940 TextAbstraction::ARABIC
942 ScriptRun scriptRun1010 =
948 TextAbstraction::HANGUL
950 ScriptRun scriptRun1011 =
956 TextAbstraction::HANGUL
958 scriptRuns10.PushBack( scriptRun1000 );
959 scriptRuns10.PushBack( scriptRun1001 );
960 scriptRuns10.PushBack( scriptRun1002 );
961 scriptRuns10.PushBack( scriptRun1003 );
962 scriptRuns10.PushBack( scriptRun1004 );
963 scriptRuns10.PushBack( scriptRun1005 );
964 scriptRuns10.PushBack( scriptRun1006 );
965 scriptRuns10.PushBack( scriptRun1007 );
966 scriptRuns10.PushBack( scriptRun1008 );
967 scriptRuns10.PushBack( scriptRun1009 );
968 scriptRuns10.PushBack( scriptRun1010 );
969 scriptRuns10.PushBack( scriptRun1011 );
971 // Paragraphs with no scripts mixed with paragraphs with scripts.
972 Vector<ScriptRun> scriptRuns11;
973 ScriptRun scriptRun1100 =
979 TextAbstraction::UNKNOWN
981 ScriptRun scriptRun1101 =
987 TextAbstraction::UNKNOWN
989 ScriptRun scriptRun1102 =
995 TextAbstraction::LATIN
997 ScriptRun scriptRun1103 =
1003 TextAbstraction::UNKNOWN
1005 ScriptRun scriptRun1104 =
1011 TextAbstraction::UNKNOWN
1013 ScriptRun scriptRun1105 =
1019 TextAbstraction::HEBREW
1021 ScriptRun scriptRun1106 =
1027 TextAbstraction::UNKNOWN
1029 ScriptRun scriptRun1107 =
1035 TextAbstraction::UNKNOWN
1037 ScriptRun scriptRun1108 =
1043 TextAbstraction::UNKNOWN
1045 scriptRuns11.PushBack( scriptRun1100 );
1046 scriptRuns11.PushBack( scriptRun1101 );
1047 scriptRuns11.PushBack( scriptRun1102 );
1048 scriptRuns11.PushBack( scriptRun1103 );
1049 scriptRuns11.PushBack( scriptRun1104 );
1050 scriptRuns11.PushBack( scriptRun1105 );
1051 scriptRuns11.PushBack( scriptRun1106 );
1052 scriptRuns11.PushBack( scriptRun1107 );
1053 scriptRuns11.PushBack( scriptRun1108 );
1055 // Paragraphs with no scripts.
1056 Vector<ScriptRun> scriptRuns12;
1057 ScriptRun scriptRun1200 =
1063 TextAbstraction::UNKNOWN
1065 ScriptRun scriptRun1201 =
1071 TextAbstraction::UNKNOWN
1073 ScriptRun scriptRun1202 =
1079 TextAbstraction::UNKNOWN
1081 ScriptRun scriptRun1203 =
1087 TextAbstraction::UNKNOWN
1089 scriptRuns12.PushBack( scriptRun1200 );
1090 scriptRuns12.PushBack( scriptRun1201 );
1091 scriptRuns12.PushBack( scriptRun1202 );
1092 scriptRuns12.PushBack( scriptRun1203 );
1094 Vector<ScriptRun> scriptRuns13;
1095 ScriptRun scriptRun1301 =
1101 TextAbstraction::UNKNOWN
1103 scriptRuns13.PushBack( scriptRun1301 );
1105 const ScriptsData data[] =
1115 "Easy latin script",
1122 "Mix of LTR '\\n'and RTL",
1123 "Hello world\nمرحبا بالعالم",
1129 "Update mix of LTR '\\n'and RTL. Update LTR",
1130 "Hello world\nمرحبا بالعالم",
1136 "Update mix of LTR '\\n'and RTL. Update RTL",
1137 "Hello world\nمرحبا بالعالم",
1143 "Mix of RTL '\\n'and LTR",
1144 "مرحبا بالعالم\nHello world",
1150 "Update mix of RTL '\\n'and LTR. Update RTL",
1151 "مرحبا بالعالم\nHello world",
1157 "Update mix of RTL '\\n'and LTR. Update LTR",
1158 "مرحبا بالعالم\nHello world",
1164 "White spaces. At the beginning of the text.",
1171 "White spaces. At the end of the text.",
1178 "White spaces. At the middle of the text.",
1185 "White spaces between different scripts.",
1192 "White spaces between different scripts and differetn directions. Starting LTR.",
1193 " Hello world مرحبا بالعالم 안녕하세요 세계 ",
1199 "White spaces between different scripts and differetn directions. Starting RTL.",
1200 " مرحبا بالعالم Hello world 안녕하세요 세계 مرحبا بالعالم ",
1206 "Paragraphs with different directions.",
1207 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1208 " Hello world 안녕하세요 세계 \n "
1209 " مرحبا بالعالم Hello world שלום עולם \n "
1210 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1217 "Update paragraphs with different directions. Update initial paragraphs.",
1218 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1219 " Hello world 안녕하세요 세계 \n "
1220 " مرحبا بالعالم Hello world שלום עולם \n "
1221 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1228 "Update paragraphs with different directions. Update middle paragraphs.",
1229 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1230 " Hello world 안녕하세요 세계 \n "
1231 " مرحبا بالعالم Hello world שלום עולם \n "
1232 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1239 "Update paragraphs with different directions. Update final paragraphs.",
1240 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1241 " Hello world 안녕하세요 세계 \n "
1242 " مرحبا بالعالم Hello world שלום עולם \n "
1243 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1250 "Paragraphs with no scripts mixed with paragraphs with scripts.",
1251 " \n \n Hello world \n \n \n שלום עולם \n \n \n ",
1257 "Paragraphs with no scripts.",
1264 "Update paragraphs with no scripts. Update initial paragraphs.",
1271 "Update paragraphs with no scripts. Update middle paragraphs.",
1278 "Update paragraphs with no scripts. Update final paragraphs.",
1286 "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1292 const unsigned int numberOfTests = 24u;
1294 for( unsigned int index = 0u; index < numberOfTests; ++index )
1296 if( !ScriptsTest( data[index] ) )
1298 tet_result(TET_FAIL);
1302 tet_result(TET_PASS);
1306 int UtcDaliTextMultiLanguageValidateFonts01(void)
1308 ToolkitTestApplication application;
1309 tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1311 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1313 char* pathNamePtr = get_current_dir_name();
1314 const std::string pathName( pathNamePtr );
1315 free( pathNamePtr );
1317 const PointSize26Dot6 pointSize01 = static_cast<PointSize26Dot6>( 21.f * 64.f );
1318 const PointSize26Dot6 pointSize02 = static_cast<PointSize26Dot6>( 35.f * 64.f );
1321 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1322 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1323 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf", EMOJI_FONT_SIZE );
1324 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 );
1325 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 );
1326 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 );
1327 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 );
1329 // Font id 1 --> TizenSansArabicRegular.ttf
1330 // Font id 2 --> TizenSansHebrewRegular.ttf
1331 // Font id 3 --> BreezeColorEmoji.ttf
1332 // Font id 4 --> TizenSansRegular.ttf, size 8
1333 // Font id 5 --> TizenSansRegular.ttf, size 16
1334 // Font id 6 --> TizenSansHebrewRegular.ttf, size 8
1335 // Font id 7 --> TizenSansHebrewRegular.ttf, size 16
1336 // Font id 8 --> (default)
1338 Vector<FontRun> fontRuns01;
1339 Vector<FontDescriptionRun> fontDescriptions01;
1341 FontRun fontRun0201 =
1349 Vector<FontRun> fontRuns02;
1350 fontRuns02.PushBack( fontRun0201 );
1352 FontDescriptionRun fontDescription0201 =
1358 const_cast<char*>( "TizenSans" ),
1360 TextAbstraction::FontWeight::NORMAL,
1361 TextAbstraction::FontWidth::NORMAL,
1362 TextAbstraction::FontSlant::NORMAL,
1370 Vector<FontDescriptionRun> fontDescriptions02;
1371 fontDescriptions02.PushBack( fontDescription0201 );
1373 FontRun fontRun0301 =
1381 FontRun fontRun0302 =
1389 FontRun fontRun0303 =
1397 Vector<FontRun> fontRuns03;
1398 fontRuns03.PushBack( fontRun0301 );
1399 fontRuns03.PushBack( fontRun0302 );
1400 fontRuns03.PushBack( fontRun0303 );
1402 Vector<FontDescriptionRun> fontDescriptions03;
1404 FontRun fontRun0701 =
1412 FontRun fontRun0702 =
1420 FontRun fontRun0703 =
1428 Vector<FontRun> fontRuns07;
1429 fontRuns07.PushBack( fontRun0701 );
1430 fontRuns07.PushBack( fontRun0702 );
1431 fontRuns07.PushBack( fontRun0703 );
1433 FontDescriptionRun fontDescription0701 =
1439 const_cast<char*>( "TizenSansHebrew" ),
1441 TextAbstraction::FontWeight::NORMAL,
1442 TextAbstraction::FontWidth::NORMAL,
1443 TextAbstraction::FontSlant::NORMAL,
1451 FontDescriptionRun fontDescription0702 =
1457 const_cast<char*>( "TizenSansHebrew" ),
1459 TextAbstraction::FontWeight::NORMAL,
1460 TextAbstraction::FontWidth::NORMAL,
1461 TextAbstraction::FontSlant::NORMAL,
1469 Vector<FontDescriptionRun> fontDescriptions07;
1470 fontDescriptions07.PushBack( fontDescription0701 );
1471 fontDescriptions07.PushBack( fontDescription0702 );
1473 FontRun fontRun0801 =
1481 Vector<FontRun> fontRuns08;
1482 fontRuns08.PushBack( fontRun0801 );
1484 Vector<FontDescriptionRun> fontDescriptions08;
1486 FontRun fontRun0901 =
1494 Vector<FontRun> fontRuns09;
1495 fontRuns09.PushBack( fontRun0901 );
1497 Vector<FontDescriptionRun> fontDescriptions09;
1498 FontDescriptionRun fontDescription0901 =
1504 const_cast<char*>( "BreezeColorEmoji" ),
1506 TextAbstraction::FontWeight::NORMAL,
1507 TextAbstraction::FontWidth::NORMAL,
1508 TextAbstraction::FontSlant::NORMAL,
1516 fontDescriptions09.PushBack( fontDescription0901 );
1518 FontRun fontRun1001 =
1526 FontRun fontRun1002 =
1534 FontRun fontRun1003 =
1542 FontRun fontRun1004 =
1550 Vector<FontRun> fontRuns10;
1551 fontRuns10.PushBack( fontRun1001 );
1552 fontRuns10.PushBack( fontRun1002 );
1553 fontRuns10.PushBack( fontRun1003 );
1554 fontRuns10.PushBack( fontRun1004 );
1556 FontDescriptionRun fontDescription1001 =
1562 const_cast<char*>( "TizenSans" ),
1564 TextAbstraction::FontWeight::NORMAL,
1565 TextAbstraction::FontWidth::NORMAL,
1566 TextAbstraction::FontSlant::NORMAL,
1574 FontDescriptionRun fontDescription1002 =
1580 const_cast<char*>( "TizenSansHebrew" ),
1582 TextAbstraction::FontWeight::NORMAL,
1583 TextAbstraction::FontWidth::NORMAL,
1584 TextAbstraction::FontSlant::NORMAL,
1592 FontDescriptionRun fontDescription1003 =
1598 const_cast<char*>( "TizenSans" ),
1600 TextAbstraction::FontWeight::NORMAL,
1601 TextAbstraction::FontWidth::NORMAL,
1602 TextAbstraction::FontSlant::NORMAL,
1610 FontDescriptionRun fontDescription1004 =
1616 const_cast<char*>( "TizenSansHebrew" ),
1618 TextAbstraction::FontWeight::NORMAL,
1619 TextAbstraction::FontWidth::NORMAL,
1620 TextAbstraction::FontSlant::NORMAL,
1628 Vector<FontDescriptionRun> fontDescriptions10;
1629 fontDescriptions10.PushBack( fontDescription1001 );
1630 fontDescriptions10.PushBack( fontDescription1002 );
1631 fontDescriptions10.PushBack( fontDescription1003 );
1632 fontDescriptions10.PushBack( fontDescription1004 );
1634 FontRun fontRun1101 =
1642 Vector<FontRun> fontRuns11;
1643 fontRuns11.PushBack( fontRun1101 );
1645 FontDescriptionRun fontDescription1101 =
1651 const_cast<char*>( "TizenSans" ),
1653 TextAbstraction::FontWeight::NORMAL,
1654 TextAbstraction::FontWidth::NORMAL,
1655 TextAbstraction::FontSlant::NORMAL,
1663 Vector<FontDescriptionRun> fontDescriptions11;
1664 fontDescriptions11.PushBack( fontDescription1101 );
1666 FontRun fontRun1201 =
1674 FontRun fontRun1202 =
1682 FontRun fontRun1203 =
1690 Vector<FontRun> fontRuns12;
1691 fontRuns12.PushBack( fontRun1201 );
1692 fontRuns12.PushBack( fontRun1202 );
1693 fontRuns12.PushBack( fontRun1203 );
1695 FontDescriptionRun fontDescription1201 =
1701 const_cast<char*>( "TizenSans" ),
1703 TextAbstraction::FontWeight::NORMAL,
1704 TextAbstraction::FontWidth::NORMAL,
1705 TextAbstraction::FontSlant::NORMAL,
1713 FontDescriptionRun fontDescription1202 =
1719 const_cast<char*>( "TizenSans" ),
1721 TextAbstraction::FontWeight::NORMAL,
1722 TextAbstraction::FontWidth::NORMAL,
1723 TextAbstraction::FontSlant::NORMAL,
1731 FontDescriptionRun fontDescription1203 =
1737 const_cast<char*>( "TizenSans" ),
1739 TextAbstraction::FontWeight::NORMAL,
1740 TextAbstraction::FontWidth::NORMAL,
1741 TextAbstraction::FontSlant::NORMAL,
1749 Vector<FontDescriptionRun> fontDescriptions12;
1750 fontDescriptions12.PushBack( fontDescription1201 );
1751 fontDescriptions12.PushBack( fontDescription1202 );
1752 fontDescriptions12.PushBack( fontDescription1203 );
1754 const ValidateFontsData data[] =
1759 "/tizen/TizenSansRegular.ttf",
1760 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1768 "Easy latin script.",
1770 "/tizen/TizenSansRegular.ttf",
1771 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1779 "Different paragraphs.",
1780 "Hello world\nhello world\ndemo",
1781 "/tizen/TizenSansRegular.ttf",
1782 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1790 "Different paragraphs. Update the initial paragraph.",
1791 "Hello world\nhello world\ndemo",
1792 "/tizen/TizenSansRegular.ttf",
1793 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1801 "Different paragraphs. Update the middle paragraph.",
1802 "Hello world\nhello world\ndemo",
1803 "/tizen/TizenSansRegular.ttf",
1804 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1812 "Different paragraphs. Update the final paragraph.",
1813 "Hello world\nhello world\ndemo",
1814 "/tizen/TizenSansRegular.ttf",
1815 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1823 "Hebrew text. Default font: latin",
1825 "/tizen/TizenSansRegular.ttf",
1826 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1834 "Hebrew text. Default font: hebrew",
1836 "/tizen/TizenSansHebrewRegular.ttf",
1837 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1846 "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1847 "/tizen/BreezeColorEmoji.ttf",
1856 "Mix text. Default font: latin. Different font sizes",
1857 "Hello world, שלום עולם, hello world, שלום עולם",
1858 "/tizen/TizenSansRegular.ttf",
1859 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1867 "Unknown script -> changed to LATIN",
1868 "WRC – The Official App",
1869 "/tizen/TizenSansRegular.ttf",
1870 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1880 "/tizen/TizenSansRegular.ttf",
1881 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1889 const unsigned int numberOfTests = 12u;
1891 for( unsigned int index = 0u; index < numberOfTests; ++index )
1893 if( !ValidateFontTest( data[index] ) )
1895 tet_result(TET_FAIL);
1899 tet_result(TET_PASS);
1903 int UtcDaliTextMultiLanguageLocaleChange(void)
1905 ToolkitTestApplication application;
1906 tet_infoline(" UtcDaliTextMultiLanguageLocaleChange");
1908 Adaptor &adaptor = application.GetAdaptor();
1909 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
1911 std::string newLocale = "multi_TEST";
1912 adaptor.LocaleChangedSignal().Emit(newLocale);
1914 application.SendNotification();
1915 application.Render();
1917 DALI_TEST_EQUALS(newLocale.data(), GetImplementation(multilanguageSupport).GetLocale(), TEST_LOCATION);