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 // Vector<bool>& isDefaultFont,
41 // const TextAbstraction::FontDescription& defaultFontDescription,
42 // TextAbstraction::PointSize26Dot6 defaultPointSize,
43 // CharacterIndex startIndex,
44 // Length numberOfCharacters );
46 // Script GetScript( Length index,
47 // Vector<ScriptRun>::ConstIterator& scriptRunIt,
48 // const Vector<ScriptRun>::ConstIterator& scriptRunEndIt );
50 // Constructor, destructor and MultilanguageSupport::Get()
52 // void MultilanguageSupport::SetScripts( const Vector<Character>& text,
53 // CharacterIndex startIndex,
54 // Length numberOfCharacters,
55 // Vector<ScriptRun>& scripts );
57 // void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
58 // const Vector<ScriptRun>& scripts,
59 // const Vector<FontDescriptionRun>& fontDescriptions,
60 // FontId defaultFontId,
61 // CharacterIndex startIndex,
62 // Length numberOfCharacters,
63 // Vector<FontRun>& fonts );
65 //////////////////////////////////////////////////////////
70 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
71 const unsigned int EMOJI_FONT_SIZE = 3968u;
72 const unsigned int NON_DEFAULT_FONT_SIZE = 40u;
74 struct MergeFontDescriptionsData
76 std::string description; ///< Description of the experiment.
77 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
78 TextAbstraction::FontDescription defaultFontDescription; ///< The default font description.
79 TextAbstraction::PointSize26Dot6 defaultPointSize; ///< The default point size.
80 unsigned int startIndex; ///< The start index.
81 unsigned int numberOfCharacters; ///< The number of characters.
82 Vector<FontId> expectedFontIds; ///< The expected font ids.
83 Vector<bool> expectedIsDefault; ///< The expected font ids.
88 std::string description; ///< Description of the experiment.
89 std::string text; ///< Input text.
90 unsigned int index; ///< The index of the first character to update the script.
91 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
92 Vector<ScriptRun> scriptRuns; ///< Expected script runs.
95 struct ValidateFontsData
97 std::string description; ///< Description of the experiment.
98 std::string text; ///< Input text.
99 std::string defaultFont; ///< The default font.
100 unsigned int defaultFontSize; ///< The default font size.
101 unsigned int index; ///< The index of the first character to update the script.
102 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
103 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
104 Vector<FontRun> fontRuns; ///< The expected font runs.
107 //////////////////////////////////////////////////////////
109 bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
111 Vector<FontId> fontIds;
112 fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
113 Vector<bool> isDefaultFont;
114 isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true );
116 MergeFontDescriptions( data.fontDescriptionRuns,
119 data.defaultFontDescription,
120 data.defaultPointSize,
122 data.numberOfCharacters );
124 if( fontIds.Count() != data.expectedFontIds.Count() )
126 std::cout << data.description << " Different number of font ids : " << fontIds.Count() << ", expected : " << data.expectedFontIds.Count() << std::endl;
130 for( unsigned int index = 0u; index < fontIds.Count(); ++index )
132 if( fontIds[index] != data.expectedFontIds[index] )
134 std::cout << data.description << " Different font id at index : " << index << ", font id : " << fontIds[index] << ", expected : " << data.expectedFontIds[index] << std::endl;
135 std::cout << " font ids : ";
136 for( unsigned int i=0;i<fontIds.Count();++i)
138 std::cout << fontIds[i] << " ";
140 std::cout << std::endl;
141 std::cout << " expected font ids : ";
142 for( unsigned int i=0;i<data.expectedFontIds.Count();++i)
144 std::cout << data.expectedFontIds[i] << " ";
146 std::cout << std::endl;
150 if( isDefaultFont[index] != data.expectedIsDefault[index] )
152 std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl;
160 bool ScriptsTest( const ScriptsData& data )
162 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
164 // 1) Convert to utf32
165 Vector<Character> utf32;
166 utf32.Resize( data.text.size() );
168 const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
171 utf32.Resize( numberOfCharacters );
173 // 2) Set the script info.
174 Vector<ScriptRun> scripts;
175 multilanguageSupport.SetScripts( utf32,
180 if( ( 0u != data.index ) ||
181 ( numberOfCharacters != data.numberOfCharacters ) )
183 // 3) Clear the scripts.
184 ClearCharacterRuns( data.index,
185 data.index + data.numberOfCharacters - 1u,
188 multilanguageSupport.SetScripts( utf32,
190 data.numberOfCharacters,
194 // 4) Compare the results.
196 tet_printf( "Testing %s\n", data.description.c_str() );
197 if( scripts.Count() != data.scriptRuns.Count() )
199 tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
200 for( Vector<ScriptRun>::ConstIterator it = scripts.Begin(); it != scripts.End(); ++it)
202 const ScriptRun& run = *it;
204 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", script : [" << TextAbstraction::ScriptName[run.script] << "]" << std::endl;
209 for( unsigned int index = 0u; index < scripts.Count(); ++index )
211 const ScriptRun& scriptRun1 = scripts[index];
212 const ScriptRun& scriptRun2 = data.scriptRuns[index];
214 if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
216 tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
220 if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
222 tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
226 if( scriptRun1.script != scriptRun2.script )
228 tet_printf("ScriptsTest FAIL: different script. %s, should be %s\n", TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
236 bool ValidateFontTest( const ValidateFontsData& data )
238 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
239 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
241 // 1) Convert to utf32
242 Vector<Character> utf32;
243 utf32.Resize( data.text.size() );
245 const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
248 utf32.Resize( numberOfCharacters );
250 // 2) Set the script info.
251 Vector<ScriptRun> scripts;
252 multilanguageSupport.SetScripts( utf32,
257 char* pathNamePtr = get_current_dir_name();
258 const std::string pathName( pathNamePtr );
261 // Get the default font id.
262 const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
263 data.defaultFontSize );
265 Vector<FontRun> fontRuns;
267 // 3) Validate the fonts.
268 multilanguageSupport.ValidateFonts( utf32,
270 data.fontDescriptionRuns,
276 if( ( 0u != data.index ) ||
277 ( numberOfCharacters != data.numberOfCharacters ) )
279 // 4) Clear the fonts.
280 ClearCharacterRuns( data.index,
281 data.index + data.numberOfCharacters - 1u,
284 multilanguageSupport.ValidateFonts( utf32,
286 data.fontDescriptionRuns,
289 data.numberOfCharacters,
293 // 5) Compare the results.
294 if( data.fontRuns.Count() != fontRuns.Count() )
296 std::cout << " Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
301 for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
303 const FontRun& run = fontRuns[index];
304 const FontRun& expectedRun = data.fontRuns[index];
306 if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
308 std::cout << " character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
311 if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
313 std::cout << " character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
316 if( run.fontId != expectedRun.fontId )
318 std::cout << " character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
328 int UtcDaliTextGetScript(void)
330 ToolkitTestApplication application;
331 tet_infoline(" UtcDaliTextGetScript");
333 Script script = TextAbstraction::LATIN;
335 // Text with no scripts.
336 Vector<ScriptRun> scriptRuns;
337 Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
338 script = GetScript( 0u,
342 DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
344 const unsigned int numberOfCharacters = 7u;
346 ScriptRun scriptRun01 =
352 TextAbstraction::LATIN
354 ScriptRun scriptRun02 =
360 TextAbstraction::HEBREW
362 ScriptRun scriptRun03 =
368 TextAbstraction::ARABIC
370 scriptRuns.PushBack( scriptRun01 );
371 scriptRuns.PushBack( scriptRun02 );
372 scriptRuns.PushBack( scriptRun03 );
375 TextAbstraction::Script expectedScripts[]=
377 TextAbstraction::LATIN,
378 TextAbstraction::LATIN,
379 TextAbstraction::HEBREW,
380 TextAbstraction::HEBREW,
381 TextAbstraction::ARABIC,
382 TextAbstraction::ARABIC,
383 TextAbstraction::UNKNOWN
386 scriptRunIt = scriptRuns.Begin();
387 for( unsigned int index = 0u; index < numberOfCharacters; ++index )
389 script = GetScript( index,
393 DALI_TEST_CHECK( expectedScripts[index] == script );
395 DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
397 tet_result(TET_PASS);
401 int UtcDaliTextMergeFontDescriptions(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliTextMergeFontDescriptions");
408 char* pathNamePtr = get_current_dir_name();
409 const std::string pathName( pathNamePtr );
412 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
413 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
414 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
415 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
416 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
417 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
419 // To test the font width as GetFontId() with the font file path can't cache the width property.
420 TextAbstraction::FontDescription widthDescription;
421 widthDescription.path = "";
422 widthDescription.family = "DejaVu Serif";
423 widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
424 widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
425 widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
426 fontClient.GetFontId( widthDescription );
430 TextAbstraction::FontDescription defaultFontDescription01;
431 Vector<FontDescriptionRun> fontDescriptionRuns01;
432 Vector<FontId> expectedFontIds01;
433 Vector<bool> expectedIsFontDefault01;
435 TextAbstraction::FontDescription defaultFontDescription02;
436 Vector<FontDescriptionRun> fontDescriptionRuns02;
437 Vector<FontId> expectedFontIds02;
438 expectedFontIds02.PushBack( 0u );
439 expectedFontIds02.PushBack( 0u );
440 Vector<bool> expectedIsFontDefault02;
441 expectedIsFontDefault02.PushBack( true );
442 expectedIsFontDefault02.PushBack( true );
444 TextAbstraction::FontDescription defaultFontDescription03;
445 defaultFontDescription03.family = "DejaVu Serif";
446 Vector<FontDescriptionRun> fontDescriptionRuns03;
448 FontDescriptionRun fontDescription0301 =
454 const_cast<char*>( "DejaVu Sans" ),
456 TextAbstraction::FontWeight::NORMAL,
457 TextAbstraction::FontWidth::NORMAL,
458 TextAbstraction::FontSlant::NORMAL,
459 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
466 FontDescriptionRun fontDescription0302 =
474 TextAbstraction::FontWeight::NORMAL,
475 TextAbstraction::FontWidth::NORMAL,
476 TextAbstraction::FontSlant::ITALIC,
477 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
484 FontDescriptionRun fontDescription0303 =
492 TextAbstraction::FontWeight::BOLD,
493 TextAbstraction::FontWidth::NORMAL,
494 TextAbstraction::FontSlant::NORMAL,
495 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
502 FontDescriptionRun fontDescription0304 =
510 TextAbstraction::FontWeight::NORMAL,
511 TextAbstraction::FontWidth::NORMAL,
512 TextAbstraction::FontSlant::NORMAL,
513 NON_DEFAULT_FONT_SIZE,
520 FontDescriptionRun fontDescription0305 =
528 TextAbstraction::FontWeight::NORMAL,
529 TextAbstraction::FontWidth::EXPANDED,
530 TextAbstraction::FontSlant::NORMAL,
531 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
539 fontDescriptionRuns03.PushBack( fontDescription0301 );
540 fontDescriptionRuns03.PushBack( fontDescription0302 );
541 fontDescriptionRuns03.PushBack( fontDescription0303 );
542 fontDescriptionRuns03.PushBack( fontDescription0304 );
543 fontDescriptionRuns03.PushBack( fontDescription0305 );
545 Vector<FontId> expectedFontIds03;
546 expectedFontIds03.PushBack( 1u );
547 expectedFontIds03.PushBack( 1u );
548 expectedFontIds03.PushBack( 5u );
549 expectedFontIds03.PushBack( 5u );
550 expectedFontIds03.PushBack( 4u );
551 expectedFontIds03.PushBack( 4u );
552 expectedFontIds03.PushBack( 3u );
553 expectedFontIds03.PushBack( 3u );
554 expectedFontIds03.PushBack( 6u );
555 expectedFontIds03.PushBack( 6u );
556 Vector<bool> expectedIsFontDefault03;
557 expectedIsFontDefault03.PushBack( false );
558 expectedIsFontDefault03.PushBack( false );
559 expectedIsFontDefault03.PushBack( false );
560 expectedIsFontDefault03.PushBack( false );
561 expectedIsFontDefault03.PushBack( false );
562 expectedIsFontDefault03.PushBack( false );
563 expectedIsFontDefault03.PushBack( false );
564 expectedIsFontDefault03.PushBack( false );
565 expectedIsFontDefault03.PushBack( false );
566 expectedIsFontDefault03.PushBack( false );
568 const MergeFontDescriptionsData data[] =
572 fontDescriptionRuns01,
573 defaultFontDescription01,
574 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
578 expectedIsFontDefault01
581 "No description runs.",
582 fontDescriptionRuns02,
583 defaultFontDescription02,
584 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
588 expectedIsFontDefault02
591 "Some description runs.",
592 fontDescriptionRuns03,
593 defaultFontDescription03,
594 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
598 expectedIsFontDefault03
601 const unsigned int numberOfTests = 3u;
603 for( unsigned int index = 0u; index < numberOfTests; ++index )
605 if( !MergeFontDescriptionsTest( data[index] ) )
607 tet_result(TET_FAIL);
611 tet_result(TET_PASS);
615 int UtcDaliTextMultiLanguageConstructor(void)
617 ToolkitTestApplication application;
618 tet_infoline(" UtcDaliTextMultiLanguageConstructor");
620 MultilanguageSupport multilanguageSupport;
621 DALI_TEST_CHECK( !multilanguageSupport );
623 MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
624 DALI_TEST_CHECK( multilanguageSupport1 );
626 // To increase coverage.
627 MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
628 DALI_TEST_CHECK( multilanguageSupport2 );
630 DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
632 tet_result(TET_PASS);
636 int UtcDaliTextMultiLanguageSetScripts(void)
638 ToolkitTestApplication application;
639 tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
642 Vector<ScriptRun> scriptRuns00;
645 Vector<ScriptRun> scriptRuns01;
646 ScriptRun scriptRun0100 =
652 TextAbstraction::LATIN
654 scriptRuns01.PushBack( scriptRun0100 );
656 // Mix of LTR '\n'and RTL
657 Vector<ScriptRun> scriptRuns02;
658 ScriptRun scriptRun0200 =
664 TextAbstraction::LATIN
666 ScriptRun scriptRun0201 =
672 TextAbstraction::ARABIC
674 scriptRuns02.PushBack( scriptRun0200 );
675 scriptRuns02.PushBack( scriptRun0201 );
677 // Mix of RTL '\n'and LTR
678 Vector<ScriptRun> scriptRuns03;
679 ScriptRun scriptRun0300 =
685 TextAbstraction::ARABIC
687 ScriptRun scriptRun0301 =
693 TextAbstraction::LATIN
695 scriptRuns03.PushBack( scriptRun0300 );
696 scriptRuns03.PushBack( scriptRun0301 );
698 // White spaces. At the beginning of the text.
699 Vector<ScriptRun> scriptRuns04;
700 ScriptRun scriptRun0400 =
706 TextAbstraction::LATIN
708 scriptRuns04.PushBack( scriptRun0400 );
710 // White spaces. At the end of the text.
711 Vector<ScriptRun> scriptRuns05;
712 ScriptRun scriptRun0500 =
718 TextAbstraction::LATIN
720 scriptRuns05.PushBack( scriptRun0500 );
722 // White spaces. At the middle of the text.
723 Vector<ScriptRun> scriptRuns06;
724 ScriptRun scriptRun0600 =
730 TextAbstraction::LATIN
732 scriptRuns06.PushBack( scriptRun0600 );
734 // White spaces between different scripts.
735 Vector<ScriptRun> scriptRuns07;
736 ScriptRun scriptRun0700 =
742 TextAbstraction::LATIN
744 ScriptRun scriptRun0701 =
750 TextAbstraction::HANGUL
752 scriptRuns07.PushBack( scriptRun0700 );
753 scriptRuns07.PushBack( scriptRun0701 );
755 // White spaces between different scripts and differetn directions. Starting LTR.
756 Vector<ScriptRun> scriptRuns08;
757 ScriptRun scriptRun0800 =
763 TextAbstraction::LATIN
765 ScriptRun scriptRun0801 =
771 TextAbstraction::ARABIC
773 ScriptRun scriptRun0802 =
779 TextAbstraction::HANGUL
781 scriptRuns08.PushBack( scriptRun0800 );
782 scriptRuns08.PushBack( scriptRun0801 );
783 scriptRuns08.PushBack( scriptRun0802 );
785 // White spaces between different scripts and differetn directions. Starting RTL.
786 Vector<ScriptRun> scriptRuns09;
787 ScriptRun scriptRun0900 =
793 TextAbstraction::ARABIC
795 ScriptRun scriptRun0901 =
801 TextAbstraction::LATIN
803 ScriptRun scriptRun0902 =
809 TextAbstraction::HANGUL
811 ScriptRun scriptRun0903 =
817 TextAbstraction::ARABIC
819 scriptRuns09.PushBack( scriptRun0900 );
820 scriptRuns09.PushBack( scriptRun0901 );
821 scriptRuns09.PushBack( scriptRun0902 );
822 scriptRuns09.PushBack( scriptRun0903 );
824 // Paragraphs with different directions.
825 Vector<ScriptRun> scriptRuns10;
826 ScriptRun scriptRun1000 =
832 TextAbstraction::ARABIC
834 ScriptRun scriptRun1001 =
840 TextAbstraction::HEBREW
842 ScriptRun scriptRun1002 =
848 TextAbstraction::ARABIC
850 ScriptRun scriptRun1003 =
856 TextAbstraction::LATIN
858 ScriptRun scriptRun1004 =
864 TextAbstraction::HANGUL
866 ScriptRun scriptRun1005 =
872 TextAbstraction::ARABIC
874 ScriptRun scriptRun1006 =
880 TextAbstraction::LATIN
882 ScriptRun scriptRun1007 =
888 TextAbstraction::HEBREW
890 ScriptRun scriptRun1008 =
896 TextAbstraction::LATIN
898 ScriptRun scriptRun1009 =
904 TextAbstraction::ARABIC
906 ScriptRun scriptRun1010 =
912 TextAbstraction::HANGUL
914 ScriptRun scriptRun1011 =
920 TextAbstraction::HANGUL
922 scriptRuns10.PushBack( scriptRun1000 );
923 scriptRuns10.PushBack( scriptRun1001 );
924 scriptRuns10.PushBack( scriptRun1002 );
925 scriptRuns10.PushBack( scriptRun1003 );
926 scriptRuns10.PushBack( scriptRun1004 );
927 scriptRuns10.PushBack( scriptRun1005 );
928 scriptRuns10.PushBack( scriptRun1006 );
929 scriptRuns10.PushBack( scriptRun1007 );
930 scriptRuns10.PushBack( scriptRun1008 );
931 scriptRuns10.PushBack( scriptRun1009 );
932 scriptRuns10.PushBack( scriptRun1010 );
933 scriptRuns10.PushBack( scriptRun1011 );
935 // Paragraphs with no scripts mixed with paragraphs with scripts.
936 Vector<ScriptRun> scriptRuns11;
937 ScriptRun scriptRun1100 =
943 TextAbstraction::LATIN
945 ScriptRun scriptRun1101 =
951 TextAbstraction::LATIN
953 ScriptRun scriptRun1102 =
959 TextAbstraction::LATIN
961 ScriptRun scriptRun1103 =
967 TextAbstraction::LATIN
969 ScriptRun scriptRun1104 =
975 TextAbstraction::LATIN
977 ScriptRun scriptRun1105 =
983 TextAbstraction::HEBREW
985 ScriptRun scriptRun1106 =
991 TextAbstraction::LATIN
993 ScriptRun scriptRun1107 =
999 TextAbstraction::LATIN
1001 ScriptRun scriptRun1108 =
1007 TextAbstraction::LATIN
1009 scriptRuns11.PushBack( scriptRun1100 );
1010 scriptRuns11.PushBack( scriptRun1101 );
1011 scriptRuns11.PushBack( scriptRun1102 );
1012 scriptRuns11.PushBack( scriptRun1103 );
1013 scriptRuns11.PushBack( scriptRun1104 );
1014 scriptRuns11.PushBack( scriptRun1105 );
1015 scriptRuns11.PushBack( scriptRun1106 );
1016 scriptRuns11.PushBack( scriptRun1107 );
1017 scriptRuns11.PushBack( scriptRun1108 );
1019 // Paragraphs with no scripts.
1020 Vector<ScriptRun> scriptRuns12;
1021 ScriptRun scriptRun1200 =
1027 TextAbstraction::LATIN
1029 ScriptRun scriptRun1201 =
1035 TextAbstraction::LATIN
1037 ScriptRun scriptRun1202 =
1043 TextAbstraction::LATIN
1045 ScriptRun scriptRun1203 =
1051 TextAbstraction::LATIN
1053 scriptRuns12.PushBack( scriptRun1200 );
1054 scriptRuns12.PushBack( scriptRun1201 );
1055 scriptRuns12.PushBack( scriptRun1202 );
1056 scriptRuns12.PushBack( scriptRun1203 );
1058 Vector<ScriptRun> scriptRuns13;
1059 ScriptRun scriptRun1301 =
1065 TextAbstraction::LATIN // An unknown script is transformed to LATIN
1067 scriptRuns13.PushBack( scriptRun1301 );
1069 const ScriptsData data[] =
1079 "Easy latin script",
1086 "Mix of LTR '\\n'and RTL",
1087 "Hello world\nمرحبا بالعالم",
1093 "Update mix of LTR '\\n'and RTL. Update LTR",
1094 "Hello world\nمرحبا بالعالم",
1100 "Update mix of LTR '\\n'and RTL. Update RTL",
1101 "Hello world\nمرحبا بالعالم",
1107 "Mix of RTL '\\n'and LTR",
1108 "مرحبا بالعالم\nHello world",
1114 "Update mix of RTL '\\n'and LTR. Update RTL",
1115 "مرحبا بالعالم\nHello world",
1121 "Update mix of RTL '\\n'and LTR. Update LTR",
1122 "مرحبا بالعالم\nHello world",
1128 "White spaces. At the beginning of the text.",
1135 "White spaces. At the end of the text.",
1142 "White spaces. At the middle of the text.",
1149 "White spaces between different scripts.",
1156 "White spaces between different scripts and differetn directions. Starting LTR.",
1157 " Hello world مرحبا بالعالم 안녕하세요 세계 ",
1163 "White spaces between different scripts and differetn directions. Starting RTL.",
1164 " مرحبا بالعالم Hello world 안녕하세요 세계 مرحبا بالعالم ",
1170 "Paragraphs with different directions.",
1171 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1172 " Hello world 안녕하세요 세계 \n "
1173 " مرحبا بالعالم Hello world שלום עולם \n "
1174 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1181 "Update paragraphs with different directions. Update initial paragraphs.",
1182 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1183 " Hello world 안녕하세요 세계 \n "
1184 " مرحبا بالعالم Hello world שלום עולם \n "
1185 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1192 "Update paragraphs with different directions. Update middle paragraphs.",
1193 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1194 " Hello world 안녕하세요 세계 \n "
1195 " مرحبا بالعالم Hello world שלום עולם \n "
1196 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1203 "Update paragraphs with different directions. Update final paragraphs.",
1204 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1205 " Hello world 안녕하세요 세계 \n "
1206 " مرحبا بالعالم Hello world שלום עולם \n "
1207 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1214 "Paragraphs with no scripts mixed with paragraphs with scripts.",
1215 " \n \n Hello world \n \n \n שלום עולם \n \n \n ",
1221 "Paragraphs with no scripts.",
1228 "Update paragraphs with no scripts. Update initial paragraphs.",
1235 "Update paragraphs with no scripts. Update middle paragraphs.",
1242 "Update paragraphs with no scripts. Update final paragraphs.",
1250 "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1256 const unsigned int numberOfTests = 24u;
1258 for( unsigned int index = 0u; index < numberOfTests; ++index )
1260 if( !ScriptsTest( data[index] ) )
1262 tet_result(TET_FAIL);
1266 tet_result(TET_PASS);
1270 int UtcDaliTextMultiLanguageValidateFonts01(void)
1272 ToolkitTestApplication application;
1273 tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1275 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1277 char* pathNamePtr = get_current_dir_name();
1278 const std::string pathName( pathNamePtr );
1279 free( pathNamePtr );
1281 const PointSize26Dot6 pointSize01 = static_cast<PointSize26Dot6>( 21.f * 64.f );
1282 const PointSize26Dot6 pointSize02 = static_cast<PointSize26Dot6>( 35.f * 64.f );
1285 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1286 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1287 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
1288 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 );
1289 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 );
1290 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 );
1291 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 );
1293 // Font id 1 --> TizenSansArabicRegular.ttf
1294 // Font id 2 --> TizenSansHebrewRegular.ttf
1295 // Font id 3 --> TizenColorEmoji.ttf
1296 // Font id 4 --> TizenSansRegular.ttf, size 8
1297 // Font id 5 --> TizenSansRegular.ttf, size 16
1298 // Font id 6 --> TizenSansHebrewRegular.ttf, size 8
1299 // Font id 7 --> TizenSansHebrewRegular.ttf, size 16
1300 // Font id 8 --> (default)
1302 Vector<FontRun> fontRuns01;
1303 Vector<FontDescriptionRun> fontDescriptions01;
1305 FontRun fontRun0201 =
1313 Vector<FontRun> fontRuns02;
1314 fontRuns02.PushBack( fontRun0201 );
1316 FontDescriptionRun fontDescription0201 =
1322 const_cast<char*>( "TizenSans" ),
1324 TextAbstraction::FontWeight::NORMAL,
1325 TextAbstraction::FontWidth::NORMAL,
1326 TextAbstraction::FontSlant::NORMAL,
1334 Vector<FontDescriptionRun> fontDescriptions02;
1335 fontDescriptions02.PushBack( fontDescription0201 );
1337 FontRun fontRun0301 =
1345 FontRun fontRun0302 =
1353 FontRun fontRun0303 =
1361 Vector<FontRun> fontRuns03;
1362 fontRuns03.PushBack( fontRun0301 );
1363 fontRuns03.PushBack( fontRun0302 );
1364 fontRuns03.PushBack( fontRun0303 );
1366 Vector<FontDescriptionRun> fontDescriptions03;
1368 FontRun fontRun0701 =
1376 FontRun fontRun0702 =
1384 FontRun fontRun0703 =
1392 Vector<FontRun> fontRuns07;
1393 fontRuns07.PushBack( fontRun0701 );
1394 fontRuns07.PushBack( fontRun0702 );
1395 fontRuns07.PushBack( fontRun0703 );
1397 FontDescriptionRun fontDescription0701 =
1403 const_cast<char*>( "TizenSansHebrew" ),
1405 TextAbstraction::FontWeight::NORMAL,
1406 TextAbstraction::FontWidth::NORMAL,
1407 TextAbstraction::FontSlant::NORMAL,
1415 FontDescriptionRun fontDescription0702 =
1421 const_cast<char*>( "TizenSansHebrew" ),
1423 TextAbstraction::FontWeight::NORMAL,
1424 TextAbstraction::FontWidth::NORMAL,
1425 TextAbstraction::FontSlant::NORMAL,
1433 Vector<FontDescriptionRun> fontDescriptions07;
1434 fontDescriptions07.PushBack( fontDescription0701 );
1435 fontDescriptions07.PushBack( fontDescription0702 );
1437 FontRun fontRun0801 =
1445 Vector<FontRun> fontRuns08;
1446 fontRuns08.PushBack( fontRun0801 );
1448 Vector<FontDescriptionRun> fontDescriptions08;
1450 FontRun fontRun0901 =
1458 Vector<FontRun> fontRuns09;
1459 fontRuns09.PushBack( fontRun0901 );
1461 Vector<FontDescriptionRun> fontDescriptions09;
1462 FontDescriptionRun fontDescription0901 =
1468 const_cast<char*>( "TizenColorEmoji" ),
1470 TextAbstraction::FontWeight::NORMAL,
1471 TextAbstraction::FontWidth::NORMAL,
1472 TextAbstraction::FontSlant::NORMAL,
1480 fontDescriptions09.PushBack( fontDescription0901 );
1482 FontRun fontRun1001 =
1490 FontRun fontRun1002 =
1498 FontRun fontRun1003 =
1506 FontRun fontRun1004 =
1514 Vector<FontRun> fontRuns10;
1515 fontRuns10.PushBack( fontRun1001 );
1516 fontRuns10.PushBack( fontRun1002 );
1517 fontRuns10.PushBack( fontRun1003 );
1518 fontRuns10.PushBack( fontRun1004 );
1520 FontDescriptionRun fontDescription1001 =
1526 const_cast<char*>( "TizenSans" ),
1528 TextAbstraction::FontWeight::NORMAL,
1529 TextAbstraction::FontWidth::NORMAL,
1530 TextAbstraction::FontSlant::NORMAL,
1538 FontDescriptionRun fontDescription1002 =
1544 const_cast<char*>( "TizenSansHebrew" ),
1546 TextAbstraction::FontWeight::NORMAL,
1547 TextAbstraction::FontWidth::NORMAL,
1548 TextAbstraction::FontSlant::NORMAL,
1556 FontDescriptionRun fontDescription1003 =
1562 const_cast<char*>( "TizenSans" ),
1564 TextAbstraction::FontWeight::NORMAL,
1565 TextAbstraction::FontWidth::NORMAL,
1566 TextAbstraction::FontSlant::NORMAL,
1574 FontDescriptionRun fontDescription1004 =
1580 const_cast<char*>( "TizenSansHebrew" ),
1582 TextAbstraction::FontWeight::NORMAL,
1583 TextAbstraction::FontWidth::NORMAL,
1584 TextAbstraction::FontSlant::NORMAL,
1592 Vector<FontDescriptionRun> fontDescriptions10;
1593 fontDescriptions10.PushBack( fontDescription1001 );
1594 fontDescriptions10.PushBack( fontDescription1002 );
1595 fontDescriptions10.PushBack( fontDescription1003 );
1596 fontDescriptions10.PushBack( fontDescription1004 );
1598 const ValidateFontsData data[] =
1603 "/tizen/TizenSansRegular.ttf",
1604 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1611 "Easy latin script.",
1613 "/tizen/TizenSansRegular.ttf",
1614 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1621 "Different paragraphs.",
1622 "Hello world\nhello world\ndemo",
1623 "/tizen/TizenSansRegular.ttf",
1624 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1631 "Different paragraphs. Update the initial paragraph.",
1632 "Hello world\nhello world\ndemo",
1633 "/tizen/TizenSansRegular.ttf",
1634 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1641 "Different paragraphs. Update the middle paragraph.",
1642 "Hello world\nhello world\ndemo",
1643 "/tizen/TizenSansRegular.ttf",
1644 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1651 "Different paragraphs. Update the final paragraph.",
1652 "Hello world\nhello world\ndemo",
1653 "/tizen/TizenSansRegular.ttf",
1654 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1661 "Hebrew text. Default font: latin",
1663 "/tizen/TizenSansRegular.ttf",
1664 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1671 "Hebrew text. Default font: hebrew",
1673 "/tizen/TizenSansHebrewRegular.ttf",
1674 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1682 "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1683 "/tizen/TizenColorEmoji.ttf",
1691 "Mix text. Default font: latin. Different font sizes",
1692 "Hello world, שלום עולם, hello world, שלום עולם",
1693 "/tizen/TizenSansRegular.ttf",
1694 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1701 const unsigned int numberOfTests = 10u;
1703 for( unsigned int index = 0u; index < numberOfTests; ++index )
1705 if( !ValidateFontTest( data[index] ) )
1707 tet_result(TET_FAIL);
1711 tet_result(TET_PASS);