2 * Copyright (c) 2015 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/segmentation.h>
28 #include <dali-toolkit/internal/text/text-run-container.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
33 using namespace Toolkit;
36 // Tests the following functions with different scripts.
38 // void MergeFontDescriptions( const Vector<FontDescriptionRun>& fontDescriptions,
39 // Vector<FontId>& fontIds,
40 // const TextAbstraction::FontDescription& defaultFontDescription,
41 // TextAbstraction::PointSize26Dot6 defaultPointSize,
42 // CharacterIndex startIndex,
43 // Length numberOfCharacters );
45 // Script GetScript( Length index,
46 // Vector<ScriptRun>::ConstIterator& scriptRunIt,
47 // const Vector<ScriptRun>::ConstIterator& scriptRunEndIt );
49 // Constructor, destructor and MultilanguageSupport::Get()
51 // void MultilanguageSupport::SetScripts( const Vector<Character>& text,
52 // CharacterIndex startIndex,
53 // Length numberOfCharacters,
54 // Vector<ScriptRun>& scripts );
56 // void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
57 // const Vector<ScriptRun>& scripts,
58 // const Vector<FontDescriptionRun>& fontDescriptions,
59 // FontId defaultFontId,
60 // CharacterIndex startIndex,
61 // Length numberOfCharacters,
62 // Vector<FontRun>& fonts );
64 //////////////////////////////////////////////////////////
69 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
70 const unsigned int EMOJI_FONT_SIZE = 3968u;
71 const unsigned int NON_DEFAULT_FONT_SIZE = 40u;
73 struct MergeFontDescriptionsData
75 std::string description; ///< Description of the experiment.
76 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
77 TextAbstraction::FontDescription defaultFontDescription; ///< The default font description.
78 TextAbstraction::PointSize26Dot6 defaultPointSize; ///< The default point size.
79 unsigned int startIndex; ///< The start index.
80 unsigned int numberOfCharacters; ///< The number of characters.
81 Vector<FontId> expectedFontIds; ///< The expected font ids.
86 std::string description; ///< Description of the experiment.
87 std::string text; ///< Input text.
88 unsigned int index; ///< The index of the first character to update the script.
89 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
90 Vector<ScriptRun> scriptRuns; ///< Expected script runs.
93 struct ValidateFontsData
95 std::string description; ///< Description of the experiment.
96 std::string text; ///< Input text.
97 std::string defaultFont; ///< The default font.
98 unsigned int defaultFontSize; ///< The default font size.
99 unsigned int index; ///< The index of the first character to update the script.
100 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
101 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
102 Vector<FontRun> fontRuns; ///< The expected font runs.
105 //////////////////////////////////////////////////////////
107 bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
109 Vector<FontId> fontIds;
110 fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
112 MergeFontDescriptions( data.fontDescriptionRuns,
114 data.defaultFontDescription,
115 data.defaultPointSize,
117 data.numberOfCharacters );
119 if( fontIds.Count() != data.expectedFontIds.Count() )
121 std::cout << data.description << " Different number of font ids : " << fontIds.Count() << ", expected : " << data.expectedFontIds.Count() << std::endl;
125 for( unsigned int index = 0u; index < fontIds.Count(); ++index )
127 if( fontIds[index] != data.expectedFontIds[index] )
129 std::cout << data.description << " Different font id at index : " << index << ", font id : " << fontIds[index] << ", expected : " << data.expectedFontIds[index] << std::endl;
130 std::cout << " font ids : ";
131 for( unsigned int i=0;i<fontIds.Count();++i)
133 std::cout << fontIds[i] << " ";
135 std::cout << std::endl;
136 std::cout << " expected font ids : ";
137 for( unsigned int i=0;i<data.expectedFontIds.Count();++i)
139 std::cout << data.expectedFontIds[i] << " ";
141 std::cout << std::endl;
149 bool ScriptsTest( const ScriptsData& data )
151 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
153 // 1) Convert to utf32
154 Vector<Character> utf32;
155 utf32.Resize( data.text.size() );
157 const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
160 utf32.Resize( numberOfCharacters );
162 // 2) Set the script info.
163 Vector<ScriptRun> scripts;
164 multilanguageSupport.SetScripts( utf32,
169 if( ( 0u != data.index ) ||
170 ( numberOfCharacters != data.numberOfCharacters ) )
172 // 3) Clear the scripts.
173 ClearCharacterRuns( data.index,
174 data.index + data.numberOfCharacters - 1u,
177 multilanguageSupport.SetScripts( utf32,
179 data.numberOfCharacters,
183 // 4) Compare the results.
185 tet_printf( "Testing %s\n", data.description.c_str() );
186 if( scripts.Count() != data.scriptRuns.Count() )
188 tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
192 for( unsigned int index = 0u; index < scripts.Count(); ++index )
194 const ScriptRun& scriptRun1 = scripts[index];
195 const ScriptRun& scriptRun2 = data.scriptRuns[index];
197 if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
199 tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
203 if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
205 tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
209 if( scriptRun1.script != scriptRun2.script )
211 tet_printf("ScriptsTest FAIL: different script. %s, should be %s\n", TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
219 bool ValidateFontTest( const ValidateFontsData& data )
221 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
222 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
224 // 1) Convert to utf32
225 Vector<Character> utf32;
226 utf32.Resize( data.text.size() );
228 const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
231 utf32.Resize( numberOfCharacters );
233 // 2) Set the script info.
234 Vector<ScriptRun> scripts;
235 multilanguageSupport.SetScripts( utf32,
240 char* pathNamePtr = get_current_dir_name();
241 const std::string pathName( pathNamePtr );
244 // Get the default font id.
245 const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
246 data.defaultFontSize );
248 Vector<FontRun> fontRuns;
250 // 3) Validate the fonts.
251 multilanguageSupport.ValidateFonts( utf32,
253 data.fontDescriptionRuns,
259 if( ( 0u != data.index ) ||
260 ( numberOfCharacters != data.numberOfCharacters ) )
262 // 4) Clear the fonts.
263 ClearCharacterRuns( data.index,
264 data.index + data.numberOfCharacters - 1u,
267 multilanguageSupport.ValidateFonts( utf32,
269 data.fontDescriptionRuns,
272 data.numberOfCharacters,
276 // 5) Compare the results.
277 if( data.fontRuns.Count() != fontRuns.Count() )
279 std::cout << " Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
284 for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
286 const FontRun& run = fontRuns[index];
287 const FontRun& expectedRun = data.fontRuns[index];
289 if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
291 std::cout << " character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
294 if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
296 std::cout << " character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
299 if( run.fontId != expectedRun.fontId )
301 std::cout << " character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
311 int UtcDaliTextGetScript(void)
313 ToolkitTestApplication application;
314 tet_infoline(" UtcDaliTextGetScript");
316 Script script = TextAbstraction::LATIN;
318 // Text with no scripts.
319 Vector<ScriptRun> scriptRuns;
320 Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
321 script = GetScript( 0u,
325 DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
327 const unsigned int numberOfCharacters = 7u;
329 ScriptRun scriptRun01 =
335 TextAbstraction::LATIN
337 ScriptRun scriptRun02 =
343 TextAbstraction::HEBREW
345 ScriptRun scriptRun03 =
351 TextAbstraction::ARABIC
353 scriptRuns.PushBack( scriptRun01 );
354 scriptRuns.PushBack( scriptRun02 );
355 scriptRuns.PushBack( scriptRun03 );
358 TextAbstraction::Script expectedScripts[]=
360 TextAbstraction::LATIN,
361 TextAbstraction::LATIN,
362 TextAbstraction::HEBREW,
363 TextAbstraction::HEBREW,
364 TextAbstraction::ARABIC,
365 TextAbstraction::ARABIC,
366 TextAbstraction::UNKNOWN
369 scriptRunIt = scriptRuns.Begin();
370 for( unsigned int index = 0u; index < numberOfCharacters; ++index )
372 script = GetScript( index,
376 DALI_TEST_CHECK( expectedScripts[index] == script );
378 DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
380 tet_result(TET_PASS);
384 int UtcDaliTextMergeFontDescriptions(void)
386 ToolkitTestApplication application;
387 tet_infoline(" UtcDaliTextMergeFontDescriptions");
391 char* pathNamePtr = get_current_dir_name();
392 const std::string pathName( pathNamePtr );
395 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
396 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
397 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
398 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
399 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
400 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
402 // To test the font width as GetFontId() with the font file path can't cache the width property.
403 TextAbstraction::FontDescription widthDescription;
404 widthDescription.path = "";
405 widthDescription.family = "DejaVu Serif";
406 widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
407 widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
408 widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
409 fontClient.GetFontId( widthDescription );
413 TextAbstraction::FontDescription defaultFontDescription01;
414 Vector<FontDescriptionRun> fontDescriptionRuns01;
415 Vector<FontId> expectedFontIds01;
417 TextAbstraction::FontDescription defaultFontDescription02;
418 Vector<FontDescriptionRun> fontDescriptionRuns02;
419 Vector<FontId> expectedFontIds02;
420 expectedFontIds02.PushBack( 0u );
421 expectedFontIds02.PushBack( 0u );
423 TextAbstraction::FontDescription defaultFontDescription03;
424 defaultFontDescription03.family = "DejaVu Serif";
425 Vector<FontDescriptionRun> fontDescriptionRuns03;
427 FontDescriptionRun fontDescription0301 =
433 const_cast<char*>( "DejaVu Sans" ),
435 TextAbstraction::FontWeight::NORMAL,
436 TextAbstraction::FontWidth::NORMAL,
437 TextAbstraction::FontSlant::NORMAL,
438 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
445 FontDescriptionRun fontDescription0302 =
453 TextAbstraction::FontWeight::NORMAL,
454 TextAbstraction::FontWidth::NORMAL,
455 TextAbstraction::FontSlant::ITALIC,
456 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
463 FontDescriptionRun fontDescription0303 =
471 TextAbstraction::FontWeight::BOLD,
472 TextAbstraction::FontWidth::NORMAL,
473 TextAbstraction::FontSlant::NORMAL,
474 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
481 FontDescriptionRun fontDescription0304 =
489 TextAbstraction::FontWeight::NORMAL,
490 TextAbstraction::FontWidth::NORMAL,
491 TextAbstraction::FontSlant::NORMAL,
492 NON_DEFAULT_FONT_SIZE,
499 FontDescriptionRun fontDescription0305 =
507 TextAbstraction::FontWeight::NORMAL,
508 TextAbstraction::FontWidth::EXPANDED,
509 TextAbstraction::FontSlant::NORMAL,
510 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
518 fontDescriptionRuns03.PushBack( fontDescription0301 );
519 fontDescriptionRuns03.PushBack( fontDescription0302 );
520 fontDescriptionRuns03.PushBack( fontDescription0303 );
521 fontDescriptionRuns03.PushBack( fontDescription0304 );
522 fontDescriptionRuns03.PushBack( fontDescription0305 );
524 Vector<FontId> expectedFontIds03;
525 expectedFontIds03.PushBack( 1u );
526 expectedFontIds03.PushBack( 1u );
527 expectedFontIds03.PushBack( 5u );
528 expectedFontIds03.PushBack( 5u );
529 expectedFontIds03.PushBack( 4u );
530 expectedFontIds03.PushBack( 4u );
531 expectedFontIds03.PushBack( 3u );
532 expectedFontIds03.PushBack( 3u );
533 expectedFontIds03.PushBack( 6u );
534 expectedFontIds03.PushBack( 6u );
536 const MergeFontDescriptionsData data[] =
540 fontDescriptionRuns01,
541 defaultFontDescription01,
542 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
548 "No description runs.",
549 fontDescriptionRuns02,
550 defaultFontDescription02,
551 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
557 "Some description runs.",
558 fontDescriptionRuns03,
559 defaultFontDescription03,
560 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
566 const unsigned int numberOfTests = 3u;
568 for( unsigned int index = 0u; index < numberOfTests; ++index )
570 if( !MergeFontDescriptionsTest( data[index] ) )
572 tet_result(TET_FAIL);
576 tet_result(TET_PASS);
580 int UtcDaliTextMultiLanguageConstructor(void)
582 ToolkitTestApplication application;
583 tet_infoline(" UtcDaliTextMultiLanguageConstructor");
585 MultilanguageSupport multilanguageSupport;
586 DALI_TEST_CHECK( !multilanguageSupport );
588 MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
589 DALI_TEST_CHECK( multilanguageSupport1 );
591 // To increase coverage.
592 MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
593 DALI_TEST_CHECK( multilanguageSupport2 );
595 DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
597 tet_result(TET_PASS);
601 int UtcDaliTextMultiLanguageSetScripts(void)
603 ToolkitTestApplication application;
604 tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
607 Vector<ScriptRun> scriptRuns00;
610 Vector<ScriptRun> scriptRuns01;
611 ScriptRun scriptRun0100 =
617 TextAbstraction::LATIN
619 scriptRuns01.PushBack( scriptRun0100 );
621 // Mix of LTR '\n'and RTL
622 Vector<ScriptRun> scriptRuns02;
623 ScriptRun scriptRun0200 =
629 TextAbstraction::LATIN
631 ScriptRun scriptRun0201 =
637 TextAbstraction::ARABIC
639 scriptRuns02.PushBack( scriptRun0200 );
640 scriptRuns02.PushBack( scriptRun0201 );
642 // Mix of RTL '\n'and LTR
643 Vector<ScriptRun> scriptRuns03;
644 ScriptRun scriptRun0300 =
650 TextAbstraction::ARABIC
652 ScriptRun scriptRun0301 =
658 TextAbstraction::LATIN
660 scriptRuns03.PushBack( scriptRun0300 );
661 scriptRuns03.PushBack( scriptRun0301 );
663 // White spaces. At the beginning of the text.
664 Vector<ScriptRun> scriptRuns04;
665 ScriptRun scriptRun0400 =
671 TextAbstraction::LATIN
673 scriptRuns04.PushBack( scriptRun0400 );
675 // White spaces. At the end of the text.
676 Vector<ScriptRun> scriptRuns05;
677 ScriptRun scriptRun0500 =
683 TextAbstraction::LATIN
685 scriptRuns05.PushBack( scriptRun0500 );
687 // White spaces. At the middle of the text.
688 Vector<ScriptRun> scriptRuns06;
689 ScriptRun scriptRun0600 =
695 TextAbstraction::LATIN
697 scriptRuns06.PushBack( scriptRun0600 );
699 // White spaces between different scripts.
700 Vector<ScriptRun> scriptRuns07;
701 ScriptRun scriptRun0700 =
707 TextAbstraction::LATIN
709 ScriptRun scriptRun0701 =
715 TextAbstraction::HANGUL
717 scriptRuns07.PushBack( scriptRun0700 );
718 scriptRuns07.PushBack( scriptRun0701 );
720 // White spaces between different scripts and differetn directions. Starting LTR.
721 Vector<ScriptRun> scriptRuns08;
722 ScriptRun scriptRun0800 =
728 TextAbstraction::LATIN
730 ScriptRun scriptRun0801 =
736 TextAbstraction::ARABIC
738 ScriptRun scriptRun0802 =
744 TextAbstraction::HANGUL
746 scriptRuns08.PushBack( scriptRun0800 );
747 scriptRuns08.PushBack( scriptRun0801 );
748 scriptRuns08.PushBack( scriptRun0802 );
750 // White spaces between different scripts and differetn directions. Starting RTL.
751 Vector<ScriptRun> scriptRuns09;
752 ScriptRun scriptRun0900 =
758 TextAbstraction::ARABIC
760 ScriptRun scriptRun0901 =
766 TextAbstraction::LATIN
768 ScriptRun scriptRun0902 =
774 TextAbstraction::HANGUL
776 ScriptRun scriptRun0903 =
782 TextAbstraction::ARABIC
784 scriptRuns09.PushBack( scriptRun0900 );
785 scriptRuns09.PushBack( scriptRun0901 );
786 scriptRuns09.PushBack( scriptRun0902 );
787 scriptRuns09.PushBack( scriptRun0903 );
789 // Paragraphs with different directions.
790 Vector<ScriptRun> scriptRuns10;
791 ScriptRun scriptRun1000 =
797 TextAbstraction::ARABIC
799 ScriptRun scriptRun1001 =
805 TextAbstraction::HEBREW
807 ScriptRun scriptRun1002 =
813 TextAbstraction::ARABIC
815 ScriptRun scriptRun1003 =
821 TextAbstraction::LATIN
823 ScriptRun scriptRun1004 =
829 TextAbstraction::HANGUL
831 ScriptRun scriptRun1005 =
837 TextAbstraction::ARABIC
839 ScriptRun scriptRun1006 =
845 TextAbstraction::LATIN
847 ScriptRun scriptRun1007 =
853 TextAbstraction::HEBREW
855 ScriptRun scriptRun1008 =
861 TextAbstraction::LATIN
863 ScriptRun scriptRun1009 =
869 TextAbstraction::ARABIC
871 ScriptRun scriptRun1010 =
877 TextAbstraction::HANGUL
879 ScriptRun scriptRun1011 =
885 TextAbstraction::HANGUL
887 scriptRuns10.PushBack( scriptRun1000 );
888 scriptRuns10.PushBack( scriptRun1001 );
889 scriptRuns10.PushBack( scriptRun1002 );
890 scriptRuns10.PushBack( scriptRun1003 );
891 scriptRuns10.PushBack( scriptRun1004 );
892 scriptRuns10.PushBack( scriptRun1005 );
893 scriptRuns10.PushBack( scriptRun1006 );
894 scriptRuns10.PushBack( scriptRun1007 );
895 scriptRuns10.PushBack( scriptRun1008 );
896 scriptRuns10.PushBack( scriptRun1009 );
897 scriptRuns10.PushBack( scriptRun1010 );
898 scriptRuns10.PushBack( scriptRun1011 );
900 // Paragraphs with no scripts mixed with paragraphs with scripts.
901 Vector<ScriptRun> scriptRuns11;
902 ScriptRun scriptRun1100 =
908 TextAbstraction::LATIN
910 ScriptRun scriptRun1101 =
916 TextAbstraction::LATIN
918 ScriptRun scriptRun1102 =
924 TextAbstraction::LATIN
926 ScriptRun scriptRun1103 =
932 TextAbstraction::LATIN
934 ScriptRun scriptRun1104 =
940 TextAbstraction::LATIN
942 ScriptRun scriptRun1105 =
948 TextAbstraction::HEBREW
950 ScriptRun scriptRun1106 =
956 TextAbstraction::LATIN
958 ScriptRun scriptRun1107 =
964 TextAbstraction::LATIN
966 ScriptRun scriptRun1108 =
972 TextAbstraction::LATIN
974 scriptRuns11.PushBack( scriptRun1100 );
975 scriptRuns11.PushBack( scriptRun1101 );
976 scriptRuns11.PushBack( scriptRun1102 );
977 scriptRuns11.PushBack( scriptRun1103 );
978 scriptRuns11.PushBack( scriptRun1104 );
979 scriptRuns11.PushBack( scriptRun1105 );
980 scriptRuns11.PushBack( scriptRun1106 );
981 scriptRuns11.PushBack( scriptRun1107 );
982 scriptRuns11.PushBack( scriptRun1108 );
984 // Paragraphs with no scripts.
985 Vector<ScriptRun> scriptRuns12;
986 ScriptRun scriptRun1200 =
992 TextAbstraction::LATIN
994 ScriptRun scriptRun1201 =
1000 TextAbstraction::LATIN
1002 ScriptRun scriptRun1202 =
1008 TextAbstraction::LATIN
1010 ScriptRun scriptRun1203 =
1016 TextAbstraction::LATIN
1018 scriptRuns12.PushBack( scriptRun1200 );
1019 scriptRuns12.PushBack( scriptRun1201 );
1020 scriptRuns12.PushBack( scriptRun1202 );
1021 scriptRuns12.PushBack( scriptRun1203 );
1023 Vector<ScriptRun> scriptRuns13;
1024 ScriptRun scriptRun1301 =
1030 TextAbstraction::LATIN // An unknown script is transformed to LATIN
1032 scriptRuns13.PushBack( scriptRun1301 );
1034 const ScriptsData data[] =
1044 "Easy latin script",
1051 "Mix of LTR '\\n'and RTL",
1052 "Hello world\nمرحبا بالعالم",
1058 "Update mix of LTR '\\n'and RTL. Update LTR",
1059 "Hello world\nمرحبا بالعالم",
1065 "Update mix of LTR '\\n'and RTL. Update RTL",
1066 "Hello world\nمرحبا بالعالم",
1072 "Mix of RTL '\\n'and LTR",
1073 "مرحبا بالعالم\nHello world",
1079 "Update mix of RTL '\\n'and LTR. Update RTL",
1080 "مرحبا بالعالم\nHello world",
1086 "Update mix of RTL '\\n'and LTR. Update LTR",
1087 "مرحبا بالعالم\nHello world",
1093 "White spaces. At the beginning of the text.",
1100 "White spaces. At the end of the text.",
1107 "White spaces. At the middle of the text.",
1114 "White spaces between different scripts.",
1121 "White spaces between different scripts and differetn directions. Starting LTR.",
1122 " Hello world مرحبا بالعالم 안녕하세요 세계 ",
1128 "White spaces between different scripts and differetn directions. Starting RTL.",
1129 " مرحبا بالعالم Hello world 안녕하세요 세계 مرحبا بالعالم ",
1135 "Paragraphs with different directions.",
1136 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1137 " Hello world 안녕하세요 세계 \n "
1138 " مرحبا بالعالم Hello world שלום עולם \n "
1139 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1146 "Update paragraphs with different directions. Update initial paragraphs.",
1147 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1148 " Hello world 안녕하세요 세계 \n "
1149 " مرحبا بالعالم Hello world שלום עולם \n "
1150 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1157 "Update paragraphs with different directions. Update middle paragraphs.",
1158 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1159 " Hello world 안녕하세요 세계 \n "
1160 " مرحبا بالعالم Hello world שלום עולם \n "
1161 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1168 "Update paragraphs with different directions. Update final paragraphs.",
1169 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1170 " Hello world 안녕하세요 세계 \n "
1171 " مرحبا بالعالم Hello world שלום עולם \n "
1172 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1179 "Paragraphs with no scripts mixed with paragraphs with scripts.",
1180 " \n \n Hello world \n \n \n שלום עולם \n \n \n ",
1186 "Paragraphs with no scripts.",
1193 "Update paragraphs with no scripts. Update initial paragraphs.",
1200 "Update paragraphs with no scripts. Update middle paragraphs.",
1207 "Update paragraphs with no scripts. Update final paragraphs.",
1215 "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1221 const unsigned int numberOfTests = 24u;
1223 for( unsigned int index = 0u; index < numberOfTests; ++index )
1225 if( !ScriptsTest( data[index] ) )
1227 tet_result(TET_FAIL);
1231 tet_result(TET_PASS);
1235 int UtcDaliTextMultiLanguageValidateFonts01(void)
1237 ToolkitTestApplication application;
1238 tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1240 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1242 char* pathNamePtr = get_current_dir_name();
1243 const std::string pathName( pathNamePtr );
1244 free( pathNamePtr );
1247 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1248 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1249 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
1251 // Font id 1 --> TizenSansArabicRegular.ttf
1252 // Font id 2 --> TizenSansHebrewRegular.ttf
1253 // Font id 3 --> TizenColorEmoji.ttf
1254 // Font id 4 --> (default)
1256 Vector<FontRun> fontRuns01;
1257 Vector<FontDescriptionRun> fontDescriptions01;
1259 FontRun fontRun0201 =
1267 Vector<FontRun> fontRuns02;
1268 fontRuns02.PushBack( fontRun0201 );
1270 FontDescriptionRun fontDescription0201 =
1276 const_cast<char*>( "TizenSans" ),
1278 TextAbstraction::FontWeight::NORMAL,
1279 TextAbstraction::FontWidth::NORMAL,
1280 TextAbstraction::FontSlant::NORMAL,
1288 Vector<FontDescriptionRun> fontDescriptions02;
1289 fontDescriptions02.PushBack( fontDescription0201 );
1291 FontRun fontRun0301 =
1299 FontRun fontRun0302 =
1307 FontRun fontRun0303 =
1315 Vector<FontRun> fontRuns03;
1316 fontRuns03.PushBack( fontRun0301 );
1317 fontRuns03.PushBack( fontRun0302 );
1318 fontRuns03.PushBack( fontRun0303 );
1320 Vector<FontDescriptionRun> fontDescriptions03;
1322 FontRun fontRun0701 =
1330 FontRun fontRun0702 =
1338 FontRun fontRun0703 =
1346 Vector<FontRun> fontRuns07;
1347 fontRuns07.PushBack( fontRun0701 );
1348 fontRuns07.PushBack( fontRun0702 );
1349 fontRuns07.PushBack( fontRun0703 );
1351 FontDescriptionRun fontDescription0701 =
1357 const_cast<char*>( "TizenSansHebrew" ),
1359 TextAbstraction::FontWeight::NORMAL,
1360 TextAbstraction::FontWidth::NORMAL,
1361 TextAbstraction::FontSlant::NORMAL,
1369 FontDescriptionRun fontDescription0702 =
1375 const_cast<char*>( "TizenSansHebrew" ),
1377 TextAbstraction::FontWeight::NORMAL,
1378 TextAbstraction::FontWidth::NORMAL,
1379 TextAbstraction::FontSlant::NORMAL,
1387 Vector<FontDescriptionRun> fontDescriptions07;
1388 fontDescriptions07.PushBack( fontDescription0701 );
1389 fontDescriptions07.PushBack( fontDescription0702 );
1391 FontRun fontRun0801 =
1399 Vector<FontRun> fontRuns08;
1400 fontRuns08.PushBack( fontRun0801 );
1402 Vector<FontDescriptionRun> fontDescriptions08;
1404 FontRun fontRun0901 =
1412 Vector<FontRun> fontRuns09;
1413 fontRuns09.PushBack( fontRun0901 );
1415 Vector<FontDescriptionRun> fontDescriptions09;
1416 FontDescriptionRun fontDescription0901 =
1422 const_cast<char*>( "TizenColorEmoji" ),
1424 TextAbstraction::FontWeight::NORMAL,
1425 TextAbstraction::FontWidth::NORMAL,
1426 TextAbstraction::FontSlant::NORMAL,
1434 fontDescriptions09.PushBack( fontDescription0901 );
1436 const ValidateFontsData data[] =
1441 "/tizen/TizenSansRegular.ttf",
1442 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1449 "Easy latin script.",
1451 "/tizen/TizenSansRegular.ttf",
1452 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1459 "Different paragraphs.",
1460 "Hello world\nhello world\ndemo",
1461 "/tizen/TizenSansRegular.ttf",
1462 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1469 "Different paragraphs. Update the initial paragraph.",
1470 "Hello world\nhello world\ndemo",
1471 "/tizen/TizenSansRegular.ttf",
1472 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1479 "Different paragraphs. Update the middle paragraph.",
1480 "Hello world\nhello world\ndemo",
1481 "/tizen/TizenSansRegular.ttf",
1482 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1489 "Different paragraphs. Update the final paragraph.",
1490 "Hello world\nhello world\ndemo",
1491 "/tizen/TizenSansRegular.ttf",
1492 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1499 "Hebrew text. Default font: latin",
1501 "/tizen/TizenSansRegular.ttf",
1502 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1509 "Hebrew text. Default font: hebrew",
1511 "/tizen/TizenSansHebrewRegular.ttf",
1512 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1520 "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1521 "/tizen/TizenColorEmoji.ttf",
1529 const unsigned int numberOfTests = 9u;
1531 for( unsigned int index = 0u; index < numberOfTests; ++index )
1533 if( !ValidateFontTest( data[index] ) )
1535 tet_result(TET_FAIL);
1539 tet_result(TET_PASS);