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 // To be completed ...
249 Vector<FontRun> fontRuns;
251 // 3) Validate the fonts.
252 multilanguageSupport.ValidateFonts( utf32,
254 data.fontDescriptionRuns,
260 if( ( 0u != data.index ) ||
261 ( numberOfCharacters != data.numberOfCharacters ) )
263 // 4) Clear the fonts.
264 ClearCharacterRuns( data.index,
265 data.index + data.numberOfCharacters - 1u,
268 multilanguageSupport.ValidateFonts( utf32,
270 data.fontDescriptionRuns,
273 data.numberOfCharacters,
277 // 5) Compare the results.
278 if( data.fontRuns.Count() != fontRuns.Count() )
280 std::cout << " Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
285 for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
287 const FontRun& run = fontRuns[index];
288 const FontRun& expectedRun = data.fontRuns[index];
290 if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
292 std::cout << " character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
295 if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
297 std::cout << " character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
300 if( run.fontId != expectedRun.fontId )
302 std::cout << " character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
312 int UtcDaliTextGetScript(void)
314 ToolkitTestApplication application;
315 tet_infoline(" UtcDaliTextGetScript");
317 Script script = TextAbstraction::LATIN;
319 // Text with no scripts.
320 Vector<ScriptRun> scriptRuns;
321 Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
322 script = GetScript( 0u,
326 DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
328 const unsigned int numberOfCharacters = 7u;
330 ScriptRun scriptRun01 =
336 TextAbstraction::LATIN
338 ScriptRun scriptRun02 =
344 TextAbstraction::HEBREW
346 ScriptRun scriptRun03 =
352 TextAbstraction::ARABIC
354 scriptRuns.PushBack( scriptRun01 );
355 scriptRuns.PushBack( scriptRun02 );
356 scriptRuns.PushBack( scriptRun03 );
359 TextAbstraction::Script expectedScripts[]=
361 TextAbstraction::LATIN,
362 TextAbstraction::LATIN,
363 TextAbstraction::HEBREW,
364 TextAbstraction::HEBREW,
365 TextAbstraction::ARABIC,
366 TextAbstraction::ARABIC,
367 TextAbstraction::UNKNOWN
370 scriptRunIt = scriptRuns.Begin();
371 for( unsigned int index = 0u; index < numberOfCharacters; ++index )
373 script = GetScript( index,
377 DALI_TEST_CHECK( expectedScripts[index] == script );
379 DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
381 tet_result(TET_PASS);
385 int UtcDaliTextMergeFontDescriptions(void)
387 ToolkitTestApplication application;
388 tet_infoline(" UtcDaliTextMergeFontDescriptions");
392 char* pathNamePtr = get_current_dir_name();
393 const std::string pathName( pathNamePtr );
396 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
397 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
398 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
399 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
400 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
401 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
403 // To test the font width as GetFontId() with the font file path can't cache the width property.
404 TextAbstraction::FontDescription widthDescription;
405 widthDescription.path = "";
406 widthDescription.family = "DejaVu Serif";
407 widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
408 widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
409 widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
410 fontClient.GetFontId( widthDescription );
414 TextAbstraction::FontDescription defaultFontDescription01;
415 Vector<FontDescriptionRun> fontDescriptionRuns01;
416 Vector<FontId> expectedFontIds01;
418 TextAbstraction::FontDescription defaultFontDescription02;
419 Vector<FontDescriptionRun> fontDescriptionRuns02;
420 Vector<FontId> expectedFontIds02;
421 expectedFontIds02.PushBack( 0u );
422 expectedFontIds02.PushBack( 0u );
424 TextAbstraction::FontDescription defaultFontDescription03;
425 defaultFontDescription03.family = "DejaVu Serif";
426 Vector<FontDescriptionRun> fontDescriptionRuns03;
428 FontDescriptionRun fontDescription0301 =
434 const_cast<char*>( "DejaVu Sans" ),
436 TextAbstraction::FontWeight::NORMAL,
437 TextAbstraction::FontWidth::NORMAL,
438 TextAbstraction::FontSlant::NORMAL,
439 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
446 FontDescriptionRun fontDescription0302 =
454 TextAbstraction::FontWeight::NORMAL,
455 TextAbstraction::FontWidth::NORMAL,
456 TextAbstraction::FontSlant::ITALIC,
457 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
464 FontDescriptionRun fontDescription0303 =
472 TextAbstraction::FontWeight::BOLD,
473 TextAbstraction::FontWidth::NORMAL,
474 TextAbstraction::FontSlant::NORMAL,
475 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
482 FontDescriptionRun fontDescription0304 =
490 TextAbstraction::FontWeight::NORMAL,
491 TextAbstraction::FontWidth::NORMAL,
492 TextAbstraction::FontSlant::NORMAL,
493 NON_DEFAULT_FONT_SIZE,
500 FontDescriptionRun fontDescription0305 =
508 TextAbstraction::FontWeight::NORMAL,
509 TextAbstraction::FontWidth::EXPANDED,
510 TextAbstraction::FontSlant::NORMAL,
511 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
519 fontDescriptionRuns03.PushBack( fontDescription0301 );
520 fontDescriptionRuns03.PushBack( fontDescription0302 );
521 fontDescriptionRuns03.PushBack( fontDescription0303 );
522 fontDescriptionRuns03.PushBack( fontDescription0304 );
523 fontDescriptionRuns03.PushBack( fontDescription0305 );
525 Vector<FontId> expectedFontIds03;
526 expectedFontIds03.PushBack( 1u );
527 expectedFontIds03.PushBack( 1u );
528 expectedFontIds03.PushBack( 5u );
529 expectedFontIds03.PushBack( 5u );
530 expectedFontIds03.PushBack( 4u );
531 expectedFontIds03.PushBack( 4u );
532 expectedFontIds03.PushBack( 3u );
533 expectedFontIds03.PushBack( 3u );
534 expectedFontIds03.PushBack( 6u );
535 expectedFontIds03.PushBack( 6u );
537 const MergeFontDescriptionsData data[] =
541 fontDescriptionRuns01,
542 defaultFontDescription01,
543 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
549 "No description runs.",
550 fontDescriptionRuns02,
551 defaultFontDescription02,
552 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
558 "Some description runs.",
559 fontDescriptionRuns03,
560 defaultFontDescription03,
561 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
567 const unsigned int numberOfTests = 3u;
569 for( unsigned int index = 0u; index < numberOfTests; ++index )
571 if( !MergeFontDescriptionsTest( data[index] ) )
573 tet_result(TET_FAIL);
577 tet_result(TET_PASS);
581 int UtcDaliTextMultiLanguageConstructor(void)
583 ToolkitTestApplication application;
584 tet_infoline(" UtcDaliTextMultiLanguageConstructor");
586 MultilanguageSupport multilanguageSupport;
587 DALI_TEST_CHECK( !multilanguageSupport );
589 MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
590 DALI_TEST_CHECK( multilanguageSupport1 );
592 // To increase coverage.
593 MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
594 DALI_TEST_CHECK( multilanguageSupport2 );
596 DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
598 tet_result(TET_PASS);
602 int UtcDaliTextMultiLanguageSetScripts(void)
604 ToolkitTestApplication application;
605 tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
608 Vector<ScriptRun> scriptRuns00;
611 Vector<ScriptRun> scriptRuns01;
612 ScriptRun scriptRun0100 =
618 TextAbstraction::LATIN
620 scriptRuns01.PushBack( scriptRun0100 );
622 // Mix of LTR '\n'and RTL
623 Vector<ScriptRun> scriptRuns02;
624 ScriptRun scriptRun0200 =
630 TextAbstraction::LATIN
632 ScriptRun scriptRun0201 =
638 TextAbstraction::ARABIC
640 scriptRuns02.PushBack( scriptRun0200 );
641 scriptRuns02.PushBack( scriptRun0201 );
643 // Mix of RTL '\n'and LTR
644 Vector<ScriptRun> scriptRuns03;
645 ScriptRun scriptRun0300 =
651 TextAbstraction::ARABIC
653 ScriptRun scriptRun0301 =
659 TextAbstraction::LATIN
661 scriptRuns03.PushBack( scriptRun0300 );
662 scriptRuns03.PushBack( scriptRun0301 );
664 // White spaces. At the beginning of the text.
665 Vector<ScriptRun> scriptRuns04;
666 ScriptRun scriptRun0400 =
672 TextAbstraction::LATIN
674 scriptRuns04.PushBack( scriptRun0400 );
676 // White spaces. At the end of the text.
677 Vector<ScriptRun> scriptRuns05;
678 ScriptRun scriptRun0500 =
684 TextAbstraction::LATIN
686 scriptRuns05.PushBack( scriptRun0500 );
688 // White spaces. At the middle of the text.
689 Vector<ScriptRun> scriptRuns06;
690 ScriptRun scriptRun0600 =
696 TextAbstraction::LATIN
698 scriptRuns06.PushBack( scriptRun0600 );
700 // White spaces between different scripts.
701 Vector<ScriptRun> scriptRuns07;
702 ScriptRun scriptRun0700 =
708 TextAbstraction::LATIN
710 ScriptRun scriptRun0701 =
716 TextAbstraction::HANGUL
718 scriptRuns07.PushBack( scriptRun0700 );
719 scriptRuns07.PushBack( scriptRun0701 );
721 // White spaces between different scripts and differetn directions. Starting LTR.
722 Vector<ScriptRun> scriptRuns08;
723 ScriptRun scriptRun0800 =
729 TextAbstraction::LATIN
731 ScriptRun scriptRun0801 =
737 TextAbstraction::ARABIC
739 ScriptRun scriptRun0802 =
745 TextAbstraction::HANGUL
747 scriptRuns08.PushBack( scriptRun0800 );
748 scriptRuns08.PushBack( scriptRun0801 );
749 scriptRuns08.PushBack( scriptRun0802 );
751 // White spaces between different scripts and differetn directions. Starting RTL.
752 Vector<ScriptRun> scriptRuns09;
753 ScriptRun scriptRun0900 =
759 TextAbstraction::ARABIC
761 ScriptRun scriptRun0901 =
767 TextAbstraction::LATIN
769 ScriptRun scriptRun0902 =
775 TextAbstraction::HANGUL
777 ScriptRun scriptRun0903 =
783 TextAbstraction::ARABIC
785 scriptRuns09.PushBack( scriptRun0900 );
786 scriptRuns09.PushBack( scriptRun0901 );
787 scriptRuns09.PushBack( scriptRun0902 );
788 scriptRuns09.PushBack( scriptRun0903 );
790 // Paragraphs with different directions.
791 Vector<ScriptRun> scriptRuns10;
792 ScriptRun scriptRun1000 =
798 TextAbstraction::ARABIC
800 ScriptRun scriptRun1001 =
806 TextAbstraction::HEBREW
808 ScriptRun scriptRun1002 =
814 TextAbstraction::ARABIC
816 ScriptRun scriptRun1003 =
822 TextAbstraction::LATIN
824 ScriptRun scriptRun1004 =
830 TextAbstraction::HANGUL
832 ScriptRun scriptRun1005 =
838 TextAbstraction::ARABIC
840 ScriptRun scriptRun1006 =
846 TextAbstraction::LATIN
848 ScriptRun scriptRun1007 =
854 TextAbstraction::HEBREW
856 ScriptRun scriptRun1008 =
862 TextAbstraction::LATIN
864 ScriptRun scriptRun1009 =
870 TextAbstraction::ARABIC
872 ScriptRun scriptRun1010 =
878 TextAbstraction::HANGUL
880 ScriptRun scriptRun1011 =
886 TextAbstraction::HANGUL
888 scriptRuns10.PushBack( scriptRun1000 );
889 scriptRuns10.PushBack( scriptRun1001 );
890 scriptRuns10.PushBack( scriptRun1002 );
891 scriptRuns10.PushBack( scriptRun1003 );
892 scriptRuns10.PushBack( scriptRun1004 );
893 scriptRuns10.PushBack( scriptRun1005 );
894 scriptRuns10.PushBack( scriptRun1006 );
895 scriptRuns10.PushBack( scriptRun1007 );
896 scriptRuns10.PushBack( scriptRun1008 );
897 scriptRuns10.PushBack( scriptRun1009 );
898 scriptRuns10.PushBack( scriptRun1010 );
899 scriptRuns10.PushBack( scriptRun1011 );
901 // Paragraphs with no scripts mixed with paragraphs with scripts.
902 Vector<ScriptRun> scriptRuns11;
903 ScriptRun scriptRun1100 =
909 TextAbstraction::LATIN
911 ScriptRun scriptRun1101 =
917 TextAbstraction::LATIN
919 ScriptRun scriptRun1102 =
925 TextAbstraction::LATIN
927 ScriptRun scriptRun1103 =
933 TextAbstraction::LATIN
935 ScriptRun scriptRun1104 =
941 TextAbstraction::LATIN
943 ScriptRun scriptRun1105 =
949 TextAbstraction::HEBREW
951 ScriptRun scriptRun1106 =
957 TextAbstraction::LATIN
959 ScriptRun scriptRun1107 =
965 TextAbstraction::LATIN
967 ScriptRun scriptRun1108 =
973 TextAbstraction::LATIN
975 scriptRuns11.PushBack( scriptRun1100 );
976 scriptRuns11.PushBack( scriptRun1101 );
977 scriptRuns11.PushBack( scriptRun1102 );
978 scriptRuns11.PushBack( scriptRun1103 );
979 scriptRuns11.PushBack( scriptRun1104 );
980 scriptRuns11.PushBack( scriptRun1105 );
981 scriptRuns11.PushBack( scriptRun1106 );
982 scriptRuns11.PushBack( scriptRun1107 );
983 scriptRuns11.PushBack( scriptRun1108 );
985 // Paragraphs with no scripts.
986 Vector<ScriptRun> scriptRuns12;
987 ScriptRun scriptRun1200 =
993 TextAbstraction::LATIN
995 ScriptRun scriptRun1201 =
1001 TextAbstraction::LATIN
1003 ScriptRun scriptRun1202 =
1009 TextAbstraction::LATIN
1011 ScriptRun scriptRun1203 =
1017 TextAbstraction::LATIN
1019 scriptRuns12.PushBack( scriptRun1200 );
1020 scriptRuns12.PushBack( scriptRun1201 );
1021 scriptRuns12.PushBack( scriptRun1202 );
1022 scriptRuns12.PushBack( scriptRun1203 );
1024 Vector<ScriptRun> scriptRuns13;
1025 ScriptRun scriptRun1301 =
1031 TextAbstraction::LATIN // An unknown script is transformed to LATIN
1033 scriptRuns13.PushBack( scriptRun1301 );
1035 const ScriptsData data[] =
1045 "Easy latin script",
1052 "Mix of LTR '\\n'and RTL",
1053 "Hello world\nمرحبا بالعالم",
1059 "Update mix of LTR '\\n'and RTL. Update LTR",
1060 "Hello world\nمرحبا بالعالم",
1066 "Update mix of LTR '\\n'and RTL. Update RTL",
1067 "Hello world\nمرحبا بالعالم",
1073 "Mix of RTL '\\n'and LTR",
1074 "مرحبا بالعالم\nHello world",
1080 "Update mix of RTL '\\n'and LTR. Update RTL",
1081 "مرحبا بالعالم\nHello world",
1087 "Update mix of RTL '\\n'and LTR. Update LTR",
1088 "مرحبا بالعالم\nHello world",
1094 "White spaces. At the beginning of the text.",
1101 "White spaces. At the end of the text.",
1108 "White spaces. At the middle of the text.",
1115 "White spaces between different scripts.",
1122 "White spaces between different scripts and differetn directions. Starting LTR.",
1123 " Hello world مرحبا بالعالم 안녕하세요 세계 ",
1129 "White spaces between different scripts and differetn directions. Starting RTL.",
1130 " مرحبا بالعالم Hello world 안녕하세요 세계 مرحبا بالعالم ",
1136 "Paragraphs with different directions.",
1137 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1138 " Hello world 안녕하세요 세계 \n "
1139 " مرحبا بالعالم Hello world שלום עולם \n "
1140 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1147 "Update paragraphs with different directions. Update initial paragraphs.",
1148 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1149 " Hello world 안녕하세요 세계 \n "
1150 " مرحبا بالعالم Hello world שלום עולם \n "
1151 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1158 "Update paragraphs with different directions. Update middle paragraphs.",
1159 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1160 " Hello world 안녕하세요 세계 \n "
1161 " مرحبا بالعالم Hello world שלום עולם \n "
1162 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1169 "Update paragraphs with different directions. Update final paragraphs.",
1170 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1171 " Hello world 안녕하세요 세계 \n "
1172 " مرحبا بالعالم Hello world שלום עולם \n "
1173 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1180 "Paragraphs with no scripts mixed with paragraphs with scripts.",
1181 " \n \n Hello world \n \n \n שלום עולם \n \n \n ",
1187 "Paragraphs with no scripts.",
1194 "Update paragraphs with no scripts. Update initial paragraphs.",
1201 "Update paragraphs with no scripts. Update middle paragraphs.",
1208 "Update paragraphs with no scripts. Update final paragraphs.",
1216 "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1222 const unsigned int numberOfTests = 24u;
1224 for( unsigned int index = 0u; index < numberOfTests; ++index )
1226 if( !ScriptsTest( data[index] ) )
1228 tet_result(TET_FAIL);
1232 tet_result(TET_PASS);
1236 int UtcDaliTextMultiLanguageValidateFonts01(void)
1238 ToolkitTestApplication application;
1239 tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1241 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1243 char* pathNamePtr = get_current_dir_name();
1244 const std::string pathName( pathNamePtr );
1245 free( pathNamePtr );
1248 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1249 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1250 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
1252 // Font id 1 --> TizenSansArabicRegular.ttf
1253 // Font id 2 --> TizenSansHebrewRegular.ttf
1254 // Font id 3 --> TizenColorEmoji.ttf
1255 // Font id 4 --> (default)
1257 Vector<FontRun> fontRuns01;
1258 Vector<FontDescriptionRun> fontDescriptions01;
1260 FontRun fontRun0201 =
1268 Vector<FontRun> fontRuns02;
1269 fontRuns02.PushBack( fontRun0201 );
1271 FontDescriptionRun fontDescription0201 =
1277 const_cast<char*>( "TizenSans" ),
1279 TextAbstraction::FontWeight::NORMAL,
1280 TextAbstraction::FontWidth::NORMAL,
1281 TextAbstraction::FontSlant::NORMAL,
1289 Vector<FontDescriptionRun> fontDescriptions02;
1290 fontDescriptions02.PushBack( fontDescription0201 );
1292 FontRun fontRun0301 =
1300 FontRun fontRun0302 =
1308 FontRun fontRun0303 =
1316 Vector<FontRun> fontRuns03;
1317 fontRuns03.PushBack( fontRun0301 );
1318 fontRuns03.PushBack( fontRun0302 );
1319 fontRuns03.PushBack( fontRun0303 );
1321 Vector<FontDescriptionRun> fontDescriptions03;
1323 FontRun fontRun0701 =
1331 FontRun fontRun0702 =
1339 FontRun fontRun0703 =
1347 Vector<FontRun> fontRuns07;
1348 fontRuns07.PushBack( fontRun0701 );
1349 fontRuns07.PushBack( fontRun0702 );
1350 fontRuns07.PushBack( fontRun0703 );
1352 FontDescriptionRun fontDescription0701 =
1358 const_cast<char*>( "TizenSansHebrew" ),
1360 TextAbstraction::FontWeight::NORMAL,
1361 TextAbstraction::FontWidth::NORMAL,
1362 TextAbstraction::FontSlant::NORMAL,
1370 FontDescriptionRun fontDescription0702 =
1376 const_cast<char*>( "TizenSansHebrew" ),
1378 TextAbstraction::FontWeight::NORMAL,
1379 TextAbstraction::FontWidth::NORMAL,
1380 TextAbstraction::FontSlant::NORMAL,
1388 Vector<FontDescriptionRun> fontDescriptions07;
1389 fontDescriptions07.PushBack( fontDescription0701 );
1390 fontDescriptions07.PushBack( fontDescription0702 );
1392 FontRun fontRun0801 =
1400 Vector<FontRun> fontRuns08;
1401 fontRuns08.PushBack( fontRun0801 );
1403 Vector<FontDescriptionRun> fontDescriptions08;
1405 FontRun fontRun0901 =
1413 Vector<FontRun> fontRuns09;
1414 fontRuns09.PushBack( fontRun0901 );
1416 Vector<FontDescriptionRun> fontDescriptions09;
1417 FontDescriptionRun fontDescription0901 =
1423 const_cast<char*>( "TizenColorEmoji" ),
1425 TextAbstraction::FontWeight::NORMAL,
1426 TextAbstraction::FontWidth::NORMAL,
1427 TextAbstraction::FontSlant::NORMAL,
1435 fontDescriptions09.PushBack( fontDescription0901 );
1437 const ValidateFontsData data[] =
1442 "/tizen/TizenSansRegular.ttf",
1443 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1450 "Easy latin script.",
1452 "/tizen/TizenSansRegular.ttf",
1453 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1460 "Different paragraphs.",
1461 "Hello world\nhello world\ndemo",
1462 "/tizen/TizenSansRegular.ttf",
1463 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1470 "Different paragraphs. Update the initial paragraph.",
1471 "Hello world\nhello world\ndemo",
1472 "/tizen/TizenSansRegular.ttf",
1473 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1480 "Different paragraphs. Update the middle paragraph.",
1481 "Hello world\nhello world\ndemo",
1482 "/tizen/TizenSansRegular.ttf",
1483 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1490 "Different paragraphs. Update the final paragraph.",
1491 "Hello world\nhello world\ndemo",
1492 "/tizen/TizenSansRegular.ttf",
1493 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1500 "Hebrew text. Default font: latin",
1502 "/tizen/TizenSansRegular.ttf",
1503 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1510 "Hebrew text. Default font: hebrew",
1512 "/tizen/TizenSansHebrewRegular.ttf",
1513 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1521 "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1522 "/tizen/TizenColorEmoji.ttf",
1530 const unsigned int numberOfTests = 9u;
1532 for( unsigned int index = 0u; index < numberOfTests; ++index )
1534 if( !ValidateFontTest( data[index] ) )
1536 tet_result(TET_FAIL);
1540 tet_result(TET_PASS);