2 * Copyright (c) 2017 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 = 3968u;
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 = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
184 utf32.Resize( numberOfCharacters );
186 // 2) Set the script info.
187 Vector<ScriptRun> scripts;
188 multilanguageSupport.SetScripts( utf32,
193 if( ( 0u != data.index ) ||
194 ( numberOfCharacters != data.numberOfCharacters ) )
196 // 3) Clear the scripts.
197 ClearCharacterRuns( data.index,
198 data.index + data.numberOfCharacters - 1u,
201 multilanguageSupport.SetScripts( utf32,
203 data.numberOfCharacters,
207 // 4) Compare the results.
209 tet_printf( "Testing %s\n", data.description.c_str() );
210 if( scripts.Count() != data.scriptRuns.Count() )
212 tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
213 for( Vector<ScriptRun>::ConstIterator it = scripts.Begin(); it != scripts.End(); ++it)
215 const ScriptRun& run = *it;
217 std::cout << " index : " << run.characterRun.characterIndex << ", num chars : " << run.characterRun.numberOfCharacters << ", script : [" << TextAbstraction::ScriptName[run.script] << "]" << std::endl;
222 for( unsigned int index = 0u; index < scripts.Count(); ++index )
224 const ScriptRun& scriptRun1 = scripts[index];
225 const ScriptRun& scriptRun2 = data.scriptRuns[index];
227 if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
229 tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
233 if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
235 tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
239 if( scriptRun1.script != scriptRun2.script )
241 tet_printf("ScriptsTest FAIL: different script. %s, should be %s\n", TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
249 bool ValidateFontTest( const ValidateFontsData& data )
251 MultilanguageSupport multilanguageSupport = MultilanguageSupport::Get();
252 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
254 // 1) Convert to utf32
255 Vector<Character> utf32;
256 utf32.Resize( data.text.size() );
258 const uint32_t numberOfCharacters = Utf8ToUtf32( reinterpret_cast<const uint8_t* const>( data.text.c_str() ),
261 utf32.Resize( numberOfCharacters );
263 // 2) Set the script info.
264 Vector<ScriptRun> scripts;
265 multilanguageSupport.SetScripts( utf32,
270 char* pathNamePtr = get_current_dir_name();
271 const std::string pathName( pathNamePtr );
274 // Get the default font id.
275 const FontId defaultFontId = fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + data.defaultFont,
276 data.defaultFontSize );
277 TextAbstraction::FontDescription defaultFontDescription;
278 fontClient.GetDescription( defaultFontId, defaultFontDescription );
280 const TextAbstraction::PointSize26Dot6 defaultPointSize = fontClient.GetPointSize( defaultFontId );
282 Vector<FontRun> fontRuns;
284 // 3) Validate the fonts.
285 multilanguageSupport.ValidateFonts( utf32,
287 data.fontDescriptionRuns,
288 defaultFontDescription,
294 if( ( 0u != data.index ) ||
295 ( numberOfCharacters != data.numberOfCharacters ) )
297 // 4) Clear the fonts.
298 ClearCharacterRuns( data.index,
299 data.index + data.numberOfCharacters - 1u,
302 multilanguageSupport.ValidateFonts( utf32,
304 data.fontDescriptionRuns,
305 defaultFontDescription,
308 data.numberOfCharacters,
312 // 5) Compare the results.
313 if( data.fontRuns.Count() != fontRuns.Count() )
315 std::cout << " Different number of font runs : " << fontRuns.Count() << ", expected : " << data.fontRuns.Count() << std::endl;
320 for( unsigned int index = 0; index < data.fontRuns.Count(); ++index )
322 const FontRun& run = fontRuns[index];
323 const FontRun& expectedRun = data.fontRuns[index];
325 if( run.characterRun.characterIndex != expectedRun.characterRun.characterIndex )
327 std::cout << " character run : " << index << ", index : " << run.characterRun.characterIndex << ", expected : " << expectedRun.characterRun.characterIndex << std::endl;
330 if( run.characterRun.numberOfCharacters != expectedRun.characterRun.numberOfCharacters )
332 std::cout << " character run : " << index << ", num chars : " << run.characterRun.numberOfCharacters << ", expected : " << expectedRun.characterRun.numberOfCharacters << std::endl;
335 if( run.fontId != expectedRun.fontId )
337 std::cout << " character run : " << index << ", font : " << run.fontId << ", expected : " << expectedRun.fontId << std::endl;
347 int UtcDaliTextGetScript(void)
349 ToolkitTestApplication application;
350 tet_infoline(" UtcDaliTextGetScript");
352 Script script = TextAbstraction::LATIN;
354 // Text with no scripts.
355 Vector<ScriptRun> scriptRuns;
356 Vector<ScriptRun>::ConstIterator scriptRunIt = scriptRuns.Begin();
357 script = GetScript( 0u,
361 DALI_TEST_CHECK( TextAbstraction::UNKNOWN == script );
363 const unsigned int numberOfCharacters = 7u;
365 ScriptRun scriptRun01 =
371 TextAbstraction::LATIN
373 ScriptRun scriptRun02 =
379 TextAbstraction::HEBREW
381 ScriptRun scriptRun03 =
387 TextAbstraction::ARABIC
389 scriptRuns.PushBack( scriptRun01 );
390 scriptRuns.PushBack( scriptRun02 );
391 scriptRuns.PushBack( scriptRun03 );
394 TextAbstraction::Script expectedScripts[]=
396 TextAbstraction::LATIN,
397 TextAbstraction::LATIN,
398 TextAbstraction::HEBREW,
399 TextAbstraction::HEBREW,
400 TextAbstraction::ARABIC,
401 TextAbstraction::ARABIC,
402 TextAbstraction::UNKNOWN
405 scriptRunIt = scriptRuns.Begin();
406 for( unsigned int index = 0u; index < numberOfCharacters; ++index )
408 script = GetScript( index,
412 DALI_TEST_CHECK( expectedScripts[index] == script );
414 DALI_TEST_CHECK( scriptRunIt == scriptRuns.End() );
416 tet_result(TET_PASS);
420 int UtcDaliTextMergeFontDescriptions(void)
422 ToolkitTestApplication application;
423 tet_infoline(" UtcDaliTextMergeFontDescriptions");
427 char* pathNamePtr = get_current_dir_name();
428 const std::string pathName( pathNamePtr );
431 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
432 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSans.ttf" );
433 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf" );
434 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", NON_DEFAULT_FONT_SIZE );
435 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf" );
436 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Italic.ttf" );
438 // To test the font width as GetFontId() with the font file path can't cache the width property.
439 TextAbstraction::FontDescription widthDescription;
440 widthDescription.path = "";
441 widthDescription.family = "DejaVu Serif";
442 widthDescription.weight = TextAbstraction::FontWeight::NORMAL;
443 widthDescription.width = TextAbstraction::FontWidth::EXPANDED;
444 widthDescription.slant = TextAbstraction::FontSlant::NORMAL;
445 fontClient.GetFontId( widthDescription );
449 TextAbstraction::FontDescription defaultFontDescription01;
450 Vector<FontDescriptionRun> fontDescriptionRuns01;
451 Vector<FontId> expectedFontIds01;
452 Vector<bool> expectedIsFontDefault01;
454 TextAbstraction::FontDescription defaultFontDescription02;
455 Vector<FontDescriptionRun> fontDescriptionRuns02;
456 Vector<FontId> expectedFontIds02;
457 expectedFontIds02.PushBack( 0u );
458 expectedFontIds02.PushBack( 0u );
459 Vector<bool> expectedIsFontDefault02;
460 expectedIsFontDefault02.PushBack( true );
461 expectedIsFontDefault02.PushBack( true );
463 TextAbstraction::FontDescription defaultFontDescription03;
464 defaultFontDescription03.family = "DejaVu Serif";
465 Vector<FontDescriptionRun> fontDescriptionRuns03;
467 FontDescriptionRun fontDescription0301 =
473 const_cast<char*>( "DejaVu Sans" ),
475 TextAbstraction::FontWeight::NONE,
476 TextAbstraction::FontWidth::NONE,
477 TextAbstraction::FontSlant::NONE,
478 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
485 FontDescriptionRun fontDescription0302 =
493 TextAbstraction::FontWeight::NONE,
494 TextAbstraction::FontWidth::NONE,
495 TextAbstraction::FontSlant::ITALIC,
496 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
503 FontDescriptionRun fontDescription0303 =
511 TextAbstraction::FontWeight::BOLD,
512 TextAbstraction::FontWidth::NONE,
513 TextAbstraction::FontSlant::NONE,
514 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
521 FontDescriptionRun fontDescription0304 =
529 TextAbstraction::FontWeight::NONE,
530 TextAbstraction::FontWidth::NONE,
531 TextAbstraction::FontSlant::NONE,
532 NON_DEFAULT_FONT_SIZE,
539 FontDescriptionRun fontDescription0305 =
547 TextAbstraction::FontWeight::NONE,
548 TextAbstraction::FontWidth::EXPANDED,
549 TextAbstraction::FontSlant::NONE,
550 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
558 fontDescriptionRuns03.PushBack( fontDescription0301 );
559 fontDescriptionRuns03.PushBack( fontDescription0302 );
560 fontDescriptionRuns03.PushBack( fontDescription0303 );
561 fontDescriptionRuns03.PushBack( fontDescription0304 );
562 fontDescriptionRuns03.PushBack( fontDescription0305 );
564 Vector<FontId> expectedFontIds03;
565 expectedFontIds03.PushBack( 1u );
566 expectedFontIds03.PushBack( 1u );
567 expectedFontIds03.PushBack( 5u );
568 expectedFontIds03.PushBack( 5u );
569 expectedFontIds03.PushBack( 4u );
570 expectedFontIds03.PushBack( 4u );
571 expectedFontIds03.PushBack( 3u );
572 expectedFontIds03.PushBack( 3u );
573 expectedFontIds03.PushBack( 6u );
574 expectedFontIds03.PushBack( 6u );
575 Vector<bool> expectedIsFontDefault03;
576 expectedIsFontDefault03.PushBack( false );
577 expectedIsFontDefault03.PushBack( false );
578 expectedIsFontDefault03.PushBack( false );
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 );
587 const MergeFontDescriptionsData data[] =
591 fontDescriptionRuns01,
592 defaultFontDescription01,
593 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
597 expectedIsFontDefault01
600 "No description runs.",
601 fontDescriptionRuns02,
602 defaultFontDescription02,
603 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
607 expectedIsFontDefault02
610 "Some description runs.",
611 fontDescriptionRuns03,
612 defaultFontDescription03,
613 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
617 expectedIsFontDefault03
620 const unsigned int numberOfTests = 3u;
622 for( unsigned int index = 0u; index < numberOfTests; ++index )
624 if( !MergeFontDescriptionsTest( data[index] ) )
626 tet_result(TET_FAIL);
630 tet_result(TET_PASS);
634 int UtcDaliTextMultiLanguageConstructor(void)
636 ToolkitTestApplication application;
637 tet_infoline(" UtcDaliTextMultiLanguageConstructor");
639 MultilanguageSupport multilanguageSupport;
640 DALI_TEST_CHECK( !multilanguageSupport );
642 MultilanguageSupport multilanguageSupport1 = MultilanguageSupport::Get();
643 DALI_TEST_CHECK( multilanguageSupport1 );
645 // To increase coverage.
646 MultilanguageSupport multilanguageSupport2 = MultilanguageSupport::Get();
647 DALI_TEST_CHECK( multilanguageSupport2 );
649 DALI_TEST_CHECK( multilanguageSupport1 == multilanguageSupport2 );
651 tet_result(TET_PASS);
655 int UtcDaliTextMultiLanguageSetScripts(void)
657 ToolkitTestApplication application;
658 tet_infoline(" UtcDaliTextMultiLanguageSetScripts" );
661 Vector<ScriptRun> scriptRuns00;
664 Vector<ScriptRun> scriptRuns01;
665 ScriptRun scriptRun0100 =
671 TextAbstraction::LATIN
673 scriptRuns01.PushBack( scriptRun0100 );
675 // Mix of LTR '\n'and RTL
676 Vector<ScriptRun> scriptRuns02;
677 ScriptRun scriptRun0200 =
683 TextAbstraction::LATIN
685 ScriptRun scriptRun0201 =
691 TextAbstraction::ARABIC
693 scriptRuns02.PushBack( scriptRun0200 );
694 scriptRuns02.PushBack( scriptRun0201 );
696 // Mix of RTL '\n'and LTR
697 Vector<ScriptRun> scriptRuns03;
698 ScriptRun scriptRun0300 =
704 TextAbstraction::ARABIC
706 ScriptRun scriptRun0301 =
712 TextAbstraction::LATIN
714 scriptRuns03.PushBack( scriptRun0300 );
715 scriptRuns03.PushBack( scriptRun0301 );
717 // White spaces. At the beginning of the text.
718 Vector<ScriptRun> scriptRuns04;
719 ScriptRun scriptRun0400 =
725 TextAbstraction::LATIN
727 scriptRuns04.PushBack( scriptRun0400 );
729 // White spaces. At the end of the text.
730 Vector<ScriptRun> scriptRuns05;
731 ScriptRun scriptRun0500 =
737 TextAbstraction::LATIN
739 scriptRuns05.PushBack( scriptRun0500 );
741 // White spaces. At the middle of the text.
742 Vector<ScriptRun> scriptRuns06;
743 ScriptRun scriptRun0600 =
749 TextAbstraction::LATIN
751 scriptRuns06.PushBack( scriptRun0600 );
753 // White spaces between different scripts.
754 Vector<ScriptRun> scriptRuns07;
755 ScriptRun scriptRun0700 =
761 TextAbstraction::LATIN
763 ScriptRun scriptRun0701 =
769 TextAbstraction::HANGUL
771 scriptRuns07.PushBack( scriptRun0700 );
772 scriptRuns07.PushBack( scriptRun0701 );
774 // White spaces between different scripts and differetn directions. Starting LTR.
775 Vector<ScriptRun> scriptRuns08;
776 ScriptRun scriptRun0800 =
782 TextAbstraction::LATIN
784 ScriptRun scriptRun0801 =
790 TextAbstraction::ARABIC
792 ScriptRun scriptRun0802 =
798 TextAbstraction::HANGUL
800 scriptRuns08.PushBack( scriptRun0800 );
801 scriptRuns08.PushBack( scriptRun0801 );
802 scriptRuns08.PushBack( scriptRun0802 );
804 // White spaces between different scripts and differetn directions. Starting RTL.
805 Vector<ScriptRun> scriptRuns09;
806 ScriptRun scriptRun0900 =
812 TextAbstraction::ARABIC
814 ScriptRun scriptRun0901 =
820 TextAbstraction::LATIN
822 ScriptRun scriptRun0902 =
828 TextAbstraction::HANGUL
830 ScriptRun scriptRun0903 =
836 TextAbstraction::ARABIC
838 scriptRuns09.PushBack( scriptRun0900 );
839 scriptRuns09.PushBack( scriptRun0901 );
840 scriptRuns09.PushBack( scriptRun0902 );
841 scriptRuns09.PushBack( scriptRun0903 );
843 // Paragraphs with different directions.
844 Vector<ScriptRun> scriptRuns10;
845 ScriptRun scriptRun1000 =
851 TextAbstraction::ARABIC
853 ScriptRun scriptRun1001 =
859 TextAbstraction::HEBREW
861 ScriptRun scriptRun1002 =
867 TextAbstraction::ARABIC
869 ScriptRun scriptRun1003 =
875 TextAbstraction::LATIN
877 ScriptRun scriptRun1004 =
883 TextAbstraction::HANGUL
885 ScriptRun scriptRun1005 =
891 TextAbstraction::ARABIC
893 ScriptRun scriptRun1006 =
899 TextAbstraction::LATIN
901 ScriptRun scriptRun1007 =
907 TextAbstraction::HEBREW
909 ScriptRun scriptRun1008 =
915 TextAbstraction::LATIN
917 ScriptRun scriptRun1009 =
923 TextAbstraction::ARABIC
925 ScriptRun scriptRun1010 =
931 TextAbstraction::HANGUL
933 ScriptRun scriptRun1011 =
939 TextAbstraction::HANGUL
941 scriptRuns10.PushBack( scriptRun1000 );
942 scriptRuns10.PushBack( scriptRun1001 );
943 scriptRuns10.PushBack( scriptRun1002 );
944 scriptRuns10.PushBack( scriptRun1003 );
945 scriptRuns10.PushBack( scriptRun1004 );
946 scriptRuns10.PushBack( scriptRun1005 );
947 scriptRuns10.PushBack( scriptRun1006 );
948 scriptRuns10.PushBack( scriptRun1007 );
949 scriptRuns10.PushBack( scriptRun1008 );
950 scriptRuns10.PushBack( scriptRun1009 );
951 scriptRuns10.PushBack( scriptRun1010 );
952 scriptRuns10.PushBack( scriptRun1011 );
954 // Paragraphs with no scripts mixed with paragraphs with scripts.
955 Vector<ScriptRun> scriptRuns11;
956 ScriptRun scriptRun1100 =
962 TextAbstraction::LATIN
964 ScriptRun scriptRun1101 =
970 TextAbstraction::LATIN
972 ScriptRun scriptRun1102 =
978 TextAbstraction::LATIN
980 ScriptRun scriptRun1103 =
986 TextAbstraction::LATIN
988 ScriptRun scriptRun1104 =
994 TextAbstraction::LATIN
996 ScriptRun scriptRun1105 =
1002 TextAbstraction::HEBREW
1004 ScriptRun scriptRun1106 =
1010 TextAbstraction::LATIN
1012 ScriptRun scriptRun1107 =
1018 TextAbstraction::LATIN
1020 ScriptRun scriptRun1108 =
1026 TextAbstraction::LATIN
1028 scriptRuns11.PushBack( scriptRun1100 );
1029 scriptRuns11.PushBack( scriptRun1101 );
1030 scriptRuns11.PushBack( scriptRun1102 );
1031 scriptRuns11.PushBack( scriptRun1103 );
1032 scriptRuns11.PushBack( scriptRun1104 );
1033 scriptRuns11.PushBack( scriptRun1105 );
1034 scriptRuns11.PushBack( scriptRun1106 );
1035 scriptRuns11.PushBack( scriptRun1107 );
1036 scriptRuns11.PushBack( scriptRun1108 );
1038 // Paragraphs with no scripts.
1039 Vector<ScriptRun> scriptRuns12;
1040 ScriptRun scriptRun1200 =
1046 TextAbstraction::LATIN
1048 ScriptRun scriptRun1201 =
1054 TextAbstraction::LATIN
1056 ScriptRun scriptRun1202 =
1062 TextAbstraction::LATIN
1064 ScriptRun scriptRun1203 =
1070 TextAbstraction::LATIN
1072 scriptRuns12.PushBack( scriptRun1200 );
1073 scriptRuns12.PushBack( scriptRun1201 );
1074 scriptRuns12.PushBack( scriptRun1202 );
1075 scriptRuns12.PushBack( scriptRun1203 );
1077 Vector<ScriptRun> scriptRuns13;
1078 ScriptRun scriptRun1301 =
1084 TextAbstraction::LATIN // An unknown script is transformed to LATIN
1086 scriptRuns13.PushBack( scriptRun1301 );
1088 const ScriptsData data[] =
1098 "Easy latin script",
1105 "Mix of LTR '\\n'and RTL",
1106 "Hello world\nمرحبا بالعالم",
1112 "Update mix of LTR '\\n'and RTL. Update LTR",
1113 "Hello world\nمرحبا بالعالم",
1119 "Update mix of LTR '\\n'and RTL. Update RTL",
1120 "Hello world\nمرحبا بالعالم",
1126 "Mix of RTL '\\n'and LTR",
1127 "مرحبا بالعالم\nHello world",
1133 "Update mix of RTL '\\n'and LTR. Update RTL",
1134 "مرحبا بالعالم\nHello world",
1140 "Update mix of RTL '\\n'and LTR. Update LTR",
1141 "مرحبا بالعالم\nHello world",
1147 "White spaces. At the beginning of the text.",
1154 "White spaces. At the end of the text.",
1161 "White spaces. At the middle of the text.",
1168 "White spaces between different scripts.",
1175 "White spaces between different scripts and differetn directions. Starting LTR.",
1176 " Hello world مرحبا بالعالم 안녕하세요 세계 ",
1182 "White spaces between different scripts and differetn directions. Starting RTL.",
1183 " مرحبا بالعالم Hello world 안녕하세요 세계 مرحبا بالعالم ",
1189 "Paragraphs with different directions.",
1190 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1191 " Hello world 안녕하세요 세계 \n "
1192 " مرحبا بالعالم Hello world שלום עולם \n "
1193 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1200 "Update paragraphs with different directions. Update initial paragraphs.",
1201 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1202 " Hello world 안녕하세요 세계 \n "
1203 " مرحبا بالعالم Hello world שלום עולם \n "
1204 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1211 "Update paragraphs with different directions. Update middle paragraphs.",
1212 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1213 " Hello world 안녕하세요 세계 \n "
1214 " مرحبا بالعالم Hello world שלום עולם \n "
1215 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1222 "Update paragraphs with different directions. Update final paragraphs.",
1223 " مرحبا بالعالم שלום עולם مرحبا بالعالم \n "
1224 " Hello world 안녕하세요 세계 \n "
1225 " مرحبا بالعالم Hello world שלום עולם \n "
1226 " Hello world مرحبا بالعالم 안녕하세요 세계 \n "
1233 "Paragraphs with no scripts mixed with paragraphs with scripts.",
1234 " \n \n Hello world \n \n \n שלום עולם \n \n \n ",
1240 "Paragraphs with no scripts.",
1247 "Update paragraphs with no scripts. Update initial paragraphs.",
1254 "Update paragraphs with no scripts. Update middle paragraphs.",
1261 "Update paragraphs with no scripts. Update final paragraphs.",
1269 "ᚩᚯᚱᚸ", // Runic script not currentlu supported.
1275 const unsigned int numberOfTests = 24u;
1277 for( unsigned int index = 0u; index < numberOfTests; ++index )
1279 if( !ScriptsTest( data[index] ) )
1281 tet_result(TET_FAIL);
1285 tet_result(TET_PASS);
1289 int UtcDaliTextMultiLanguageValidateFonts01(void)
1291 ToolkitTestApplication application;
1292 tet_infoline(" UtcDaliTextMultiLanguageValidateFonts");
1294 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1296 char* pathNamePtr = get_current_dir_name();
1297 const std::string pathName( pathNamePtr );
1298 free( pathNamePtr );
1300 const PointSize26Dot6 pointSize01 = static_cast<PointSize26Dot6>( 21.f * 64.f );
1301 const PointSize26Dot6 pointSize02 = static_cast<PointSize26Dot6>( 35.f * 64.f );
1304 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansArabicRegular.ttf" );
1305 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf" );
1306 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
1307 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize01 );
1308 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansRegular.ttf", pointSize02 );
1309 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize01 );
1310 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenSansHebrewRegular.ttf", pointSize02 );
1312 // Font id 1 --> TizenSansArabicRegular.ttf
1313 // Font id 2 --> TizenSansHebrewRegular.ttf
1314 // Font id 3 --> TizenColorEmoji.ttf
1315 // Font id 4 --> TizenSansRegular.ttf, size 8
1316 // Font id 5 --> TizenSansRegular.ttf, size 16
1317 // Font id 6 --> TizenSansHebrewRegular.ttf, size 8
1318 // Font id 7 --> TizenSansHebrewRegular.ttf, size 16
1319 // Font id 8 --> (default)
1321 Vector<FontRun> fontRuns01;
1322 Vector<FontDescriptionRun> fontDescriptions01;
1324 FontRun fontRun0201 =
1332 Vector<FontRun> fontRuns02;
1333 fontRuns02.PushBack( fontRun0201 );
1335 FontDescriptionRun fontDescription0201 =
1341 const_cast<char*>( "TizenSans" ),
1343 TextAbstraction::FontWeight::NORMAL,
1344 TextAbstraction::FontWidth::NORMAL,
1345 TextAbstraction::FontSlant::NORMAL,
1353 Vector<FontDescriptionRun> fontDescriptions02;
1354 fontDescriptions02.PushBack( fontDescription0201 );
1356 FontRun fontRun0301 =
1364 FontRun fontRun0302 =
1372 FontRun fontRun0303 =
1380 Vector<FontRun> fontRuns03;
1381 fontRuns03.PushBack( fontRun0301 );
1382 fontRuns03.PushBack( fontRun0302 );
1383 fontRuns03.PushBack( fontRun0303 );
1385 Vector<FontDescriptionRun> fontDescriptions03;
1387 FontRun fontRun0701 =
1395 FontRun fontRun0702 =
1403 FontRun fontRun0703 =
1411 Vector<FontRun> fontRuns07;
1412 fontRuns07.PushBack( fontRun0701 );
1413 fontRuns07.PushBack( fontRun0702 );
1414 fontRuns07.PushBack( fontRun0703 );
1416 FontDescriptionRun fontDescription0701 =
1422 const_cast<char*>( "TizenSansHebrew" ),
1424 TextAbstraction::FontWeight::NORMAL,
1425 TextAbstraction::FontWidth::NORMAL,
1426 TextAbstraction::FontSlant::NORMAL,
1434 FontDescriptionRun fontDescription0702 =
1440 const_cast<char*>( "TizenSansHebrew" ),
1442 TextAbstraction::FontWeight::NORMAL,
1443 TextAbstraction::FontWidth::NORMAL,
1444 TextAbstraction::FontSlant::NORMAL,
1452 Vector<FontDescriptionRun> fontDescriptions07;
1453 fontDescriptions07.PushBack( fontDescription0701 );
1454 fontDescriptions07.PushBack( fontDescription0702 );
1456 FontRun fontRun0801 =
1464 Vector<FontRun> fontRuns08;
1465 fontRuns08.PushBack( fontRun0801 );
1467 Vector<FontDescriptionRun> fontDescriptions08;
1469 FontRun fontRun0901 =
1477 Vector<FontRun> fontRuns09;
1478 fontRuns09.PushBack( fontRun0901 );
1480 Vector<FontDescriptionRun> fontDescriptions09;
1481 FontDescriptionRun fontDescription0901 =
1487 const_cast<char*>( "TizenColorEmoji" ),
1489 TextAbstraction::FontWeight::NORMAL,
1490 TextAbstraction::FontWidth::NORMAL,
1491 TextAbstraction::FontSlant::NORMAL,
1499 fontDescriptions09.PushBack( fontDescription0901 );
1501 FontRun fontRun1001 =
1509 FontRun fontRun1002 =
1517 FontRun fontRun1003 =
1525 FontRun fontRun1004 =
1533 Vector<FontRun> fontRuns10;
1534 fontRuns10.PushBack( fontRun1001 );
1535 fontRuns10.PushBack( fontRun1002 );
1536 fontRuns10.PushBack( fontRun1003 );
1537 fontRuns10.PushBack( fontRun1004 );
1539 FontDescriptionRun fontDescription1001 =
1545 const_cast<char*>( "TizenSans" ),
1547 TextAbstraction::FontWeight::NORMAL,
1548 TextAbstraction::FontWidth::NORMAL,
1549 TextAbstraction::FontSlant::NORMAL,
1557 FontDescriptionRun fontDescription1002 =
1563 const_cast<char*>( "TizenSansHebrew" ),
1565 TextAbstraction::FontWeight::NORMAL,
1566 TextAbstraction::FontWidth::NORMAL,
1567 TextAbstraction::FontSlant::NORMAL,
1575 FontDescriptionRun fontDescription1003 =
1581 const_cast<char*>( "TizenSans" ),
1583 TextAbstraction::FontWeight::NORMAL,
1584 TextAbstraction::FontWidth::NORMAL,
1585 TextAbstraction::FontSlant::NORMAL,
1593 FontDescriptionRun fontDescription1004 =
1599 const_cast<char*>( "TizenSansHebrew" ),
1601 TextAbstraction::FontWeight::NORMAL,
1602 TextAbstraction::FontWidth::NORMAL,
1603 TextAbstraction::FontSlant::NORMAL,
1611 Vector<FontDescriptionRun> fontDescriptions10;
1612 fontDescriptions10.PushBack( fontDescription1001 );
1613 fontDescriptions10.PushBack( fontDescription1002 );
1614 fontDescriptions10.PushBack( fontDescription1003 );
1615 fontDescriptions10.PushBack( fontDescription1004 );
1617 const ValidateFontsData data[] =
1622 "/tizen/TizenSansRegular.ttf",
1623 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1630 "Easy latin script.",
1632 "/tizen/TizenSansRegular.ttf",
1633 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1640 "Different paragraphs.",
1641 "Hello world\nhello world\ndemo",
1642 "/tizen/TizenSansRegular.ttf",
1643 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1650 "Different paragraphs. Update the initial paragraph.",
1651 "Hello world\nhello world\ndemo",
1652 "/tizen/TizenSansRegular.ttf",
1653 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1660 "Different paragraphs. Update the middle paragraph.",
1661 "Hello world\nhello world\ndemo",
1662 "/tizen/TizenSansRegular.ttf",
1663 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1670 "Different paragraphs. Update the final paragraph.",
1671 "Hello world\nhello world\ndemo",
1672 "/tizen/TizenSansRegular.ttf",
1673 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1680 "Hebrew text. Default font: latin",
1682 "/tizen/TizenSansRegular.ttf",
1683 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1690 "Hebrew text. Default font: hebrew",
1692 "/tizen/TizenSansHebrewRegular.ttf",
1693 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1701 "\xF0\x9F\x98\x81\xF0\x9F\x98\x82\xF0\x9F\x98\x83\xF0\x9F\x98\x84",
1702 "/tizen/TizenColorEmoji.ttf",
1710 "Mix text. Default font: latin. Different font sizes",
1711 "Hello world, שלום עולם, hello world, שלום עולם",
1712 "/tizen/TizenSansRegular.ttf",
1713 TextAbstraction::FontClient::DEFAULT_POINT_SIZE,
1720 const unsigned int numberOfTests = 10u;
1722 for( unsigned int index = 0u; index < numberOfTests; ++index )
1724 if( !ValidateFontTest( data[index] ) )
1726 tet_result(TET_FAIL);
1730 tet_result(TET_PASS);