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 );
1246 const PointSize26Dot6 pointSize01 = static_cast<PointSize26Dot6>( 21.f * 64.f );
1247 const PointSize26Dot6 pointSize02 = static_cast<PointSize26Dot6>( 35.f * 64.f );
1250 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1251 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1252 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
1253 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 );
1254 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 );
1255 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 );
1256 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 );
1258 // Font id 1 --> TizenSansArabicRegular.ttf
1259 // Font id 2 --> TizenSansHebrewRegular.ttf
1260 // Font id 3 --> TizenColorEmoji.ttf
1261 // Font id 4 --> TizenSansRegular.ttf, size 8
1262 // Font id 5 --> TizenSansRegular.ttf, size 16
1263 // Font id 6 --> TizenSansHebrewRegular.ttf, size 8
1264 // Font id 7 --> TizenSansHebrewRegular.ttf, size 16
1265 // Font id 8 --> (default)
1267 Vector<FontRun> fontRuns01;
1268 Vector<FontDescriptionRun> fontDescriptions01;
1270 FontRun fontRun0201 =
1278 Vector<FontRun> fontRuns02;
1279 fontRuns02.PushBack( fontRun0201 );
1281 FontDescriptionRun fontDescription0201 =
1287 const_cast<char*>( "TizenSans" ),
1289 TextAbstraction::FontWeight::NORMAL,
1290 TextAbstraction::FontWidth::NORMAL,
1291 TextAbstraction::FontSlant::NORMAL,
1299 Vector<FontDescriptionRun> fontDescriptions02;
1300 fontDescriptions02.PushBack( fontDescription0201 );
1302 FontRun fontRun0301 =
1310 FontRun fontRun0302 =
1318 FontRun fontRun0303 =
1326 Vector<FontRun> fontRuns03;
1327 fontRuns03.PushBack( fontRun0301 );
1328 fontRuns03.PushBack( fontRun0302 );
1329 fontRuns03.PushBack( fontRun0303 );
1331 Vector<FontDescriptionRun> fontDescriptions03;
1333 FontRun fontRun0701 =
1341 FontRun fontRun0702 =
1349 FontRun fontRun0703 =
1357 Vector<FontRun> fontRuns07;
1358 fontRuns07.PushBack( fontRun0701 );
1359 fontRuns07.PushBack( fontRun0702 );
1360 fontRuns07.PushBack( fontRun0703 );
1362 FontDescriptionRun fontDescription0701 =
1368 const_cast<char*>( "TizenSansHebrew" ),
1370 TextAbstraction::FontWeight::NORMAL,
1371 TextAbstraction::FontWidth::NORMAL,
1372 TextAbstraction::FontSlant::NORMAL,
1380 FontDescriptionRun fontDescription0702 =
1386 const_cast<char*>( "TizenSansHebrew" ),
1388 TextAbstraction::FontWeight::NORMAL,
1389 TextAbstraction::FontWidth::NORMAL,
1390 TextAbstraction::FontSlant::NORMAL,
1398 Vector<FontDescriptionRun> fontDescriptions07;
1399 fontDescriptions07.PushBack( fontDescription0701 );
1400 fontDescriptions07.PushBack( fontDescription0702 );
1402 FontRun fontRun0801 =
1410 Vector<FontRun> fontRuns08;
1411 fontRuns08.PushBack( fontRun0801 );
1413 Vector<FontDescriptionRun> fontDescriptions08;
1415 FontRun fontRun0901 =
1423 Vector<FontRun> fontRuns09;
1424 fontRuns09.PushBack( fontRun0901 );
1426 Vector<FontDescriptionRun> fontDescriptions09;
1427 FontDescriptionRun fontDescription0901 =
1433 const_cast<char*>( "TizenColorEmoji" ),
1435 TextAbstraction::FontWeight::NORMAL,
1436 TextAbstraction::FontWidth::NORMAL,
1437 TextAbstraction::FontSlant::NORMAL,
1445 fontDescriptions09.PushBack( fontDescription0901 );
1447 FontRun fontRun1001 =
1455 FontRun fontRun1002 =
1463 FontRun fontRun1003 =
1471 FontRun fontRun1004 =
1479 Vector<FontRun> fontRuns10;
1480 fontRuns10.PushBack( fontRun1001 );
1481 fontRuns10.PushBack( fontRun1002 );
1482 fontRuns10.PushBack( fontRun1003 );
1483 fontRuns10.PushBack( fontRun1004 );
1485 FontDescriptionRun fontDescription1001 =
1491 const_cast<char*>( "TizenSans" ),
1493 TextAbstraction::FontWeight::NORMAL,
1494 TextAbstraction::FontWidth::NORMAL,
1495 TextAbstraction::FontSlant::NORMAL,
1503 FontDescriptionRun fontDescription1002 =
1509 const_cast<char*>( "TizenSansHebrew" ),
1511 TextAbstraction::FontWeight::NORMAL,
1512 TextAbstraction::FontWidth::NORMAL,
1513 TextAbstraction::FontSlant::NORMAL,
1521 FontDescriptionRun fontDescription1003 =
1527 const_cast<char*>( "TizenSans" ),
1529 TextAbstraction::FontWeight::NORMAL,
1530 TextAbstraction::FontWidth::NORMAL,
1531 TextAbstraction::FontSlant::NORMAL,
1539 FontDescriptionRun fontDescription1004 =
1545 const_cast<char*>( "TizenSansHebrew" ),
1547 TextAbstraction::FontWeight::NORMAL,
1548 TextAbstraction::FontWidth::NORMAL,
1549 TextAbstraction::FontSlant::NORMAL,
1557 Vector<FontDescriptionRun> fontDescriptions10;
1558 fontDescriptions10.PushBack( fontDescription1001 );
1559 fontDescriptions10.PushBack( fontDescription1002 );
1560 fontDescriptions10.PushBack( fontDescription1003 );
1561 fontDescriptions10.PushBack( fontDescription1004 );
1563 const ValidateFontsData data[] =
1568 "/tizen/TizenSansRegular.ttf",
1569 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1576 "Easy latin script.",
1578 "/tizen/TizenSansRegular.ttf",
1579 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1586 "Different paragraphs.",
1587 "Hello world\nhello world\ndemo",
1588 "/tizen/TizenSansRegular.ttf",
1589 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1596 "Different paragraphs. Update the initial paragraph.",
1597 "Hello world\nhello world\ndemo",
1598 "/tizen/TizenSansRegular.ttf",
1599 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1606 "Different paragraphs. Update the middle paragraph.",
1607 "Hello world\nhello world\ndemo",
1608 "/tizen/TizenSansRegular.ttf",
1609 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1616 "Different paragraphs. Update the final paragraph.",
1617 "Hello world\nhello world\ndemo",
1618 "/tizen/TizenSansRegular.ttf",
1619 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1626 "Hebrew text. Default font: latin",
1628 "/tizen/TizenSansRegular.ttf",
1629 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1636 "Hebrew text. Default font: hebrew",
1638 "/tizen/TizenSansHebrewRegular.ttf",
1639 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1647 "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1648 "/tizen/TizenColorEmoji.ttf",
1656 "Mix text. Default font: latin. Different font sizes",
1657 "Hello world, שלום עולם, hello world, שלום עולם",
1658 "/tizen/TizenSansRegular.ttf",
1659 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1666 const unsigned int numberOfTests = 10u;
1668 for( unsigned int index = 0u; index < numberOfTests; ++index )
1670 if( !ValidateFontTest( data[index] ) )
1672 tet_result(TET_FAIL);
1676 tet_result(TET_PASS);