2 * Copyright (c) 2018 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 // const TextAbstraction::FontDescription& defaultFontDescription,
40 // TextAbstraction::PointSize26Dot6 defaultPointSize,
41 // CharacterIndex characterIndex,
42 // TextAbstraction::FontDescription& fontDescription,
43 // TextAbstraction::PointSize26Dot6& fontPointSize,
44 // bool& isDefaultFont );
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 // const TextAbstraction::FontDescription& defaultFontDescription,
61 // TextAbstraction::PointSize26Dot6 defaultFontPointSize,
62 // CharacterIndex startIndex,
63 // Length numberOfCharacters,
64 // Vector<FontRun>& fonts );
66 //////////////////////////////////////////////////////////
71 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
72 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
73 const unsigned int NON_DEFAULT_FONT_SIZE = 40u;
75 struct MergeFontDescriptionsData
77 std::string description; ///< Description of the experiment.
78 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
79 TextAbstraction::FontDescription defaultFontDescription; ///< The default font description.
80 TextAbstraction::PointSize26Dot6 defaultPointSize; ///< The default point size.
81 unsigned int startIndex; ///< The start index.
82 unsigned int numberOfCharacters; ///< The number of characters.
83 Vector<FontId> expectedFontIds; ///< The expected font ids.
84 Vector<bool> expectedIsDefault; ///< The expected font ids.
89 std::string description; ///< Description of the experiment.
90 std::string text; ///< Input text.
91 unsigned int index; ///< The index of the first character to update the script.
92 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
93 Vector<ScriptRun> scriptRuns; ///< Expected script runs.
96 struct ValidateFontsData
98 std::string description; ///< Description of the experiment.
99 std::string text; ///< Input text.
100 std::string defaultFont; ///< The default font.
101 unsigned int defaultFontSize; ///< The default font size.
102 unsigned int index; ///< The index of the first character to update the script.
103 unsigned int numberOfCharacters; ///< The numbers of characters to update the script.
104 Vector<FontDescriptionRun> fontDescriptionRuns; ///< The font description runs.
105 Vector<FontRun> fontRuns; ///< The expected font runs.
108 //////////////////////////////////////////////////////////
109 bool MergeFontDescriptionsTest( const MergeFontDescriptionsData& data )
111 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
113 Vector<FontId> fontIds;
114 fontIds.Resize( data.startIndex + data.numberOfCharacters, 0u );
115 Vector<bool> isDefaultFont;
116 isDefaultFont.Resize( data.startIndex + data.numberOfCharacters, true );
118 for( unsigned int index = data.startIndex; index < data.startIndex + data.numberOfCharacters; ++index )
120 TextAbstraction::FontDescription fontDescription;
121 TextAbstraction::PointSize26Dot6 fontPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
123 MergeFontDescriptions( data.fontDescriptionRuns,
124 data.defaultFontDescription,
125 data.defaultPointSize,
129 isDefaultFont[index] );
131 if( !isDefaultFont[index] )
133 fontIds[index] = fontClient.GetFontId( fontDescription, fontPointSize );
137 if( fontIds.Count() != data.expectedFontIds.Count() )
139 std::cout << data.description << " Different number of font ids : " << fontIds.Count() << ", expected : " << data.expectedFontIds.Count() << std::endl;
143 for( unsigned int index = 0u; index < fontIds.Count(); ++index )
145 if( fontIds[index] != data.expectedFontIds[index] )
147 std::cout << data.description << " Different font id at index : " << index << ", font id : " << fontIds[index] << ", expected : " << data.expectedFontIds[index] << std::endl;
148 std::cout << " font ids : ";
149 for( unsigned int i=0;i<fontIds.Count();++i)
151 std::cout << fontIds[i] << " ";
153 std::cout << std::endl;
154 std::cout << " expected font ids : ";
155 for( unsigned int i=0;i<data.expectedFontIds.Count();++i)
157 std::cout << data.expectedFontIds[i] << " ";
159 std::cout << std::endl;
163 if( isDefaultFont[index] != data.expectedIsDefault[index] )
165 std::cout << data.description << " Different 'is font default' at index : " << index << ", is font default : " << isDefaultFont[index] << ", expected : " << data.expectedIsDefault[index] << std::endl;
173 bool ScriptsTest( const ScriptsData& data )
175 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
177 // 1) Convert to utf32
178 Vector<Character> utf32;
179 utf32.Resize( data.text.size() );
181 const uint32_t numberOfCharacters = ( data.text.size() == 0 ) ? 0 :
182 Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
186 utf32.Resize( numberOfCharacters );
188 // 2) Set the script info.
189 Vector<ScriptRun> scripts;
190 multilanguageSupport.SetScripts( utf32,
195 if( ( 0u != data.index ) ||
196 ( numberOfCharacters != data.numberOfCharacters ) )
198 // 3) Clear the scripts.
199 ClearCharacterRuns( data.index,
200 data.index + data.numberOfCharacters - 1u,
203 multilanguageSupport.SetScripts( utf32,
205 data.numberOfCharacters,
209 // 4) Compare the results.
211 tet_printf( "Testing %s\n", data.description.c_str() );
212 if( scripts.Count() != data.scriptRuns.Count() )
214 tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
215 for( Vector<ScriptRun>::ConstIterator it = scripts.Begin(); it != scripts.End(); ++it)
217 const ScriptRun& run = *it;
219 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", script : [" << TextAbstraction::ScriptName[run.script] << "]" << std::endl;
224 for( unsigned int index = 0u; index < scripts.Count(); ++index )
226 const ScriptRun& scriptRun1 = scripts[index];
227 const ScriptRun& scriptRun2 = data.scriptRuns[index];
229 if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
231 tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
235 if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
237 tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
241 if( scriptRun1.script != scriptRun2.script )
243 tet_printf("ScriptsTest FAIL: script index: %u, different script. %s, should be %s\n", index, TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
251 bool ValidateFontTest( const ValidateFontsData& data )
253 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
254 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
256 // 1) Convert to utf32
257 Vector<Character> utf32;
258 utf32.Resize( data.text.size() );
260 const uint32_t numberOfCharacters = (data.text.size() == 0 ) ? 0 :
261 Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
264 utf32.Resize( numberOfCharacters );
266 // 2) Set the script info.
267 Vector<ScriptRun> scripts;
268 multilanguageSupport.SetScripts( utf32,
273 char* pathNamePtr = get_current_dir_name();
274 const std::string pathName( pathNamePtr );
277 // Get the default font id.
278 const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
279 data.defaultFontSize );
280 TextAbstraction::FontDescription defaultFontDescription;
281 fontClient.GetDescription( defaultFontId, defaultFontDescription );
283 const TextAbstraction::PointSize26Dot6 defaultPointSize = fontClient.GetPointSize( defaultFontId );
285 Vector<FontRun> fontRuns;
287 // 3) Validate the fonts.
288 multilanguageSupport.ValidateFonts( utf32,
290 data.fontDescriptionRuns,
291 defaultFontDescription,
297 if( ( 0u != data.index ) ||
298 ( numberOfCharacters != data.numberOfCharacters ) )
300 // 4) Clear the fonts.
301 ClearCharacterRuns( data.index,
302 data.index + data.numberOfCharacters - 1u,
305 multilanguageSupport.ValidateFonts( utf32,
307 data.fontDescriptionRuns,
308 defaultFontDescription,
311 data.numberOfCharacters,
315 // 5) Compare the results.
316 if( data.fontRuns.Count() != fontRuns.Count() )
318 std::cout << " Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
323 for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
325 const FontRun& run = fontRuns[index];
326 const FontRun& expectedRun = data.fontRuns[index];
328 if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
330 std::cout << " character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
333 if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
335 std::cout << " character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
338 if( run.fontId != expectedRun.fontId )
340 std::cout << " character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
350 int UtcDaliTextGetScript(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliTextGetScript");
355 Script script = TextAbstraction::LATIN;
357 // Text with no scripts.
358 Vector<ScriptRun> scriptRuns;
359 Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
360 script = GetScript( 0u,
364 DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
366 const unsigned int numberOfCharacters = 7u;
368 ScriptRun scriptRun01 =
374 TextAbstraction::LATIN
376 ScriptRun scriptRun02 =
382 TextAbstraction::HEBREW
384 ScriptRun scriptRun03 =
390 TextAbstraction::ARABIC
392 scriptRuns.PushBack( scriptRun01 );
393 scriptRuns.PushBack( scriptRun02 );
394 scriptRuns.PushBack( scriptRun03 );
397 TextAbstraction::Script expectedScripts[]=
399 TextAbstraction::LATIN,
400 TextAbstraction::LATIN,
401 TextAbstraction::HEBREW,
402 TextAbstraction::HEBREW,
403 TextAbstraction::ARABIC,
404 TextAbstraction::ARABIC,
405 TextAbstraction::UNKNOWN
408 scriptRunIt = scriptRuns.Begin();
409 for( unsigned int index = 0u; index < numberOfCharacters; ++index )
411 script = GetScript( index,
415 DALI_TEST_CHECK( expectedScripts[index] == script );
417 DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
419 tet_result(TET_PASS);
423 int UtcDaliTextMergeFontDescriptions(void)
425 ToolkitTestApplication application;
426 tet_infoline(" UtcDaliTextMergeFontDescriptions");
430 char* pathNamePtr = get_current_dir_name();
431 const std::string pathName( pathNamePtr );
434 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
435 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
436 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
437 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
438 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
439 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
441 // To test the font width as GetFontId() with the font file path can't cache the width property.
442 TextAbstraction::FontDescription widthDescription;
443 widthDescription.path = "";
444 widthDescription.family = "DejaVu Serif";
445 widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
446 widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
447 widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
448 fontClient.GetFontId( widthDescription );
452 TextAbstraction::FontDescription defaultFontDescription01;
453 Vector<FontDescriptionRun> fontDescriptionRuns01;
454 Vector<FontId> expectedFontIds01;
455 Vector<bool> expectedIsFontDefault01;
457 TextAbstraction::FontDescription defaultFontDescription02;
458 Vector<FontDescriptionRun> fontDescriptionRuns02;
459 Vector<FontId> expectedFontIds02;
460 expectedFontIds02.PushBack( 0u );
461 expectedFontIds02.PushBack( 0u );
462 Vector<bool> expectedIsFontDefault02;
463 expectedIsFontDefault02.PushBack( true );
464 expectedIsFontDefault02.PushBack( true );
466 TextAbstraction::FontDescription defaultFontDescription03;
467 defaultFontDescription03.family = "DejaVu Serif";
468 Vector<FontDescriptionRun> fontDescriptionRuns03;
470 FontDescriptionRun fontDescription0301 =
476 const_cast<char*>( "DejaVu Sans" ),
478 TextAbstraction::FontWeight::NONE,
479 TextAbstraction::FontWidth::NONE,
480 TextAbstraction::FontSlant::NONE,
481 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
488 FontDescriptionRun fontDescription0302 =
496 TextAbstraction::FontWeight::NONE,
497 TextAbstraction::FontWidth::NONE,
498 TextAbstraction::FontSlant::ITALIC,
499 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
506 FontDescriptionRun fontDescription0303 =
514 TextAbstraction::FontWeight::BOLD,
515 TextAbstraction::FontWidth::NONE,
516 TextAbstraction::FontSlant::NONE,
517 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
524 FontDescriptionRun fontDescription0304 =
532 TextAbstraction::FontWeight::NONE,
533 TextAbstraction::FontWidth::NONE,
534 TextAbstraction::FontSlant::NONE,
535 NON_DEFAULT_FONT_SIZE,
542 FontDescriptionRun fontDescription0305 =
550 TextAbstraction::FontWeight::NONE,
551 TextAbstraction::FontWidth::EXPANDED,
552 TextAbstraction::FontSlant::NONE,
553 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
561 fontDescriptionRuns03.PushBack( fontDescription0301 );
562 fontDescriptionRuns03.PushBack( fontDescription0302 );
563 fontDescriptionRuns03.PushBack( fontDescription0303 );
564 fontDescriptionRuns03.PushBack( fontDescription0304 );
565 fontDescriptionRuns03.PushBack( fontDescription0305 );
567 Vector<FontId> expectedFontIds03;
568 expectedFontIds03.PushBack( 1u );
569 expectedFontIds03.PushBack( 1u );
570 expectedFontIds03.PushBack( 5u );
571 expectedFontIds03.PushBack( 5u );
572 expectedFontIds03.PushBack( 4u );
573 expectedFontIds03.PushBack( 4u );
574 expectedFontIds03.PushBack( 3u );
575 expectedFontIds03.PushBack( 3u );
576 expectedFontIds03.PushBack( 6u );
577 expectedFontIds03.PushBack( 6u );
578 Vector<bool> expectedIsFontDefault03;
579 expectedIsFontDefault03.PushBack( false );
580 expectedIsFontDefault03.PushBack( false );
581 expectedIsFontDefault03.PushBack( false );
582 expectedIsFontDefault03.PushBack( false );
583 expectedIsFontDefault03.PushBack( false );
584 expectedIsFontDefault03.PushBack( false );
585 expectedIsFontDefault03.PushBack( false );
586 expectedIsFontDefault03.PushBack( false );
587 expectedIsFontDefault03.PushBack( false );
588 expectedIsFontDefault03.PushBack( false );
590 const MergeFontDescriptionsData data[] =
594 fontDescriptionRuns01,
595 defaultFontDescription01,
596 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
600 expectedIsFontDefault01
603 "No description runs.",
604 fontDescriptionRuns02,
605 defaultFontDescription02,
606 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
610 expectedIsFontDefault02
613 "Some description runs.",
614 fontDescriptionRuns03,
615 defaultFontDescription03,
616 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
620 expectedIsFontDefault03
623 const unsigned int numberOfTests = 3u;
625 for( unsigned int index = 0u; index < numberOfTests; ++index )
627 if( !MergeFontDescriptionsTest( data[index] ) )
629 tet_result(TET_FAIL);
633 tet_result(TET_PASS);
637 int UtcDaliTextMultiLanguageConstructor(void)
639 ToolkitTestApplication application;
640 tet_infoline(" UtcDaliTextMultiLanguageConstructor");
642 MultilanguageSupport multilanguageSupport;
643 DALI_TEST_CHECK( !multilanguageSupport );
645 MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
646 DALI_TEST_CHECK( multilanguageSupport1 );
648 // To increase coverage.
649 MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
650 DALI_TEST_CHECK( multilanguageSupport2 );
652 DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
654 tet_result(TET_PASS);
658 int UtcDaliTextMultiLanguageSetScripts(void)
660 ToolkitTestApplication application;
661 tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
664 Vector<ScriptRun> scriptRuns00;
667 Vector<ScriptRun> scriptRuns01;
668 ScriptRun scriptRun0100 =
674 TextAbstraction::LATIN
676 scriptRuns01.PushBack( scriptRun0100 );
678 // Mix of LTR '\n'and RTL
679 Vector<ScriptRun> scriptRuns02;
680 ScriptRun scriptRun0200 =
686 TextAbstraction::LATIN
688 ScriptRun scriptRun0201 =
694 TextAbstraction::ARABIC
696 scriptRuns02.PushBack( scriptRun0200 );
697 scriptRuns02.PushBack( scriptRun0201 );
699 // Mix of RTL '\n'and LTR
700 Vector<ScriptRun> scriptRuns03;
701 ScriptRun scriptRun0300 =
707 TextAbstraction::ARABIC
709 ScriptRun scriptRun0301 =
715 TextAbstraction::LATIN
717 scriptRuns03.PushBack( scriptRun0300 );
718 scriptRuns03.PushBack( scriptRun0301 );
720 // White spaces. At the beginning of the text.
721 Vector<ScriptRun> scriptRuns04;
722 ScriptRun scriptRun0400 =
728 TextAbstraction::LATIN
730 scriptRuns04.PushBack( scriptRun0400 );
732 // White spaces. At the end of the text.
733 Vector<ScriptRun> scriptRuns05;
734 ScriptRun scriptRun0500 =
740 TextAbstraction::LATIN
742 scriptRuns05.PushBack( scriptRun0500 );
744 // White spaces. At the middle of the text.
745 Vector<ScriptRun> scriptRuns06;
746 ScriptRun scriptRun0600 =
752 TextAbstraction::LATIN
754 scriptRuns06.PushBack( scriptRun0600 );
756 // White spaces between different scripts.
757 Vector<ScriptRun> scriptRuns07;
758 ScriptRun scriptRun0700 =
764 TextAbstraction::LATIN
766 ScriptRun scriptRun0701 =
772 TextAbstraction::HANGUL
774 scriptRuns07.PushBack( scriptRun0700 );
775 scriptRuns07.PushBack( scriptRun0701 );
777 // White spaces between different scripts and differetn directions. Starting LTR.
778 Vector<ScriptRun> scriptRuns08;
779 ScriptRun scriptRun0800 =
785 TextAbstraction::LATIN
787 ScriptRun scriptRun0801 =
793 TextAbstraction::ARABIC
795 ScriptRun scriptRun0802 =
801 TextAbstraction::HANGUL
803 scriptRuns08.PushBack( scriptRun0800 );
804 scriptRuns08.PushBack( scriptRun0801 );
805 scriptRuns08.PushBack( scriptRun0802 );
807 // White spaces between different scripts and differetn directions. Starting RTL.
808 Vector<ScriptRun> scriptRuns09;
809 ScriptRun scriptRun0900 =
815 TextAbstraction::ARABIC
817 ScriptRun scriptRun0901 =
823 TextAbstraction::LATIN
825 ScriptRun scriptRun0902 =
831 TextAbstraction::HANGUL
833 ScriptRun scriptRun0903 =
839 TextAbstraction::ARABIC
841 scriptRuns09.PushBack( scriptRun0900 );
842 scriptRuns09.PushBack( scriptRun0901 );
843 scriptRuns09.PushBack( scriptRun0902 );
844 scriptRuns09.PushBack( scriptRun0903 );
846 // Paragraphs with different directions.
847 Vector<ScriptRun> scriptRuns10;
848 ScriptRun scriptRun1000 =
854 TextAbstraction::ARABIC
856 ScriptRun scriptRun1001 =
862 TextAbstraction::HEBREW
864 ScriptRun scriptRun1002 =
870 TextAbstraction::ARABIC
872 ScriptRun scriptRun1003 =
878 TextAbstraction::LATIN
880 ScriptRun scriptRun1004 =
886 TextAbstraction::HANGUL
888 ScriptRun scriptRun1005 =
894 TextAbstraction::ARABIC
896 ScriptRun scriptRun1006 =
902 TextAbstraction::LATIN
904 ScriptRun scriptRun1007 =
910 TextAbstraction::HEBREW
912 ScriptRun scriptRun1008 =
918 TextAbstraction::LATIN
920 ScriptRun scriptRun1009 =
926 TextAbstraction::ARABIC
928 ScriptRun scriptRun1010 =
934 TextAbstraction::HANGUL
936 ScriptRun scriptRun1011 =
942 TextAbstraction::HANGUL
944 scriptRuns10.PushBack( scriptRun1000 );
945 scriptRuns10.PushBack( scriptRun1001 );
946 scriptRuns10.PushBack( scriptRun1002 );
947 scriptRuns10.PushBack( scriptRun1003 );
948 scriptRuns10.PushBack( scriptRun1004 );
949 scriptRuns10.PushBack( scriptRun1005 );
950 scriptRuns10.PushBack( scriptRun1006 );
951 scriptRuns10.PushBack( scriptRun1007 );
952 scriptRuns10.PushBack( scriptRun1008 );
953 scriptRuns10.PushBack( scriptRun1009 );
954 scriptRuns10.PushBack( scriptRun1010 );
955 scriptRuns10.PushBack( scriptRun1011 );
957 // Paragraphs with no scripts mixed with paragraphs with scripts.
958 Vector<ScriptRun> scriptRuns11;
959 ScriptRun scriptRun1100 =
965 TextAbstraction::UNKNOWN
967 ScriptRun scriptRun1101 =
973 TextAbstraction::UNKNOWN
975 ScriptRun scriptRun1102 =
981 TextAbstraction::LATIN
983 ScriptRun scriptRun1103 =
989 TextAbstraction::UNKNOWN
991 ScriptRun scriptRun1104 =
997 TextAbstraction::UNKNOWN
999 ScriptRun scriptRun1105 =
1005 TextAbstraction::HEBREW
1007 ScriptRun scriptRun1106 =
1013 TextAbstraction::UNKNOWN
1015 ScriptRun scriptRun1107 =
1021 TextAbstraction::UNKNOWN
1023 ScriptRun scriptRun1108 =
1029 TextAbstraction::UNKNOWN
1031 scriptRuns11.PushBack( scriptRun1100 );
1032 scriptRuns11.PushBack( scriptRun1101 );
1033 scriptRuns11.PushBack( scriptRun1102 );
1034 scriptRuns11.PushBack( scriptRun1103 );
1035 scriptRuns11.PushBack( scriptRun1104 );
1036 scriptRuns11.PushBack( scriptRun1105 );
1037 scriptRuns11.PushBack( scriptRun1106 );
1038 scriptRuns11.PushBack( scriptRun1107 );
1039 scriptRuns11.PushBack( scriptRun1108 );
1041 // Paragraphs with no scripts.
1042 Vector<ScriptRun> scriptRuns12;
1043 ScriptRun scriptRun1200 =
1049 TextAbstraction::UNKNOWN
1051 ScriptRun scriptRun1201 =
1057 TextAbstraction::UNKNOWN
1059 ScriptRun scriptRun1202 =
1065 TextAbstraction::UNKNOWN
1067 ScriptRun scriptRun1203 =
1073 TextAbstraction::UNKNOWN
1075 scriptRuns12.PushBack( scriptRun1200 );
1076 scriptRuns12.PushBack( scriptRun1201 );
1077 scriptRuns12.PushBack( scriptRun1202 );
1078 scriptRuns12.PushBack( scriptRun1203 );
1080 Vector<ScriptRun> scriptRuns13;
1081 ScriptRun scriptRun1301 =
1087 TextAbstraction::UNKNOWN
1089 scriptRuns13.PushBack( scriptRun1301 );
1091 const ScriptsData data[] =
1101 "Easy latin script",
1108 "Mix of LTR '\\n'and RTL",
1109 "Hello world\nمرحبا بالعالم",
1115 "Update mix of LTR '\\n'and RTL. Update LTR",
1116 "Hello world\nمرحبا بالعالم",
1122 "Update mix of LTR '\\n'and RTL. Update RTL",
1123 "Hello world\nمرحبا بالعالم",
1129 "Mix of RTL '\\n'and LTR",
1130 "مرحبا بالعالم\nHello world",
1136 "Update mix of RTL '\\n'and LTR. Update RTL",
1137 "مرحبا بالعالم\nHello world",
1143 "Update mix of RTL '\\n'and LTR. Update LTR",
1144 "مرحبا بالعالم\nHello world",
1150 "White spaces. At the beginning of the text.",
1157 "White spaces. At the end of the text.",
1164 "White spaces. At the middle of the text.",
1171 "White spaces between different scripts.",
1178 "White spaces between different scripts and differetn directions. Starting LTR.",
1179 " Hello world مرحبا بالعالم 안녕하세요 세계 ",
1185 "White spaces between different scripts and differetn directions. Starting RTL.",
1186 " مرحبا بالعالم Hello world 안녕하세요 세계 مرحبا بالعالم ",
1192 "Paragraphs with different directions.",
1193 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1194 " Hello world 안녕하세요 세계 \n "
1195 " مرحبا بالعالم Hello world שלום עולם \n "
1196 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1203 "Update paragraphs with different directions. Update initial paragraphs.",
1204 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1205 " Hello world 안녕하세요 세계 \n "
1206 " مرحبا بالعالم Hello world שלום עולם \n "
1207 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1214 "Update paragraphs with different directions. Update middle paragraphs.",
1215 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1216 " Hello world 안녕하세요 세계 \n "
1217 " مرحبا بالعالم Hello world שלום עולם \n "
1218 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1225 "Update paragraphs with different directions. Update final paragraphs.",
1226 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1227 " Hello world 안녕하세요 세계 \n "
1228 " مرحبا بالعالم Hello world שלום עולם \n "
1229 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1236 "Paragraphs with no scripts mixed with paragraphs with scripts.",
1237 " \n \n Hello world \n \n \n שלום עולם \n \n \n ",
1243 "Paragraphs with no scripts.",
1250 "Update paragraphs with no scripts. Update initial paragraphs.",
1257 "Update paragraphs with no scripts. Update middle paragraphs.",
1264 "Update paragraphs with no scripts. Update final paragraphs.",
1272 "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1278 const unsigned int numberOfTests = 24u;
1280 for( unsigned int index = 0u; index < numberOfTests; ++index )
1282 if( !ScriptsTest( data[index] ) )
1284 tet_result(TET_FAIL);
1288 tet_result(TET_PASS);
1292 int UtcDaliTextMultiLanguageValidateFonts01(void)
1294 ToolkitTestApplication application;
1295 tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1297 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1299 char* pathNamePtr = get_current_dir_name();
1300 const std::string pathName( pathNamePtr );
1301 free( pathNamePtr );
1303 const PointSize26Dot6 pointSize01 = static_cast<PointSize26Dot6>( 21.f * 64.f );
1304 const PointSize26Dot6 pointSize02 = static_cast<PointSize26Dot6>( 35.f * 64.f );
1307 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1308 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1309 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf", EMOJI_FONT_SIZE );
1310 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 );
1311 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 );
1312 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 );
1313 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 );
1315 // Font id 1 --> TizenSansArabicRegular.ttf
1316 // Font id 2 --> TizenSansHebrewRegular.ttf
1317 // Font id 3 --> BreezeColorEmoji.ttf
1318 // Font id 4 --> TizenSansRegular.ttf, size 8
1319 // Font id 5 --> TizenSansRegular.ttf, size 16
1320 // Font id 6 --> TizenSansHebrewRegular.ttf, size 8
1321 // Font id 7 --> TizenSansHebrewRegular.ttf, size 16
1322 // Font id 8 --> (default)
1324 Vector<FontRun> fontRuns01;
1325 Vector<FontDescriptionRun> fontDescriptions01;
1327 FontRun fontRun0201 =
1335 Vector<FontRun> fontRuns02;
1336 fontRuns02.PushBack( fontRun0201 );
1338 FontDescriptionRun fontDescription0201 =
1344 const_cast<char*>( "TizenSans" ),
1346 TextAbstraction::FontWeight::NORMAL,
1347 TextAbstraction::FontWidth::NORMAL,
1348 TextAbstraction::FontSlant::NORMAL,
1356 Vector<FontDescriptionRun> fontDescriptions02;
1357 fontDescriptions02.PushBack( fontDescription0201 );
1359 FontRun fontRun0301 =
1367 FontRun fontRun0302 =
1375 FontRun fontRun0303 =
1383 Vector<FontRun> fontRuns03;
1384 fontRuns03.PushBack( fontRun0301 );
1385 fontRuns03.PushBack( fontRun0302 );
1386 fontRuns03.PushBack( fontRun0303 );
1388 Vector<FontDescriptionRun> fontDescriptions03;
1390 FontRun fontRun0701 =
1398 FontRun fontRun0702 =
1406 FontRun fontRun0703 =
1414 Vector<FontRun> fontRuns07;
1415 fontRuns07.PushBack( fontRun0701 );
1416 fontRuns07.PushBack( fontRun0702 );
1417 fontRuns07.PushBack( fontRun0703 );
1419 FontDescriptionRun fontDescription0701 =
1425 const_cast<char*>( "TizenSansHebrew" ),
1427 TextAbstraction::FontWeight::NORMAL,
1428 TextAbstraction::FontWidth::NORMAL,
1429 TextAbstraction::FontSlant::NORMAL,
1437 FontDescriptionRun fontDescription0702 =
1443 const_cast<char*>( "TizenSansHebrew" ),
1445 TextAbstraction::FontWeight::NORMAL,
1446 TextAbstraction::FontWidth::NORMAL,
1447 TextAbstraction::FontSlant::NORMAL,
1455 Vector<FontDescriptionRun> fontDescriptions07;
1456 fontDescriptions07.PushBack( fontDescription0701 );
1457 fontDescriptions07.PushBack( fontDescription0702 );
1459 FontRun fontRun0801 =
1467 Vector<FontRun> fontRuns08;
1468 fontRuns08.PushBack( fontRun0801 );
1470 Vector<FontDescriptionRun> fontDescriptions08;
1472 FontRun fontRun0901 =
1480 Vector<FontRun> fontRuns09;
1481 fontRuns09.PushBack( fontRun0901 );
1483 Vector<FontDescriptionRun> fontDescriptions09;
1484 FontDescriptionRun fontDescription0901 =
1490 const_cast<char*>( "BreezeColorEmoji" ),
1492 TextAbstraction::FontWeight::NORMAL,
1493 TextAbstraction::FontWidth::NORMAL,
1494 TextAbstraction::FontSlant::NORMAL,
1502 fontDescriptions09.PushBack( fontDescription0901 );
1504 FontRun fontRun1001 =
1512 FontRun fontRun1002 =
1520 FontRun fontRun1003 =
1528 FontRun fontRun1004 =
1536 Vector<FontRun> fontRuns10;
1537 fontRuns10.PushBack( fontRun1001 );
1538 fontRuns10.PushBack( fontRun1002 );
1539 fontRuns10.PushBack( fontRun1003 );
1540 fontRuns10.PushBack( fontRun1004 );
1542 FontDescriptionRun fontDescription1001 =
1548 const_cast<char*>( "TizenSans" ),
1550 TextAbstraction::FontWeight::NORMAL,
1551 TextAbstraction::FontWidth::NORMAL,
1552 TextAbstraction::FontSlant::NORMAL,
1560 FontDescriptionRun fontDescription1002 =
1566 const_cast<char*>( "TizenSansHebrew" ),
1568 TextAbstraction::FontWeight::NORMAL,
1569 TextAbstraction::FontWidth::NORMAL,
1570 TextAbstraction::FontSlant::NORMAL,
1578 FontDescriptionRun fontDescription1003 =
1584 const_cast<char*>( "TizenSans" ),
1586 TextAbstraction::FontWeight::NORMAL,
1587 TextAbstraction::FontWidth::NORMAL,
1588 TextAbstraction::FontSlant::NORMAL,
1596 FontDescriptionRun fontDescription1004 =
1602 const_cast<char*>( "TizenSansHebrew" ),
1604 TextAbstraction::FontWeight::NORMAL,
1605 TextAbstraction::FontWidth::NORMAL,
1606 TextAbstraction::FontSlant::NORMAL,
1614 Vector<FontDescriptionRun> fontDescriptions10;
1615 fontDescriptions10.PushBack( fontDescription1001 );
1616 fontDescriptions10.PushBack( fontDescription1002 );
1617 fontDescriptions10.PushBack( fontDescription1003 );
1618 fontDescriptions10.PushBack( fontDescription1004 );
1620 FontRun fontRun1101 =
1628 Vector<FontRun> fontRuns11;
1629 fontRuns11.PushBack( fontRun1101 );
1631 FontDescriptionRun fontDescription1101 =
1637 const_cast<char*>( "TizenSans" ),
1639 TextAbstraction::FontWeight::NORMAL,
1640 TextAbstraction::FontWidth::NORMAL,
1641 TextAbstraction::FontSlant::NORMAL,
1649 Vector<FontDescriptionRun> fontDescriptions11;
1650 fontDescriptions11.PushBack( fontDescription1101 );
1652 FontRun fontRun1201 =
1660 FontRun fontRun1202 =
1668 FontRun fontRun1203 =
1676 Vector<FontRun> fontRuns12;
1677 fontRuns12.PushBack( fontRun1201 );
1678 fontRuns12.PushBack( fontRun1202 );
1679 fontRuns12.PushBack( fontRun1203 );
1681 FontDescriptionRun fontDescription1201 =
1687 const_cast<char*>( "TizenSans" ),
1689 TextAbstraction::FontWeight::NORMAL,
1690 TextAbstraction::FontWidth::NORMAL,
1691 TextAbstraction::FontSlant::NORMAL,
1699 FontDescriptionRun fontDescription1202 =
1705 const_cast<char*>( "TizenSans" ),
1707 TextAbstraction::FontWeight::NORMAL,
1708 TextAbstraction::FontWidth::NORMAL,
1709 TextAbstraction::FontSlant::NORMAL,
1717 FontDescriptionRun fontDescription1203 =
1723 const_cast<char*>( "TizenSans" ),
1725 TextAbstraction::FontWeight::NORMAL,
1726 TextAbstraction::FontWidth::NORMAL,
1727 TextAbstraction::FontSlant::NORMAL,
1735 Vector<FontDescriptionRun> fontDescriptions12;
1736 fontDescriptions12.PushBack( fontDescription1201 );
1737 fontDescriptions12.PushBack( fontDescription1202 );
1738 fontDescriptions12.PushBack( fontDescription1203 );
1740 const ValidateFontsData data[] =
1745 "/tizen/TizenSansRegular.ttf",
1746 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1753 "Easy latin script.",
1755 "/tizen/TizenSansRegular.ttf",
1756 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1763 "Different paragraphs.",
1764 "Hello world\nhello world\ndemo",
1765 "/tizen/TizenSansRegular.ttf",
1766 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1773 "Different paragraphs. Update the initial paragraph.",
1774 "Hello world\nhello world\ndemo",
1775 "/tizen/TizenSansRegular.ttf",
1776 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1783 "Different paragraphs. Update the middle paragraph.",
1784 "Hello world\nhello world\ndemo",
1785 "/tizen/TizenSansRegular.ttf",
1786 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1793 "Different paragraphs. Update the final paragraph.",
1794 "Hello world\nhello world\ndemo",
1795 "/tizen/TizenSansRegular.ttf",
1796 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1803 "Hebrew text. Default font: latin",
1805 "/tizen/TizenSansRegular.ttf",
1806 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1813 "Hebrew text. Default font: hebrew",
1815 "/tizen/TizenSansHebrewRegular.ttf",
1816 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1824 "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1825 "/tizen/BreezeColorEmoji.ttf",
1833 "Mix text. Default font: latin. Different font sizes",
1834 "Hello world, שלום עולם, hello world, שלום עולם",
1835 "/tizen/TizenSansRegular.ttf",
1836 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1843 "Unknown script -> changed to LATIN",
1844 "WRC – The Official App",
1845 "/tizen/TizenSansRegular.ttf",
1846 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1855 "/tizen/TizenSansRegular.ttf",
1856 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1863 const unsigned int numberOfTests = 12u;
1865 for( unsigned int index = 0u; index < numberOfTests; ++index )
1867 if( !ValidateFontTest( data[index] ) )
1869 tet_result(TET_FAIL);
1873 tet_result(TET_PASS);